发送消息从HTTP端点JMS [英] Sending message from HTTP endpoint to JMS

查看:252
本文介绍了发送消息从HTTP端点JMS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个骆驼的路线,这将接受一个HTTP端点的有效载荷,然后写一个有效载荷到JMS队列。

I am trying to have a camel route, which would accept a payload on a http endpoint and then write that payload to a JMS queue.

这是我到目前为止的路线如下。但是一个空消息被传递到JMS队列。消息到达那里,但它没有身体。

The route that I have so far is below. But an empty message gets delivered to the jms queue. A message gets there, but it has no body.

继承人的路线:

<route >
    <from uri="jetty:http://0.0.0.0:8050/add/Customer"/>
    <inOnly uri="jms:queue:Q.Customer" />
</route>

继承人,我要送进到 http://0.0.0.0:8050/add/Customer '端点有效载荷:

 <Customer xmlns="http://www.openapplications.org/9" xmlns:lw="http://www.org/9">
    <Name>John</Name>
    <Gender>Female</Gender>
 </Customer>

的原因的消息主体未写入到JMS队列不限输入?
谢谢...

Any inputs on why the message body is not being written to the jms queue? Thanks...

推荐答案

您的路线如预期的工作。我用下面的设置进行了测试:

Your routes worked as expected. I tested it with following setup:

<broker xmlns="http://activemq.apache.org/schema/core" useJmx="true" persistent="false">
    <transportConnectors>
        <transportConnector uri="tcp://localhost:61616" />
    </transportConnectors>
</broker>

<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="failover:tcp://localhost:61616" />
</bean>

<camelContext xmlns="http://camel.apache.org/schema/spring">
    <route >
        <from uri="jetty:http://0.0.0.0:8050/add/Customer"/>
        <inOnly uri="jms:queue:Q.Customer" />
    </route>
    <route>
        <from uri="jms:queue:Q.Customer" />
        <log message="Body: ${body}" />
    </route>
</camelContext>

我测试使用 org.apache.camel.spring.Main 辅助类的路线:

Main main = new Main();
main.setApplicationContextUri("META-INF/spring/jms-inout-producer.xml"); // change this
main.start();

final Object body = "<Customer xmlns=\"http://www.openapplications.org/9\" xmlns:lw=\"http://www.org/9\"><Name>John</Name><Gender>Female</Gender></Customer>";

final ProducerTemplate template = main.getCamelTemplate();
template.requestBody("http://localhost:8050/add/Customer", body);

这导致下面的输出:

INFO  Body: <Customer xmlns="http://www.openapplications.org/9" xmlns:lw="http://www.org/9"><Name>John</Name><Gender>Female</Gender></Customer>

这篇关于发送消息从HTTP端点JMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆