use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class JmsOutboundGateway method sendAndReceiveWithoutContainer.
private javax.jms.Message sendAndReceiveWithoutContainer(Message<?> requestMessage) throws JMSException {
// NOSONAR - closed in ConnectionFactoryUtils.
Connection connection = this.createConnection();
Session session = null;
Destination replyTo = null;
try {
session = this.createSession(connection);
// convert to JMS Message
Object objectToSend = requestMessage;
if (this.extractRequestPayload) {
objectToSend = requestMessage.getPayload();
}
javax.jms.Message jmsRequest = this.messageConverter.toMessage(objectToSend, session);
// map headers
this.headerMapper.fromHeaders(requestMessage.getHeaders(), jmsRequest);
replyTo = this.determineReplyDestination(requestMessage, session);
jmsRequest.setJMSReplyTo(replyTo);
connection.start();
if (logger.isDebugEnabled()) {
logger.debug("ReplyTo: " + replyTo);
}
Integer priority = new IntegrationMessageHeaderAccessor(requestMessage).getPriority();
if (priority == null) {
priority = this.priority;
}
javax.jms.Message replyMessage = null;
Destination requestDestination = this.determineRequestDestination(requestMessage, session);
if (this.correlationKey != null) {
replyMessage = doSendAndReceiveWithGeneratedCorrelationId(requestDestination, jmsRequest, replyTo, session, priority);
} else if (replyTo instanceof TemporaryQueue || replyTo instanceof TemporaryTopic) {
replyMessage = doSendAndReceiveWithTemporaryReplyToDestination(requestDestination, jmsRequest, replyTo, session, priority);
} else {
replyMessage = doSendAndReceiveWithMessageIdCorrelation(requestDestination, jmsRequest, replyTo, session, priority);
}
return replyMessage;
} finally {
JmsUtils.closeSession(session);
this.deleteDestinationIfTemporary(replyTo);
ConnectionFactoryUtils.releaseConnection(connection, this.connectionFactory, true);
}
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class XPathMessageSplitterTests method splitDocumentWithCreateDocumentsTrue.
@Test
public void splitDocumentWithCreateDocumentsTrue() throws Exception {
this.splitter.setCreateDocuments(true);
Document doc = XmlTestUtil.getDocumentForString("<orders><order>one</order><order>two</order><order>three</order></orders>");
this.splitter.handleMessage(new GenericMessage<>(doc));
List<Message<?>> docMessages = this.replyChannel.clear();
assertEquals("Wrong number of messages", 3, docMessages.size());
for (Message<?> message : docMessages) {
assertThat(message.getPayload(), instanceOf(Document.class));
Document docPayload = (Document) message.getPayload();
assertEquals("Wrong root element name", "order", docPayload.getDocumentElement().getLocalName());
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize(), greaterThan(0));
}
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class XPathMessageSplitterTests method splitDocument.
@Test
public void splitDocument() throws Exception {
Document doc = XmlTestUtil.getDocumentForString("<orders><order>one</order><order>two</order><order>three</order></orders>");
this.splitter.handleMessage(new GenericMessage<>(doc));
List<Message<?>> docMessages = this.replyChannel.clear();
assertEquals("Wrong number of messages", 3, docMessages.size());
for (Message<?> message : docMessages) {
assertThat(message.getPayload(), instanceOf(Node.class));
assertThat(message.getPayload(), not(instanceOf(Document.class)));
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize(), greaterThan(0));
}
}
Aggregations