1
votes

does anyone know a working example that bridges ActiveMQ to CXF? I saw many examples that connect a WebService to a message queue, but I need it the other way round. Messages from a JMS queue shall be forwarded to a web service and the result returned to the caller.

My first approach is only working for web services that expose one single method:

from("activemq:wsa").to("cxf:bean:webServiceA");

Status msg = producerTemplate.requestBody("activemq:wsa", params, Status.class); 

But for web services that have more than one method, a similar call results in a ExchangeTimedOutException.

Map<String, Object> header = new HashMap<String, Object>(); 
header.put(CxfConstants.OPERATION_NAME, "doSomething"); 
header.put(CxfConstants.OPERATION_NAMESPACE, "http://.../"); 

Status msg = producerTemplate.requestBodyAndHeaders("activemq:wsb", params, header, Status.class); 

Nevertheless, I can see that the request is forward to the web service and the correct answer is returned. But unfortunately then it gets lost on its way back.

Any hints or links to external resources are appreciated.

Many regards, Jakob

2

2 Answers

0
votes

ActiveMQ and JMS calls are one way default, you may want to specify it to be synchronous.

http://camel.apache.org/jms.html#JMS-RequestreplyoverJMS

Other than that, it should be no different to use ActiveMQ as a starter for CXF producers.

A suggestion is to download the Camel source and look into this folder:

\components\camel-cxf\src\test\java\org\apache\camel\component\cxf

(or by Web: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/)

You will have a huge amount of CXF producer test cases, to look at as reference material.

0
votes

The problem occurs when a web service returns objects of classes that don't implement the serializable interface, even if these classes are serializable.

Implementing the serializable interface solves the problem.