Issue
- We are encountering an error related to Liferay's dispatch framework, where the system is attempting to process a non-existent dispatch trigger. The error message is as follows:
ERROR [liferay/dispatch/executor-2][ParallelDestination:50] Unable to process message {destinationName=liferay/dispatch/executor, response=null, responseDestinationName=null, responseId=null, payload={"dispatchTriggerId": 160841}, values={GROUP_NAME=DISPATCH_GROUP_0160841, companyId=47649, groupId=0, DESTINATION_NAME=liferay/dispatch/executor, JOB_STATE=com.liferay.portal.kernel.scheduler.JobState@414b72e6, STORAGE_TYPE=PERSISTED, JOB_NAME=DISPATCH_JOB_0160841}}
com.liferay.portal.kernel.messaging.MessageListenerException: com.liferay.dispatch.exception.NoSuchTriggerException: No DispatchTrigger exists with the primary key 160841
at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:32) ~[portal-kernel.jar:?]
at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:62) ~[portal-kernel.jar:?]
at com.liferay.portal.messaging.internal.ParallelDestination$1.run(ParallelDestination.java:47) [bundleFile:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: com.liferay.dispatch.exception.NoSuchTriggerException: No DispatchTrigger exists with the primary key 160841
at com.liferay.dispatch.service.persistence.impl.DispatchTriggerPersistenceImpl.findByPrimaryKey(DispatchTriggerPersistenceImpl.java:8247) ~[?:?]
at com.liferay.dispatch.service.persistence.impl.DispatchTriggerPersistenceImpl.findByPrimaryKey(DispatchTriggerPersistenceImpl.java:8265) ~[?:?]
at com.liferay.dispatch.service.impl.DispatchTriggerLocalServiceImpl.getDispatchTrigger(DispatchTriggerLocalServiceImpl.java:206) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:41) ~[portal-impl.jar:?]
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:60) ~[portal-impl.jar:?]
at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:48) ~[portal-impl.jar:?]
at com.liferay.change.tracking.internal.aop.CTTransactionAdvice.invoke(CTTransactionAdvice.java:70) ~[?:?]
at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:48) ~[portal-impl.jar:?]
at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:40) ~[portal-impl.jar:?]
at com.sun.proxy.$Proxy552.getDispatchTrigger(Unknown Source) ~[?:?]
at com.liferay.dispatch.internal.messaging.DispatchMessageListener.doReceive(DispatchMessageListener.java:47) ~[?:?]
at com.liferay.portal.kernel.messaging.BaseMessageListener.doReceive(BaseMessageListener.java:39) ~[portal-kernel.jar:?]
at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:25) ~[portal-kernel.jar:?]
The system continues to reference this non-existent trigger, causing errors in the dispatch execution process and logging it every 5 minutes.
Environment
- QR
Resolution
import com.liferay.portal.kernel.scheduler.messaging.SchedulerResponse;
import com.liferay.portal.kernel.scheduler.SchedulerEngineHelperUtil;
import com.liferay.portal.kernel.scheduler.StorageType;
String dispatchJob = "DISPATCH_JOB_0160841"
String dispatchGroup = "DISPATCH_GROUP_0160841"
try {
SchedulerResponse sr = SchedulerEngineHelperUtil.getScheduledJob(dispatchJob, dispatchGroup, StorageType.PERSISTED);
if(sr!=null){
out.println("Scheduler unlinked to delete: "+sr);
SchedulerEngineHelperUtil.delete(sr.getJobName(), sr.getGroupName(), sr.getStorageType());
}else{
out.println("Scheduler unlinked not found");
}
} catch (Exception e) {
throw new RuntimeException(e);
}