use of org.mule.runtime.core.api.construct.FlowConstruct in project mule by mulesoft.
the class MessageProcessingFlowTraceManagerTestCase method splitStack.
@Test
public void splitStack() {
CoreEvent event = buildEvent("newAnnotatedComponentCall");
PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName());
assertThat(getContextInfo(event, rootFlowConstruct), is(""));
manager.onPipelineNotificationStart(pipelineNotification);
assertThat(getContextInfo(event, rootFlowConstruct), is("at " + rootFlowConstruct.getName()));
manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, createMockProcessor("/comp", false)));
assertThat(getContextInfo(event, rootFlowConstruct), is("at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":unknown:-1)"));
CoreEvent eventCopy = buildEvent("newAnnotatedComponentCall", event.getFlowCallStack().clone());
assertThat(getContextInfo(eventCopy, rootFlowConstruct), is("at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":unknown:-1)"));
manager.onPipelineNotificationComplete(pipelineNotification);
assertThat(getContextInfo(event, rootFlowConstruct), is(""));
final FlowConstruct asyncFlowConstruct = mock(FlowConstruct.class);
when(asyncFlowConstruct.getName()).thenReturn("asyncFlow");
manager.onPipelineNotificationStart(buildPipelineNotification(eventCopy, asyncFlowConstruct.getName()));
manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy, createMockProcessor("/asyncComp", false)));
assertThat(getContextInfo(eventCopy, asyncFlowConstruct), is("at " + asyncFlowConstruct.getName() + "(/asyncComp @ " + APP_ID + ":unknown:-1)" + lineSeparator() + "at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":unknown:-1)"));
}
use of org.mule.runtime.core.api.construct.FlowConstruct in project mule by mulesoft.
the class DefaultExpressionManagerTestCase method flowName.
@Test
@Description("Verifies that the flow variable exposing it's name works.")
public void flowName() throws MuleException {
FlowConstruct mockFlowConstruct = mock(FlowConstruct.class);
when(mockFlowConstruct.getName()).thenReturn("myFlowName");
String result = (String) expressionManager.evaluate("#[flow.name]", testEvent(), fromSingleComponent(mockFlowConstruct.getName())).getValue();
assertThat(result, is(mockFlowConstruct.getName()));
}
use of org.mule.runtime.core.api.construct.FlowConstruct in project mule by mulesoft.
the class QueueManagerLifecycleOrderTestCase method testStartupOrder.
@Test
public void testStartupOrder() throws Exception {
((MuleContextWithRegistries) muleContext).getRegistry().registerObject(OBJECT_NOTIFICATION_DISPATCHER, mock(NotificationDispatcher.class));
FlowConstruct fc = new RecordingFlow("dummy", muleContext);
((MuleContextWithRegistries) muleContext).getRegistry().registerFlowConstruct(fc);
muleContext.start();
muleContext.stop();
assertEquals(4, startStopOrder.size());
assertSame(rtqm, startStopOrder.get(0));
assertSame(fc, startStopOrder.get(1));
assertSame(fc, startStopOrder.get(2));
assertSame(rtqm, startStopOrder.get(3));
}
use of org.mule.runtime.core.api.construct.FlowConstruct in project mule by mulesoft.
the class AsyncDelegateMessageProcessor method initialise.
@Override
public void initialise() throws InitialisationException {
Object rootContainer = getFromAnnotatedObject(componentLocator, this).orElse(null);
if (rootContainer instanceof FlowConstruct) {
if (maxConcurrency != null && rootContainer instanceof Pipeline) {
ProcessingStrategyFactory flowPsFactory = ((Pipeline) rootContainer).getProcessingStrategyFactory();
if (flowPsFactory instanceof AsyncProcessingStrategyFactory) {
((AsyncProcessingStrategyFactory) flowPsFactory).setMaxConcurrency(maxConcurrency);
} else {
logger.warn("{} does not support 'maxConcurrency'. Ignoring the value.", flowPsFactory.getClass().getSimpleName());
}
processingStrategy = flowPsFactory.create(muleContext, getLocation().getLocation());
ownProcessingStrategy = true;
} else {
processingStrategy = ((FlowConstruct) rootContainer).getProcessingStrategy();
}
} else {
processingStrategy = DIRECT_PROCESSING_STRATEGY_INSTANCE;
}
if (delegateBuilder == null) {
throw new InitialisationException(objectIsNull("delegate message processor"), this);
}
delegateBuilder.setProcessingStrategy(processingStrategy);
delegate = delegateBuilder.build();
initialiseIfNeeded(delegate, muleContext);
super.initialise();
}
use of org.mule.runtime.core.api.construct.FlowConstruct in project mule by mulesoft.
the class UntilSuccessful method initialise.
@Override
public void initialise() throws InitialisationException {
if (processors == null) {
throw new InitialisationException(createStaticMessage("One message processor must be configured within 'until-successful'."), this);
}
this.nestedChain = newChain(getProcessingStrategy(locator, getRootContainerLocation()), processors);
super.initialise();
timer = muleContext.getSchedulerService().cpuLightScheduler();
policyTemplate = new SimpleRetryPolicyTemplate(millisBetweenRetries, maxRetries);
shouldRetry = event -> event.getError().isPresent();
Object rootContainer = getFromAnnotatedObject(componentLocator, this).orElse(null);
if (rootContainer instanceof FlowConstruct) {
processingStrategy = ((FlowConstruct) rootContainer).getProcessingStrategy();
} else {
processingStrategy = DIRECT_PROCESSING_STRATEGY_INSTANCE;
}
}
Aggregations