通过 Camel 从 ActiveMQ 消息中提取正文

Extracting the body from an ActiveMQ message via Camel

我有一条路线使用 Spring DSL

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="activemq:queue:worker?mapJmsMessage=false" />
    <convertBodyTo type="java.lang.String"/>
    <setHeader headerName="CamelHttpMethod">
      <constant>POST</constant>
    </setHeader>
    <to uri="http://localhost/queue" />
  </route>
</camelContext>

消息类型是ActiveMQTextMessage。我能够 POST 将消息发送到 HTTP URL,但我得到的似乎是 toString() 输出:

ActiveMQTextMessage {commandId = 5, responseRequired = false, message....

我想调用 ActiveMQTextMessage 实例上的 getText() 方法来填充路由,但我不知道如何调用该方法。我很确定我可以让它在代码中工作,但我需要通过 XML.

做所有事情

找出问题所在。几天前我设置了 mapJmsMessage=false 来处理异常。我删除了它,突然它就可以正常工作了。