flowable/flowable-engine · error · FlowableIllegalArgumentException
Cannot throw process-instance scoped message, since the disp
Error message
Cannot throw process-instance scoped message, since the dispatched event is not part of an ongoing process instance
What it means
MessageThrowingEventListener.onEvent throws this FlowableIllegalArgumentException when the event listener is configured to throw a process-instance-scoped message, but the dispatched FlowableEngineEvent has a null processInstanceId. Message subscriptions are looked up per process instance, so an execution/process-instance context is mandatory.
Source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/MessageThrowingEventListener.java:44
/**
* An {@link FlowableEventListener} that throws a message event when an event is dispatched to it. Sends the message to the execution the event was fired from. If the execution is not subscribed to a
* message, the process-instance is checked.
*
* @author Tijs Rademakers
*
*/
public class MessageThrowingEventListener extends BaseDelegateEventListener {
protected String messageName;
protected Class<?> entityClass;
@Override
public void onEvent(FlowableEvent event) {
if (isValidEvent(event) && event instanceof FlowableEngineEvent engineEvent) {
if (engineEvent.getProcessInstanceId() == null) {
throw new FlowableIllegalArgumentException("Cannot throw process-instance scoped message, since the dispatched event is not part of an ongoing process instance");
}
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
List<MessageEventSubscriptionEntity> subscriptionEntities = processEngineConfiguration.getEventSubscriptionServiceConfiguration()
.getEventSubscriptionService().findMessageEventSubscriptionsByProcessInstanceAndEventName(engineEvent.getProcessInstanceId(), messageName);
for (EventSubscriptionEntity messageEventSubscriptionEntity : subscriptionEntities) {
EventSubscriptionUtil.eventReceived(messageEventSubscriptionEntity, null, false);
}
}
}
public void setMessageName(String messageName) {
this.messageName = messageName;
}
@Override
public boolean isFailOnException() {View on GitHub (pinned to d6d39ce1c6)
Solutions
- Restrict the listener's event types (via event-listener XML 'events' attribute or addEventProcessor filtering) to those always carrying a processInstanceId (activity, task, job execution events).
- Check engineEvent.getProcessInstanceId() != null before delegating to the listener in a wrapper listener.
- If the signal/message is not meant to be process-scoped, set the listener's scope accordingly so this branch isn't taken.
- If triggering messages externally, use runtimeService.messageEventReceived with an explicit subscription instead of the event listener.
Example fix
// before
listenerRegistry.addGlobalEventListener(new MessageThrowingEventListener(...)); // receives every event
// after
if (event instanceof FlowableEngineEvent e && e.getProcessInstanceId() != null) {
messageThrowingEventListener.onEvent(event);
} Defensive patterns
Strategy: type-guard
Validate before calling
if (engineEvent.getProcessInstanceId() == null) return; // not process-scoped
Type guard
static boolean isProcessScoped(FlowableEvent event) {
return event instanceof FlowableEngineEvent && ((FlowableEngineEvent) event).getProcessInstanceId() != null;
} Try / catch
try {
listener.onEvent(event);
} catch (FlowableIllegalArgumentException e) {
if (e.getMessage().contains("not part of an ongoing process instance")) {
logger.warn("skipping process-scoped message for execution-less event {}", event.getType());
}
} Prevention
- Only register process-scoped message listeners for events with a processInstanceId.
- Restrict the 'events' attribute in listener XML to concrete activity/job events.
- Prefer runtimeService.messageEventReceived for external message delivery.
When it happens
Trigger: A 'message' event listener with processInstanceScope=true receives an engine event not tied to a running process instance (processInstanceId == null), e.g. an engine-level or job-level event.
Common situations: Global event listeners registered in process engine configuration that react to all event types; events fired during deployment or engine startup that carry no process instance; listener attached to a scope event (e.g. FLOWABLE_ENGINE) instead of an activity/job event within a process.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Cannot throw process-instance scoped signal, since the dispa
- No execution context active and event (" + event + ") is not
- Cannot create an event-throwing event-listener, unknown impl
- Unsupported entity-type for a FlowableEventListener: " + ent
- BPMN XSD could not be found
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/f3bb8c8fe1acb0c6.
Report an issue: GitHub.