Well, after 8 hours of searching documentation, trying different code and at last debugging ServiceMix code I figured out the DefaultConsumerMarshaler had to be manually configured to use InOut pattern even if the input message had the JMSReplyTo header defined. So, based on [1], I've changed the marshaler of the jms:consumer in my xbean.xml:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://servicemix.apache.org/jms/1.0" xmlns:amq="http://activemq.apache.org/schema/core" xmlns:txurl="urn:com.myreks:txurl" xsi:schemaLocation=" http://servicemix.apache.org/jms/1.0 http://servicemix.apache.org/schema/servicemix-jms-2009.01.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd"> <classpath> <library>osgi:org.apache.activemq.activemq-core</library> </classpath> <!-- Echo (test) --> <jms:provider service="txurl:EchoService" endpoint="jms" receiveTimeout="60000" destinationName="txurl/EchoChannel" connectionFactory="#connectionFactory"/> <jms:consumer service="txurl:EchoServiceConsumer" endpoint="jms" targetService="txurl:Echo" targetEndpoint="camel" destinationName="txurl/EchoChannel" marshaler="#inOutMarshaler" connectionFactory="#connectionFactory"/> <!-- ActiveMQ config --> <amq:connectionFactory id="connectionFactory" brokerURL="tcp://localhost:61616" /> <bean id="inOutMarshaler" class="org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler"> <property name="mep" value="http://www.w3.org/2004/08/wsdl/in-out" /> </bean> </beans> [1] http://servicemix.apache.org/servicemix-jms-new-endpoints.html#servicemix-jmsnewendpoints-UsingaMarshaler Regards, *Henrique Viecili* Myreks On Thu, Apr 12, 2012 at 5:00 PM, Henrique Viecili <[email protected]>wrote: > Hi fellows, > > I'm trying to create a very simple EchoService exposed as JMS. I've build > the JBI SA package and deployed to ServiceMix 4.4.1, but when I send a > message to the service's JMS queue my client hangs waiting the response on > the JMSReplyTo destination. > > Can anyone tell me what I'm doing wrong? > > This is the xbean.xml in a servicemix-jms SU: > > <beans xmlns="http://www.springframework.org/schema/beans" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:jms="http://servicemix.apache.org/jms/1.0" > xmlns:amq="http://activemq.apache.org/schema/core" > xmlns:txurl="urn:com.myreks:txurl" > xsi:schemaLocation=" > http://servicemix.apache.org/jms/1.0 > http://servicemix.apache.org/schema/servicemix-jms-2009.01.xsd > http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-3.0.xsd > http://activemq.apache.org/schema/core > http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd"> > > <classpath> > <library>osgi:org.apache.activemq.activemq-core</library> > </classpath> > > <!-- Echo (test) --> > <jms:provider > service="txurl:EchoService" > endpoint="jms" > receiveTimeout="60000" > destinationName="txurl/EchoChannel" > connectionFactory="#connectionFactory"/> > <jms:consumer > service="txurl:EchoServiceConsumer" > endpoint="jms" > targetService="txurl:Echo" > targetEndpoint="camel" > destinationName="txurl/EchoChannel" > connectionFactory="#connectionFactory"/> > > <!-- ActiveMQ config --> > <amq:connectionFactory > id="connectionFactory" > brokerURL="tcp://localhost:61616" /> > </beans> > > This is the camel-context.xml in a servicemix-camel SU: > > <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=" > http://www.w3.org/2001/XMLSchema-instance" xmlns:camel=" > http://camel.apache.org/schema/spring" > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-3.0.xsd > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd"> > > <camel:camelContext id="camel" trace="true"> > > <camel:route id="RequestResponseRoute"> > <camel:from > uri="jbi:endpoint:urn:com.myreks:txurl:Echo:camel?mep=in-out"/> > <camel:setExchangePattern pattern="InOut"/> > <camel:to uri="bean:replier" pattern="InOut"/> > </camel:route> > > </camel:camelContext> > > <bean id="replier" class="com.myreks.txurl.processor.handler.Echo"/> > > </beans> > > This is the Echo class: (implements Processor) > > public void process(Exchange exchange) throws Exception { > Endpoint ep = exchange.getFromEndpoint(); > Message in = exchange.getIn(); > exchange.getOut().setBody(in.getBody()); > } > > This is the client: > > public String echo(String request) { > String response; > > try { > QueueConnectionFactory factory = (QueueConnectionFactory) > getConnectionFactory(); > Queue txURLQueue = TxURLLocator.getEchoChannel(); // points to > txurl/EchoChannel queue > > QueueConnection conn = factory.createQueueConnection(); > conn.start(); > > QueueSession session = conn.createQueueSession(false, > QueueSession.AUTO_ACKNOWLEDGE); > > QueueRequestor requestor = new QueueRequestor(session, txURLQueue); > > TextMessage txUrlReqMsg = session.createTextMessage(); > txUrlReqMsg.setText(request); > > TextMessage txUrlRespMsg = (TextMessage) requestor.request(txUrlReqMsg); > > System.out.println("ECHO: " + txUrlRespMsg.getText()); > > response = txUrlRespMsg.getText(); > } catch (Exception e) { > e.printStackTrace(); > } > > return response; > } > > And this is the trace at ServiceMix: > > 16:38:33,481 | INFO | rovider-thread-2 | Tracer > | ? ? | 89 - org.apache.camel.camel-core > - 2.8.0.fuse-01-13 | ID-myreks-viecili-36483-1334259119415-3-1 >>> > (RequestResponseRoute) from(endpoint:urn:com.myreks:txurl:Echo:camel) --> > setExchangePattern: InOut <<< Pattern:InOnly, > Headers:{breadcrumbId=ID-myreks-viecili-36483-1334259119415-3-2}, > BodyType:org.apache.servicemix.nmr.core.util.StringSource, Body:[Body is > instance of java.xml.transform.StreamSource] > 16:38:33,492 | INFO | rovider-thread-2 | Tracer > | ? ? | 89 - org.apache.camel.camel-core > - 2.8.0.fuse-01-13 | ID-myreks-viecili-36483-1334259119415-3-1 >>> > (RequestResponseRoute) setExchangePattern: InOut --> bean://replier <<< > Pattern:InOut, > Headers:{breadcrumbId=ID-myreks-viecili-36483-1334259119415-3-2}, > BodyType:org.apache.servicemix.nmr.core.util.StringSource, Body:[Body is > instance of java.xml.transform.StreamSource] > > Thank you very much for you time! > > Regards, > *Henrique Viecili* > Myreks > >
