use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class BroadcastingDispatcherTests method applySequenceEnabled.
@Test
public void applySequenceEnabled() {
BroadcastingDispatcher dispatcher = new BroadcastingDispatcher();
dispatcher.setApplySequence(true);
final List<Message<?>> messages = Collections.synchronizedList(new ArrayList<Message<?>>());
MessageHandler target1 = new MessageStoringTestEndpoint(messages);
MessageHandler target2 = new MessageStoringTestEndpoint(messages);
MessageHandler target3 = new MessageStoringTestEndpoint(messages);
dispatcher.addHandler(target1);
dispatcher.addHandler(target2);
dispatcher.addHandler(target3);
Message<?> inputMessage = new GenericMessage<String>("test");
Object originalId = inputMessage.getHeaders().getId();
dispatcher.dispatch(inputMessage);
assertEquals(3, messages.size());
assertEquals(1, new IntegrationMessageHeaderAccessor(messages.get(0)).getSequenceNumber());
assertEquals(3, new IntegrationMessageHeaderAccessor(messages.get(0)).getSequenceSize());
assertEquals(originalId, new IntegrationMessageHeaderAccessor(messages.get(0)).getCorrelationId());
assertEquals(2, new IntegrationMessageHeaderAccessor(messages.get(1)).getSequenceNumber());
assertEquals(3, new IntegrationMessageHeaderAccessor(messages.get(1)).getSequenceSize());
assertEquals(originalId, new IntegrationMessageHeaderAccessor(messages.get(1)).getCorrelationId());
assertEquals(3, new IntegrationMessageHeaderAccessor(messages.get(2)).getSequenceNumber());
assertEquals(3, new IntegrationMessageHeaderAccessor(messages.get(2)).getSequenceSize());
assertEquals(originalId, new IntegrationMessageHeaderAccessor(messages.get(2)).getCorrelationId());
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class CorrelationIdTests method testCorrelationIdWithSplitterWhenNotValueSetOnIncomingMessage.
@Test
public void testCorrelationIdWithSplitterWhenNotValueSetOnIncomingMessage() throws Exception {
Message<?> message = new GenericMessage<String>("test1,test2");
QueueChannel testChannel = new QueueChannel();
MethodInvokingSplitter splitter = new MethodInvokingSplitter(new TestBean(), TestBean.class.getMethod("split", String.class));
splitter.setOutputChannel(testChannel);
splitter.handleMessage(message);
Message<?> reply1 = testChannel.receive(100);
Message<?> reply2 = testChannel.receive(100);
assertEquals(message.getHeaders().getId(), new IntegrationMessageHeaderAccessor(reply1).getCorrelationId());
assertEquals(message.getHeaders().getId(), new IntegrationMessageHeaderAccessor(reply2).getCorrelationId());
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class CorrelationIdTests method testCorrelationIdPassedIfAvailable.
@Test
public void testCorrelationIdPassedIfAvailable() {
Object correlationId = "123-ABC";
Message<String> message = MessageBuilder.withPayload("test").setCorrelationId(correlationId).build();
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel(1);
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(new TestBean(), "upperCase");
serviceActivator.setOutputChannel(outputChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, serviceActivator);
endpoint.start();
assertTrue(inputChannel.send(message));
Message<?> reply = outputChannel.receive(0);
assertEquals(correlationId, new IntegrationMessageHeaderAccessor(reply).getCorrelationId());
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class HeaderEnricherTests method correlationIdValue.
@Test
public void correlationIdValue() {
MessagingTemplate template = new MessagingTemplate();
MessageChannel channel = context.getBean("correlationIdValueInput", MessageChannel.class);
Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
assertNotNull(result);
assertEquals("ABC", new IntegrationMessageHeaderAccessor(result).getCorrelationId());
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class HeaderEnricherTests method expirationDateRef.
@Test
public void expirationDateRef() {
MessagingTemplate template = new MessagingTemplate();
MessageChannel channel = context.getBean("expirationDateRefInput", MessageChannel.class);
Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
assertNotNull(result);
assertEquals(new Long(9999), new IntegrationMessageHeaderAccessor(result).getExpirationDate());
}
Aggregations