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

Reply via email to