use of org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity in project Activiti by Activiti.
the class EventSubscriptionQueryTest method testQueryByEventName.
public void testQueryByEventName() {
processEngineConfiguration.getCommandExecutor().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity1.setEventName("messageName");
messageEventSubscriptionEntity1.insert();
MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity2.setEventName("messageName");
messageEventSubscriptionEntity2.insert();
MessageEventSubscriptionEntity messageEventSubscriptionEntity3 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity3.setEventName("messageName2");
messageEventSubscriptionEntity3.insert();
return null;
}
});
List<EventSubscriptionEntity> list = newEventSubscriptionQuery().eventName("messageName").list();
assertEquals(2, list.size());
list = newEventSubscriptionQuery().eventName("messageName2").list();
assertEquals(1, list.size());
cleanDb();
}
use of org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity in project Activiti by Activiti.
the class IntermediateCatchMessageEventActivityBehavior method deleteMessageEventSubScription.
protected ExecutionEntity deleteMessageEventSubScription(DelegateExecution execution) {
ExecutionEntity executionEntity = (ExecutionEntity) execution;
// Should we use triggerName and triggerData, because message name expression can change?
String messageName = messageExecutionContext.getMessageName(execution);
EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
if (eventSubscription instanceof MessageEventSubscriptionEntity && eventSubscription.getEventName().equals(messageName)) {
eventSubscriptionEntityManager.delete(eventSubscription);
}
}
return executionEntity;
}
use of org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity in project Activiti by Activiti.
the class IntermediateCatchMessageEventActivityBehavior method execute.
public void execute(DelegateExecution execution) {
CommandContext commandContext = Context.getCommandContext();
MessageEventSubscriptionEntity subscription = messageExecutionContext.createMessageEventSubscription(commandContext, execution);
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createMessageWaitingEvent(execution, subscription.getEventName(), subscription.getConfiguration()));
}
}
use of org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity in project Activiti by Activiti.
the class EventSubProcessMessageStartEventActivityBehavior method trigger.
@Override
public void trigger(DelegateExecution execution, String triggerName, Object triggerData) {
CommandContext commandContext = Context.getCommandContext();
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
ExecutionEntity executionEntity = (ExecutionEntity) execution;
StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement();
if (startEvent.isInterrupting()) {
List<ExecutionEntity> childExecutions = executionEntityManager.findChildExecutionsByParentExecutionId(executionEntity.getParentId());
for (ExecutionEntity childExecution : childExecutions) {
if (!childExecution.getId().equals(executionEntity.getId())) {
executionEntityManager.cancelExecutionAndRelatedData(childExecution, DeleteReason.EVENT_SUBPROCESS_INTERRUPTING + "(" + startEvent.getId() + ")");
}
}
}
// Should we use triggerName and triggerData, because message name expression can change?
String messageName = messageExecutionContext.getMessageName(execution);
EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
if (eventSubscription instanceof MessageEventSubscriptionEntity && eventSubscription.getEventName().equals(messageName)) {
eventSubscriptionEntityManager.delete(eventSubscription);
}
}
executionEntity.setCurrentFlowElement((SubProcess) executionEntity.getCurrentFlowElement().getParentContainer());
executionEntity.setScope(true);
ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(executionEntity);
outgoingFlowExecution.setCurrentFlowElement(startEvent);
leave(outgoingFlowExecution);
}
use of org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity in project Activiti by Activiti.
the class BoundaryMessageEventActivityBehavior method trigger.
@Override
public void trigger(DelegateExecution execution, String triggerName, Object triggerData) {
ExecutionEntity executionEntity = (ExecutionEntity) execution;
BoundaryEvent boundaryEvent = (BoundaryEvent) execution.getCurrentFlowElement();
// Should we use triggerName and triggerData, because message name expression can change?
String messageName = messageExecutionContext.getMessageName(execution);
if (boundaryEvent.isCancelActivity()) {
EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
if (eventSubscription instanceof MessageEventSubscriptionEntity && eventSubscription.getEventName().equals(messageName)) {
eventSubscriptionEntityManager.delete(eventSubscription);
}
}
}
super.trigger(executionEntity, triggerName, triggerData);
}
Aggregations