You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Blair <bl...@gmail.com> on 2010/11/16 01:27:43 UTC

confusion with active mq

ok, I'm getting rather confused with activeMQ.

I am replacing some java code with xml in camel. However, while I can queue
messages from the java code, with the xml it isn't working, even though they
should be doing the same thing. 

The stack trace I am getting isn't helping, apart from saying there is a
problem, but I don't know how to get a more useful trace from it.

anyway, the code.

    @Consume(uri = "direct:fromWebService")
    public void messagingWebService (
            @XPath(value = "//to[not(to)]/text()") NodeList toList,
            @XPath("//application/text()") String application,
            @XPath("//message/text()") String message,
            @XPath("//options/text()") String options,
            @XPath("//partnerReference/text()") String partnerReference) {
        for (int i = 0; i < toList.getLength(); i++) {
            String to =
service.cleanNumber(toList.item(i).getTextContent());
            String channel = service.getChannelFor(to);
            String shortCode = service.getShortCodeFor(application, channel,
options);
            if (shortCode == null) {
                shortCode = options;
            }

            Map<String, Object> headers = new HashMap<String, Object>();
            headers.put("CamelSmppSourceAddr", shortCode);
            headers.put("CamelSmppDestAddr", to);
            template.sendBodyAndHeaders("log:" + channel + "?showAll=true",
message, headers);

            template.sendBodyAndHeaders("activemq:" + channel, message,
headers);
        }
    }

which is pretty ugly, and should be able to use a camel split....

so... the xml replacement looks like...

        <route>
            <from uri="direct:fromWebService"/>
            <setHeader headerName="application"><xpath
resultType="java.lang.String">//application/text()</xpath></setHeader>
            <setHeader headerName="message"><xpath
resultType="java.lang.String">//message/text()</xpath></setHeader>
            <setHeader headerName="options"><xpath
resultType="java.lang.String">//options/text()</xpath></setHeader>
            <setHeader headerName="partnerReference"><xpath 
resultType="java.lang.String">//partnerReference/text()</xpath></setHeader>
            <split parallelProcessing="false">
                <xpath>//to[not(to)]/text()</xpath>
                <setHeader
headerName="to"><simple>${bean:applicationService?method=cleanNumber}</simple></setHeader>
                <setHeader
headerName="channel"><simple>${bean:applicationService?method=getChannelFor}</simple></setHeader>
                <setHeader
headerName="shortCode"><simple>${bean:applicationService?method=getShortCodeFor}</simple></setHeader>
                <setBody><header>message</header></setBody>
                <setHeader
headerName="CamelSmppSourceAddr"><header>shortCode</header></setHeader>
                <setHeader
headerName="CamelSmppDestAddr"><header>to</header></setHeader>
                <to uri="activemq:vodaphone"/>
            </split>
        </route>

which is nicer (or at least a good step towards being nicer...

however, while the java code works, the xml version spits out...
[        33192392@qtp-3808803-1] DefaultErrorHandler            ERROR Failed
delivery for exchangeId: 8b5f20db-1e42-45f6-8d68-923c9546ae3c. Exhausted
after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException:
Exception occurred during execution on the exchange: Exchange[Message:
Testing!! Testing!!]
org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange: Exchange[Message: Testing!! Testing!!]
	at
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1142)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:263)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:53)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.4.0.jar:2.4.0]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
...
[        33192392@qtp-3808803-1] PhaseInterceptorChain          WARN 
Interceptor for
{http://messaging.webservices.messagedirect.synergy.co.nz}MessagingServiceService#{http://messaging.webservices.messagedirect.synergy.co.nz}sendSMS
has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Exception occurred during execution on the
exchange: Exchange[Message: Testing!! Testing!!]
	at
org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer.java:123)[camel-cxf-2.4.0.jar:2.4.0]
	at
org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:102)[camel-cxf-2.4.0.jar:2.4.0]
	at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)[cxf-rt-core-2.2.9.jar:2.2.9]
	at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)[:1.6.0_22]
	at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_22]
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_22]
	at
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)[cxf-rt-core-2.2.9.jar:2.2.9]
	at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)[cxf-rt-core-2.2.9.jar:2.2.9]
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)[cxf-api-2.2.9.jar:2.2.9]
	at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110)[cxf-rt-core-2.2.9.jar:2.2.9]
	at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:312)[cxf-rt-transports-http-jetty-2.2.9.jar:2.2.9]
	at 
...

I've tried replacing 
<to uri="activemq:vodaphone"/> with <inOnly uri="activemq:vodaphone"/>
which stops it complaining, but... I stop being able to get anything from
that vodaphone queue.

so, I'm confused, I'm obviously not getting something with activeMQ, as if I
remove it and just uri="direct:..." it, then it works just fine.

so, my question is, how do I get a useful stacktrace? and what am I not
getting? 



-- 
View this message in context: http://camel.465427.n5.nabble.com/confusion-with-active-mq-tp3266693p3266693.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: confusion with active mq

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

Looks like you are using template.sendBodyAndHeaders(...) which is meant to
send one way requests (InOnly). You need to use
template.requestBodyAndHeaders(...) if you want a response back. You can get
back the modified exchange in this case.

Hope this helps.

Cheers,

Ashwin...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com
http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
-- 
View this message in context: http://camel.465427.n5.nabble.com/confusion-with-active-mq-tp3266693p3267228.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: confusion with active mq

Posted by Willem Jiang <wi...@gmail.com>.
On 11/16/10 6:25 PM, Blair wrote:
>
> ok, that does sound right, I have tried to convert it to inonly but that
> didn't work well at all :)
>
> How do I put the response back? I have been reading the documentation for
> the last couple of days trying to work this particular problem out.

If the message exchange pattern is InOut, the producer of the activemq 
will try to wait for the response.

You need add other route to consume the message from the activemq 
endpoint like this

from("activemq:myqueue").transformation("RESPONSE");

>
> I'm looking for a good example - if you have one then thats cool, if not
> then you have at least given me a point in the right direction!
>
> and for that alone I thank you :)
>
>
> Willem.Jiang wrote:
>>
>> Did you put the response back in the route which consumes the message
>> from "activemq:myqueue"?
>>
>> If you just redirect a WebServiceResponse activemq endpoint, the
>> MessageExchangePattern is InOut, you need to make sure set the response
>> back.
>>
>>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Re: confusion with active mq

Posted by Blair <bl...@gmail.com>.
ok, that does sound right, I have tried to convert it to inonly but that
didn't work well at all :)

How do I put the response back? I have been reading the documentation for
the last couple of days trying to work this particular problem out. 

I'm looking for a good example - if you have one then thats cool, if not
then you have at least given me a point in the right direction!

and for that alone I thank you :)


Willem.Jiang wrote:
> 
> Did you put the response back in the route which consumes the message 
> from "activemq:myqueue"?
> 
> If you just redirect a WebServiceResponse activemq endpoint, the 
> MessageExchangePattern is InOut, you need to make sure set the response 
> back.
> 
> 

-- 
View this message in context: http://camel.465427.n5.nabble.com/confusion-with-active-mq-tp3266693p3267095.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: confusion with active mq

Posted by Willem Jiang <wi...@gmail.com>.
Did you put the response back in the route which consumes the message 
from "activemq:myqueue"?

If you just redirect a WebServiceResponse activemq endpoint, the 
MessageExchangePattern is InOut, you need to make sure set the response 
back.

On 11/16/10 10:33 AM, Blair wrote:
>
> ok, lets try this again with a MUCH simpler example of whats going on.
>
>
> from("direct:fromWebService").convertBodyTo(String.class).to("activemq:myqueue");
>
> is generating the same problems.
>
> I can't seem to go from a web service to activeMQ. I can go directly to
> other components without an issue... and if I use
>
> template.sendBodyAndHeaders("activemq:myQueue", "this is my message",
> headers);
>
> it works just fine,
>
> so activeMQ is working, the web services and other components are working, I
> just can't get them to play nicely together.
>
> anyone have any ideas?


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Re: confusion with active mq

Posted by Blair <bl...@gmail.com>.
ok, lets try this again with a MUCH simpler example of whats going on.


from("direct:fromWebService").convertBodyTo(String.class).to("activemq:myqueue");
            
is generating the same problems.

I can't seem to go from a web service to activeMQ. I can go directly to
other components without an issue... and if I use 

template.sendBodyAndHeaders("activemq:myQueue", "this is my message",
headers); 

it works just fine,

so activeMQ is working, the web services and other components are working, I
just can't get them to play nicely together.

anyone have any ideas?
-- 
View this message in context: http://camel.465427.n5.nabble.com/confusion-with-active-mq-tp3266693p3266792.html
Sent from the Camel - Users mailing list archive at Nabble.com.