Php 使用Camel从ActiveMQ发送HTTP Post

Php 使用Camel从ActiveMQ发送HTTP Post,php,activemq,apache-camel,Php,Activemq,Apache Camel,我们使用驼峰路由将值从队列发布到http端点 我已经使用camel成功地设置了路由,但是我无法获得要发布的jms消息体 例如,我的路线设置如下: <route errorHandlerRef="dlc" autoStartup="true" id="route2" xmlns:ns2="http://camel.apache.org/schema/web" xmlns="http://camel.apache.org/schema/spring"> <from uri=

我们使用驼峰路由将值从队列发布到http端点

我已经使用camel成功地设置了路由,但是我无法获得要发布的jms消息体

例如,我的路线设置如下:

<route errorHandlerRef="dlc" autoStartup="true" id="route2" xmlns:ns2="http://camel.apache.org/schema/web" xmlns="http://camel.apache.org/schema/spring">
    <from uri="activemq:test"/>
    <setHeader headerName="CamelHttpMethod">
            <constant>POST</constant>
        </setHeader>
    <to uri="http://localhost/tim/camel/" id="to2"/>
</route>

邮递
这将生成一篇文章,但消息正文不会显示在我的文章字符串中(作为从$服务器打印的):

数组
(
[实例]=>本地
[HTTP_JMSDELIVERYMODE]=>1
[HTTP_JMSDESTINATION]=>queue://test
[HTTP_JMSEXPIRATION]=>0
[HTTP_JMSTYPE]=>
[HTTP_jmstiestamp]=>1291468702773
[httpjmspriority]=>0
[HTTP_JMSCORRELATIONID]=>
[HTTP_JMSMESSAGEID]=>ID:new-host-3.home-62248-129146566089-4:3:1:1:4
[HTTP_jmsrediver]=>false
[HTTP\u USER\u AGENT]=>雅加达公共场所HttpClient/3.1
[HTTP\u HOST]=>localhost
[HTTP_COOKIE]=>$Version=0;PHPSESSID=32aa692c71e1003f2e540c1b80c3b363;$Path=/
[内容长度]=>44
[内容类型]=>text/html
[路径]=>/usr/bin:/bin:/usr/sbin:/sbin
[SERVER_SIGNATURE]=>Apache/2.0.59(Unix)PHP/5.2.6 DAV/2 mod_ssl/2.0.59 OpenSSL/0.9.7l服务器本地主机端口80
[SERVER_SOFTWARE]=>Apache/2.0.59(Unix)PHP/5.2.6 DAV/2 mod_ssl/2.0.59 OpenSSL/0.9.7l
[服务器名称]=>本地主机
[服务器地址]=>127.0.0.1
[服务器端口]=>80
[远程地址]=>127.0.0.1
[DOCUMENT\u ROOT]=>/wufoo/trunk/
[服务器管理]=>you@example.com
[SCRIPT_FILENAME]=>/wufoo/trunk/tim/camel/index.php
[远程_端口]=>62877
[网关接口]=>CGI/1.1
[服务器协议]=>HTTP/1.1
[请求方法]=>发布
[查询字符串]=>
[请求URI]=>/tim/camel/
[SCRIPT_NAME]=>/tim/camel/index.php
[PHP_SELF]=>/tim/camel/index.PHP
[请求时间]=>1291468702
[argv]=>阵列
(
)
[argc]=>0
)
请注意,请求_方法是POST,但argv不包含消息正文

简而言之,我需要将消息体从“from”路由传输到“to”路由,这样它就可以作为POST发送,但不知怎的,我失败了


提前谢谢。

我找到了答案。要修复此问题,我必须将Content Type节点添加到标题中,并将正文设置为名称/值对,如下所示:

<route errorHandlerRef="dlc" autoStartup="true" inheritErrorHandler="true" id="route2" xmlns:ns2="http://camel.apache.org/schema/web" xmlns="http://camel.apache.org/schema/spring">
    <from uri="activemq:test"/>
    <setBody inheritErrorHandler="true" id="setBody2">
        <simple>name=${body}</simple>
    </setBody>
    <setHeader headerName="Content-Type" inheritErrorHandler="true" id="setHeader3">
        <constant>application/x-www-form-urlencoded;</constant>
    </setHeader>
    <setHeader headerName="CamelHttpMethod" inheritErrorHandler="true" id="setHeader4">
        <constant>POST</constant>
    </setHeader>
    <to uri="http://localhost/tim/camel/" inheritErrorHandler="true" id="to2"/>
</route>

名称=${body}
application/x-www-form-urlencoded;
邮递

Lifesaver!非常感谢你!
<route errorHandlerRef="dlc" autoStartup="true" inheritErrorHandler="true" id="route2" xmlns:ns2="http://camel.apache.org/schema/web" xmlns="http://camel.apache.org/schema/spring">
    <from uri="activemq:test"/>
    <setBody inheritErrorHandler="true" id="setBody2">
        <simple>name=${body}</simple>
    </setBody>
    <setHeader headerName="Content-Type" inheritErrorHandler="true" id="setHeader3">
        <constant>application/x-www-form-urlencoded;</constant>
    </setHeader>
    <setHeader headerName="CamelHttpMethod" inheritErrorHandler="true" id="setHeader4">
        <constant>POST</constant>
    </setHeader>
    <to uri="http://localhost/tim/camel/" inheritErrorHandler="true" id="to2"/>
</route>