use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class MethodInvokingRouterTests method channelNameResolutionByPayloadConfiguredByMethodName.
@Test
public void channelNameResolutionByPayloadConfiguredByMethodName() {
QueueChannel barChannel = new QueueChannel();
TestChannelResolver channelResolver = new TestChannelResolver();
channelResolver.addChannel("bar-channel", barChannel);
SingleChannelNameRoutingTestBean testBean = new SingleChannelNameRoutingTestBean();
MethodInvokingRouter router = new MethodInvokingRouter(testBean, "routePayload");
router.setChannelResolver(channelResolver);
Message<String> message = new GenericMessage<String>("bar");
router.handleMessage(message);
Message<?> replyMessage = barChannel.receive();
assertNotNull(replyMessage);
assertEquals(message, replyMessage);
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class MethodInvokingRouterTests method doTestChannelNameResolutionByMessage.
private void doTestChannelNameResolutionByMessage(MethodInvokingRouter router) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
TestChannelResolver channelResolver = new TestChannelResolver();
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1 = fooChannel.receive(0);
assertNotNull(result1);
assertEquals("foo", result1.getPayload());
router.handleMessage(barMessage);
Message<?> result2 = barChannel.receive(0);
assertNotNull(result2);
assertEquals("bar", result2.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
/* Success */
}
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class MethodInvokingRouterTests method doTestMultiChannelArrayResolutionByMessage.
private void doTestMultiChannelArrayResolutionByMessage(MethodInvokingRouter router, TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1a = fooChannel.receive(0);
Message<?> result1b = barChannel.receive(0);
assertNotNull(result1a);
assertEquals("foo", result1a.getPayload());
assertNotNull(result1b);
assertEquals("foo", result1b.getPayload());
router.handleMessage(barMessage);
Message<?> result2a = fooChannel.receive(0);
Message<?> result2b = barChannel.receive(0);
assertNotNull(result2a);
assertEquals("bar", result2a.getPayload());
assertNotNull(result2b);
assertEquals("bar", result2b.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
/* Success */
}
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class MethodInvokingRouterTests method doTestMultiChannelNameArrayResolutionByMessage.
private void doTestMultiChannelNameArrayResolutionByMessage(MethodInvokingRouter router, TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1a = fooChannel.receive(0);
assertNotNull(result1a);
assertEquals("foo", result1a.getPayload());
Message<?> result1b = barChannel.receive(0);
assertNotNull(result1b);
assertEquals("foo", result1b.getPayload());
router.handleMessage(barMessage);
Message<?> result2a = fooChannel.receive(0);
assertNotNull(result2a);
assertEquals("bar", result2a.getPayload());
Message<?> result2b = barChannel.receive(0);
assertNotNull(result2b);
assertEquals("bar", result2b.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
/* Success */
}
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class MethodInvokingRouterTests method doTestMultiChannelNameResolutionByMessage.
private void doTestMultiChannelNameResolutionByMessage(MethodInvokingRouter router, TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1a = fooChannel.receive(0);
assertNotNull(result1a);
assertEquals("foo", result1a.getPayload());
Message<?> result1b = barChannel.receive(0);
assertNotNull(result1b);
assertEquals("foo", result1b.getPayload());
router.handleMessage(barMessage);
Message<?> result2a = fooChannel.receive(0);
assertNotNull(result2a);
assertEquals("bar", result2a.getPayload());
Message<?> result2b = barChannel.receive(0);
assertNotNull(result2b);
assertEquals("bar", result2b.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
/* Success */
}
}
Aggregations