use of org.mule.runtime.core.api.processor.strategy.ProcessingStrategyFactory in project mule by mulesoft.
the class DefaultFlowBuilderTestCase method buildsFullFlow.
@Test
public void buildsFullFlow() throws Exception {
Processor processor1 = mock(Processor.class);
Processor processor2 = mock(Processor.class);
List<Processor> messageProcessors = new ArrayList<>();
messageProcessors.add(processor1);
messageProcessors.add(processor2);
MessageSource messageSource = mock(MessageSource.class);
ProcessingStrategyFactory processingStrategyFactory = mock(ProcessingStrategyFactory.class);
ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class);
when(processingStrategyFactory.create(any(), any())).thenReturn(processingStrategy);
FlowExceptionHandler exceptionListener = mock(FlowExceptionHandler.class);
Flow flow = flowBuilder.processors(messageProcessors).source(messageSource).processingStrategyFactory(processingStrategyFactory).messagingExceptionHandler(exceptionListener).build();
assertThat(flow.getName(), equalTo(FLOW_NAME));
assertThat(flow.getMuleContext(), is(muleContext));
assertThat(flow.getProcessors(), contains(processor1, processor2));
assertThat(flow.getSource(), is(messageSource));
assertThat(flow.getExceptionListener(), is(exceptionListener));
assertThat(flow.getProcessingStrategy(), sameInstance(processingStrategy));
}
use of org.mule.runtime.core.api.processor.strategy.ProcessingStrategyFactory in project mule by mulesoft.
the class FlowProcessingStrategyTestCase method fixedProcessingStrategyIsHonoured.
@Test
public void fixedProcessingStrategyIsHonoured() throws Exception {
ProcessingStrategyFactory processingStrategyFactory = mock(ProcessingStrategyFactory.class);
ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class);
when(processingStrategyFactory.create(any(), any())).thenReturn(processingStrategy);
createFlow(processingStrategyFactory);
flow.initialise();
assertThat(flow.getProcessingStrategy(), is(sameInstance(processingStrategy)));
}
use of org.mule.runtime.core.api.processor.strategy.ProcessingStrategyFactory in project mule by mulesoft.
the class FlowProcessingStrategyTestCase method defaultProcessingStrategyInConfigIsHonoured.
@Test
public void defaultProcessingStrategyInConfigIsHonoured() throws Exception {
ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class);
ProcessingStrategyFactory processingStrategyFactory = mock(ProcessingStrategyFactory.class);
when(processingStrategyFactory.create(any(), any())).thenReturn(processingStrategy);
when(configuration.getDefaultProcessingStrategyFactory()).thenReturn(processingStrategyFactory);
createFlow(null);
flow.initialise();
assertThat(flow.getProcessingStrategy(), is(sameInstance(processingStrategy)));
}
use of org.mule.runtime.core.api.processor.strategy.ProcessingStrategyFactory 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.processor.strategy.ProcessingStrategyFactory in project mule by mulesoft.
the class FlowProcessingStrategyTestCase method fixedProcessingStrategyTakesPrecedenceOverConfig.
@Test
public void fixedProcessingStrategyTakesPrecedenceOverConfig() throws Exception {
ProcessingStrategyFactory configProcessingStrategyFactory = mock(ProcessingStrategyFactory.class);
when(configuration.getDefaultProcessingStrategyFactory()).thenReturn(configProcessingStrategyFactory);
ProcessingStrategyFactory processingStrategyFactory = mock(ProcessingStrategyFactory.class);
ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class);
when(processingStrategyFactory.create(any(), any())).thenReturn(processingStrategy);
createFlow(processingStrategyFactory);
flow.initialise();
assertThat(flow.getProcessingStrategy(), is(sameInstance(processingStrategy)));
}
Aggregations