0
votes

I have been trying to send the JSON request made to the Activemq queue using camel-cxf component for exposing the RESTful service. Below is my route code:

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

where rsServer is the RESTful service exposed.

<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>

On calling web service Activemq does receive item in queue but on viewing the message:

javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: org.apache.cxf.message.MessageContentsList

is shown. Please tell what can be the issue as I am completely new to camel.

1
log message also doesn't expose any text body. - Mayank Agarwal

1 Answers

0
votes

If you are sending an object to the ActiveMQ then you may need to use the jmsMessageType=Text option for the activemq component, which extends the jms component.

After that, to place a message on to an ActiveMQ queue the object needs to be serializable, as the error is hinting.

In your example, once the cxfrs component has finished the exchange body is a MessageContentsList object which may not be serializable.

Two things you could do from here:

  1. Change some cxfrs configurations such as bindingStyle so that a serializable object is output instead
  2. Add another component to the route such as bean or convertBodyTo to create a serializable object before sending to the ActiveMQ component

See http://camel.apache.org/bean.html and http://camel.apache.org/convertbodyto.html and http://camel.apache.org/cxfrs.html and http://camel.apache.org/jms.html for details.