【问题标题】:Camel-cxf Request JSON to activemqCamel-cxf 请求 JSON 到 activemq
【发布时间】:2016-04-28 12:41:40
【问题描述】:

我一直在尝试使用 camel-cxf 组件向 Activemq 队列发送 JSON 请求以公开 RESTful 服务。以下是我的路线代码:

<route>
    <from uri="cxfrs:bean:rsServer" />
    <log message="${body}"/>
    <to uri="activemq:queue:testQueue" pattern="InOnly" />
</route>

rsServer 是公开的 RESTful 服务。

<cxf:rsServer id="rsServer" address="/services"
        serviceClass="com.mayank.restservice.resource.RestfulResource">

    <cxf:providers>
        <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
        <bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" />
    </cxf:providers>
    <cxf:extensionMappings>
        <entry key="xml" value="application/xml" />
        <entry key="json" value="application/json" />
    </cxf:extensionMappings>

</cxf:rsServer>

在调用网络服务时,Activemq 确实在队列中接收到项目,但在查看消息时:

javax.jms.JMSException:无法从内容构建正文。代理不可用的可序列化类。原因:java.lang.ClassNotFoundException: org.apache.cxf.message.MessageContentsList

显示。 请告诉我可能是什么问题,因为我对骆驼完全陌生。

【问题讨论】:

  • 日志消息也不公开任何文本正文。

标签: json web-services apache-camel cxf


【解决方案1】:

如果您将对象发送到 ActiveMQ,那么您可能需要为 activemq 组件使用 jmsMessageType=Text 选项,该选项扩展了 jms 组件。

之后,要将消息放入 ActiveMQ 队列,对象需要可序列化,因为错误提示。

在您的示例中,一旦 cxfrs 组件完成,交换主体就是一个可能无法序列化的 MessageContentsList 对象。

您可以从这里做两件事:

  1. 更改一些 cxfrs 配置,例如 bindingStyle 以便输出可序列化的对象
  2. 向路由添加另一个组件,例如 beanconvertBodyTo,以在发送到 ActiveMQ 组件之前创建可序列化对象

有关详细信息,请参阅 http://camel.apache.org/bean.htmlhttp://camel.apache.org/convertbodyto.htmlhttp://camel.apache.org/cxfrs.htmlhttp://camel.apache.org/jms.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-19
    • 2014-11-08
    • 1970-01-01
    • 2016-01-14
    • 2013-04-21
    • 1970-01-01
    • 2021-12-17
    相关资源
    最近更新 更多