Apache camel Apache camel ProducerTemplate asyncSendBody集JMS头和属性
Apache camel api具有Apache camel Apache camel ProducerTemplate asyncSendBody集JMS头和属性,apache-camel,jms,spring-jms,Apache Camel,Jms,Spring Jms,Apache camel api具有ProducerTemplate.asyncSendBody(端点,对象体)。 我使用上面的命令将消息发送到远程端点 我想知道如何设置其他JMS属性和头 我看到有一个api sendBodyAndHeader()允许这样做。在异步api中它的等价物是什么?您可以使用asyncRequestBodyAndHeader方法异步发送骆驼交换。驼峰交换将在exchange.InOutMEP中发送 这是一个你可以遵循的测试用例 protected Object expe
ProducerTemplate.asyncSendBody(端点,对象体)
。
我使用上面的命令将消息发送到远程端点
我想知道如何设置其他JMS属性和头
我看到有一个api sendBodyAndHeader()允许这样做。在异步api中它的等价物是什么?您可以使用
asyncRequestBodyAndHeader
方法异步发送骆驼交换。驼峰交换将在exchange.InOut
MEP中发送
这是一个你可以遵循的测试用例
protected Object expectedBody = "<time>" + new Date() + "";
protected ActiveMQQueue replyQueue = new ActiveMQQueue("test.reply.queue");
protected String correlationID = "ABC-123";
protected String messageType = getClass().getName();
public void testForwardingAMessageAcrossJMSKeepingCustomJMSHeaders() throws Exception {
MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
resultEndpoint.expectedBodiesReceived(expectedBody);
AssertionClause firstMessageExpectations = resultEndpoint.message(0);
firstMessageExpectations.header("cheese").isEqualTo(123); firstMessageExpectations.header("JMSReplyTo").isEqualTo(replyQueue);
firstMessageExpectations.header("JMSCorrelationID").isEqualTo(correlationID);
firstMessageExpectations.header("JMSType").isEqualTo(messageType);
template.asyncRequestBodyAndHeader("activemq:test.a", expectedBody, "cheese", 123);
resultEndpoint.assertIsSatisfied();
List<Exchange> list = resultEndpoint.getReceivedExchanges();
Exchange exchange = list.get(0);
Object replyTo = exchange.getIn().getHeader("JMSReplyTo");
LOG.info("Reply to is: " + replyTo);
Destination destination = assertIsInstanceOf(Destination.class, replyTo);
assertEquals("ReplyTo", replyQueue.toString(), destination.toString());
}
受保护对象expectedBody=“+新日期()+”;
受保护的ActiveMQQueue replyQueue=新的ActiveMQQueue(“test.reply.queue”);
受保护的字符串correlationID=“ABC-123”;
受保护的字符串messageType=getClass().getName();
public void TestForwardingMessageAcrossJMSkeepingCustomJMsheaders()引发异常{
MockEndpoint resultEndpoint=resolveMandatoryEndpoint(“mock:result”,MockEndpoint.class);
结果点:接受的预期身体(预期身体);
断言Lause FirstMessageExpections=resultEndpoint.message(0);
firstmessageexpections.header(“cheese”).isEqualTo(123);firstmessageexpections.header(“JMSReplyTo”).isEqualTo(replyQueue);
firstMessageExpections.header(“JMSCorrelationID”).isEqualTo(correlationID);
firstMessageExpections.header(“JMSType”).isEqualTo(messageType);
asyncRequestBodyAndHeader(“activemq:test.a”,expectedBody,“cheese”,123);
resultEndpoint.Assertessatified();
List List=resultEndpoint.getReceivedExchanges();
Exchange=list.get(0);
对象replyTo=exchange.getIn().getHeader(“JMSReplyTo”);
LOG.info(“回复为:+replyTo”);
Destination Destination=assertIsInstanceOf(Destination.class,replyTo);
assertEquals(“ReplyTo”,replyQueue.toString(),destination.toString());
}