use of org.mule.runtime.core.api.context.notification.FlowCallStack in project mule by mulesoft.
the class MessageProcessingFlowTraceManagerTestCase method joinStackEnd.
@Test
public void joinStackEnd() {
CoreEvent event = buildEvent("joinStack");
PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName());
manager.onPipelineNotificationStart(pipelineNotification);
manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, createMockProcessor("/scatter-gather", false)));
FlowCallStack flowCallStack = event.getFlowCallStack();
CoreEvent eventCopy0 = buildEvent("joinStack_0", flowCallStack.clone());
CoreEvent eventCopy1 = buildEvent("joinStack_1", flowCallStack.clone());
manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy0, createMockProcessor("/route_0", false)));
manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy1, createMockProcessor(NESTED_FLOW_NAME + "_ref", false)));
PipelineMessageNotification pipelineNotificationNested = buildPipelineNotification(eventCopy1, NESTED_FLOW_NAME);
manager.onPipelineNotificationStart(pipelineNotificationNested);
manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy1, createMockProcessor("/route_1", false)));
manager.onPipelineNotificationComplete(pipelineNotificationNested);
manager.onPipelineNotificationComplete(pipelineNotification);
assertThat(((BaseEventContext) event.getContext()).getProcessorsTrace(), hasExecutedProcessors("/scatter-gather @ " + APP_ID + ":unknown:-1", "/route_0 @ " + APP_ID + ":unknown:-1", NESTED_FLOW_NAME + "_ref @ " + APP_ID + ":unknown:-1", "/route_1 @ " + APP_ID + ":unknown:-1"));
}
use of org.mule.runtime.core.api.context.notification.FlowCallStack in project mule by mulesoft.
the class MessageProcessingFlowTraceManagerTestCase method splitStackEnd.
@Test
public void splitStackEnd() {
CoreEvent event = buildEvent("newAnnotatedComponentCall");
PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName());
manager.onPipelineNotificationStart(pipelineNotification);
manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, createMockProcessor("/comp", false)));
FlowCallStack flowCallStack = event.getFlowCallStack();
CoreEvent eventCopy = buildEvent("newAnnotatedComponentCall", flowCallStack.clone());
manager.onPipelineNotificationComplete(pipelineNotification);
String asyncFlowName = "asyncFlow";
manager.onPipelineNotificationStart(buildPipelineNotification(eventCopy, asyncFlowName));
manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy, createMockProcessor("/asyncComp", false)));
assertThat(((BaseEventContext) event.getContext()).getProcessorsTrace(), hasExecutedProcessors("/comp @ " + APP_ID + ":unknown:-1", "/asyncComp @ " + APP_ID + ":unknown:-1"));
}
use of org.mule.runtime.core.api.context.notification.FlowCallStack in project mule by mulesoft.
the class MessageProcessingFlowTraceManager method onMessageProcessorNotificationPreInvoke.
/**
* Callback method for when a message processor is about to be invoked.
* <p/>
* Updates the internal state of the event's {@link ProcessorsTrace} and {@link FlowCallStack} accordingly.
*
* @see DefaultProcessorsTrace#addExecutedProcessors(String)
* @see DefaultFlowCallStack#setCurrentProcessorPath(String)
*
* @param notification the notification that contains the event and the processor that is about to be invoked.
*/
public void onMessageProcessorNotificationPreInvoke(MessageProcessorNotification notification) {
String resolveProcessorRepresentation = resolveProcessorRepresentation(muleContext.getConfiguration().getId(), notification.getComponent().getLocation() != null ? notification.getComponent().getLocation().getLocation() : null, notification.getComponent());
EventContext eventContext = notification.getEventContext();
if (eventContext != null) {
((DefaultProcessorsTrace) ((BaseEventContext) eventContext).getProcessorsTrace()).addExecutedProcessors(resolveProcessorRepresentation);
}
FlowCallStack flowCallStack = ((CoreEvent) notification.getEvent()).getFlowCallStack();
if (flowCallStack != null) {
((DefaultFlowCallStack) flowCallStack).setCurrentProcessorPath(resolveProcessorRepresentation);
}
}
Aggregations