use of org.springframework.integration.router.RecipientListRouter in project spring-integration by spring-projects.
the class IntegrationManagementConfigurerTests method testDefaults.
@Test
public void testDefaults() {
DirectChannel channel = new DirectChannel();
AbstractMessageHandler handler = new RecipientListRouter();
AbstractMessageSource<?> source = new AbstractMessageSource<Object>() {
@Override
public String getComponentType() {
return null;
}
@Override
protected Object doReceive() {
return null;
}
};
assertTrue(channel.isLoggingEnabled());
assertTrue(handler.isLoggingEnabled());
assertTrue(source.isLoggingEnabled());
channel.setCountsEnabled(true);
channel.setStatsEnabled(true);
ApplicationContext ctx = mock(ApplicationContext.class);
Map<String, IntegrationManagement> beans = new HashMap<String, IntegrationManagement>();
beans.put("foo", channel);
beans.put("bar", handler);
beans.put("baz", source);
when(ctx.getBeansOfType(IntegrationManagement.class)).thenReturn(beans);
IntegrationManagementConfigurer configurer = new IntegrationManagementConfigurer();
configurer.setBeanName(IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME);
configurer.setApplicationContext(ctx);
configurer.setDefaultLoggingEnabled(false);
configurer.afterSingletonsInstantiated();
assertFalse(channel.isLoggingEnabled());
assertFalse(handler.isLoggingEnabled());
assertFalse(source.isLoggingEnabled());
assertTrue(channel.isCountsEnabled());
assertTrue(channel.isStatsEnabled());
}
use of org.springframework.integration.router.RecipientListRouter in project spring-integration by spring-projects.
the class RecipientListRouterParserTests method customRouter.
@Test
public void customRouter() {
Object endpoint = context.getBean("customRouter");
Object handler = TestUtils.getPropertyValue(endpoint, "handler");
assertEquals(RecipientListRouter.class, handler.getClass());
RecipientListRouter router = (RecipientListRouter) handler;
DirectFieldAccessor accessor = new DirectFieldAccessor(router);
assertEquals(new Long(1234), new DirectFieldAccessor(accessor.getPropertyValue("messagingTemplate")).getPropertyValue("sendTimeout"));
assertEquals(Boolean.TRUE, accessor.getPropertyValue("applySequence"));
assertEquals(Boolean.TRUE, accessor.getPropertyValue("ignoreSendFailures"));
}
use of org.springframework.integration.router.RecipientListRouter in project spring-integration by spring-projects.
the class RecipientListRouterParserTests method simpleRouter.
@Test
public void simpleRouter() {
Object endpoint = context.getBean("simpleRouter");
Object handler = TestUtils.getPropertyValue(endpoint, "handler");
assertEquals(RecipientListRouter.class, handler.getClass());
RecipientListRouter router = (RecipientListRouter) handler;
DirectFieldAccessor accessor = new DirectFieldAccessor(router);
assertEquals(new Long(-1), new DirectFieldAccessor(accessor.getPropertyValue("messagingTemplate")).getPropertyValue("sendTimeout"));
assertEquals(Boolean.FALSE, accessor.getPropertyValue("applySequence"));
assertEquals(Boolean.FALSE, accessor.getPropertyValue("ignoreSendFailures"));
}
use of org.springframework.integration.router.RecipientListRouter in project spring-integration by spring-projects.
the class IntegrationFlowDefinition method scatterGather.
/**
* Populate a {@link ScatterGatherHandler} to the current integration flow position
* based on the provided {@link RecipientListRouterSpec} for scattering function
* and {@link AggregatorSpec} for gathering function.
* @param scatterer the {@link Consumer} for {@link RecipientListRouterSpec} to configure scatterer.
* @param gatherer the {@link Consumer} for {@link AggregatorSpec} to configure gatherer.
* @param scatterGather the {@link Consumer} for {@link ScatterGatherSpec} to configure
* {@link ScatterGatherHandler} and its endpoint. Can be {@code null}.
* @return the current {@link IntegrationFlowDefinition}.
*/
public B scatterGather(Consumer<RecipientListRouterSpec> scatterer, Consumer<AggregatorSpec> gatherer, Consumer<ScatterGatherSpec> scatterGather) {
Assert.notNull(scatterer, "'scatterer' must not be null");
RecipientListRouterSpec recipientListRouterSpec = new RecipientListRouterSpec();
scatterer.accept(recipientListRouterSpec);
AggregatorSpec aggregatorSpec = new AggregatorSpec();
if (gatherer != null) {
gatherer.accept(aggregatorSpec);
}
RecipientListRouter recipientListRouter = recipientListRouterSpec.get().getT2();
addComponent(recipientListRouter).addComponents(recipientListRouterSpec.getComponentsToRegister());
AggregatingMessageHandler aggregatingMessageHandler = aggregatorSpec.get().getT2();
addComponent(aggregatingMessageHandler);
ScatterGatherHandler messageHandler = new ScatterGatherHandler(recipientListRouter, aggregatingMessageHandler);
return register(new ScatterGatherSpec(messageHandler), scatterGather);
}
Aggregations