Grokbase Groups Camel users May 2011
FAQ
Hi,

I've got the following three routes:
<camel:camelContext id="sampleHashCamelContext" >
<camel:route>
<camel:from uri="cxf:bean:serviceEndpoint" />
<camel:transacted />
<camel:to uri="activemq:queue:SampleAsyncHashCamelQueue" pattern="InOnly" />
</camel:route>

<camel:route streamCache="true" handleFault="false">
<camel:from uri="activemq:queue:SampleAsyncHashCamelQueue" />
<camel:transacted />
<camel:loadBalance>
<camel:roundRobin />
<camel:to uri="cxf:bean:targetEndpoint1"/>
<camel:to uri="cxf:bean:targetEndpoint2"/>
<camel:to uri="cxf:bean:targetEndpoint3"/>
</camel:loadBalance>
<camel:to uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
</camel:route>

<camel:route>
<camel:from uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
<camel:transacted />
<camel:to uri="http://192.168.1.100:8080/sampleHashCamelContext" pattern="InOnly" />
</camel:route>
</camel:camelContext>


In the no-error case everything works perfectly, one of the CXF endpoints gets called asynchronously and the results get sent to an http endpoint.

To test the error handling I change the CXF endpoints to point to TCP ports that aren't listening.
When I do this for one endpoint everything continues to work correctly.
When I change two endpoints I get the following error:
Interceptor for {http://spudsoft.co.uk/}Hash#{http://spudsoft.co.uk/}HashFiles has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
at org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer.java:218)[136:org.apache.camel.camel-cxf:2.7.1]
...
Caused by: java.lang.ClassCastException: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
at org.apache.camel.component.jms.JmsProducer.setMessageId(JmsProducer.java:365)[155:org.apache.camel.camel-jms:2.7.1]
...

In the docs for transactional-client there is an example of a similar route that has to explicitly create a new transaction for the second stage.
Should I be doing this?
If so, how does camel know that it should wrap the three routes in a single transaction (i.e. if something else were to dequeue messages wouldn't that leave the
transaction hanging?)

If I don't need to explicitly declare transaction policies, what is causing the error?

Thanks.

Jim

Search Discussions

  • Claus Ibsen at May 17, 2011 at 9:00 am
    Hi

    I have created a ticket to fix that class cast exception
    https://issues.apache.org/jira/browse/CAMEL-3979
    On Tue, May 17, 2011 at 10:46 AM, James Talbut wrote:
    Hi,

    I've got the following three routes:
    <camel:camelContext id="sampleHashCamelContext" >
    <camel:route>
    <camel:from uri="cxf:bean:serviceEndpoint" />
    <camel:transacted />
    <camel:to uri="activemq:queue:SampleAsyncHashCamelQueue" pattern="InOnly" />
    </camel:route>

    <camel:route streamCache="true" handleFault="false">
    <camel:from uri="activemq:queue:SampleAsyncHashCamelQueue" />
    <camel:transacted />
    <camel:loadBalance>
    <camel:roundRobin />
    <camel:to uri="cxf:bean:targetEndpoint1"/>
    <camel:to uri="cxf:bean:targetEndpoint2"/>
    <camel:to uri="cxf:bean:targetEndpoint3"/>
    </camel:loadBalance>
    <camel:to uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
    </camel:route>

    <camel:route>
    <camel:from uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
    <camel:transacted />
    <camel:to uri="http://192.168.1.100:8080/sampleHashCamelContext" pattern="InOnly" />
    </camel:route>
    </camel:camelContext>


    In the no-error case everything works perfectly, one of the CXF endpoints gets called asynchronously and the results get sent to an http endpoint.

    To test the error handling I change the CXF endpoints to point to TCP ports that aren't listening.
    When I do this for one endpoint everything continues to work correctly.
    When I change two endpoints I get the following error:
    Interceptor for {http://spudsoft.co.uk/}Hash#{http://spudsoft.co.uk/}HashFiles has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
    at org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer.java:218)[136:org.apache.camel.camel-cxf:2.7.1]
    ...
    Caused by: java.lang.ClassCastException: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
    at org.apache.camel.component.jms.JmsProducer.setMessageId(JmsProducer.java:365)[155:org.apache.camel.camel-jms:2.7.1]
    ...

    In the docs for transactional-client there is an example of a similar route that has to explicitly create a new transaction for the second stage.
    Should I be doing this?
    If so, how does camel know that it should wrap the three routes in a single transaction (i.e. if something else were to dequeue messages wouldn't that leave the
    transaction hanging?)

    If I don't need to explicitly declare transaction policies, what is causing the error?

    Thanks.

    Jim


    --
    Claus Ibsen
    -----------------
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    CamelOne 2011: http://fusesource.com/camelone2011/
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/
  • James Talbut at May 17, 2011 at 9:22 am
    Thanks Claus,

    Does that mean it's not currently possible to run this set of routes with multiple failures?
    Is there any way to workaround it?

    Thanks

    Jim

    On Tue, May 17, 2011 at 10:59:36AM +0200, Claus Ibsen wrote:
    Hi

    I have created a ticket to fix that class cast exception
    https://issues.apache.org/jira/browse/CAMEL-3979
    On Tue, May 17, 2011 at 10:46 AM, James Talbut wrote:
    Hi,

    I've got the following three routes:
    <camel:camelContext id="sampleHashCamelContext" >
    <camel:route>
    <camel:from uri="cxf:bean:serviceEndpoint" />
    <camel:transacted />
    <camel:to uri="activemq:queue:SampleAsyncHashCamelQueue" pattern="InOnly" />
    </camel:route>

    <camel:route streamCache="true" handleFault="false">
    <camel:from uri="activemq:queue:SampleAsyncHashCamelQueue" />
    <camel:transacted />
    <camel:loadBalance>
    <camel:roundRobin />
    <camel:to uri="cxf:bean:targetEndpoint1"/>
    <camel:to uri="cxf:bean:targetEndpoint2"/>
    <camel:to uri="cxf:bean:targetEndpoint3"/>
    </camel:loadBalance>
    <camel:to uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
    </camel:route>

    <camel:route>
    <camel:from uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
    <camel:transacted />
    <camel:to uri="http://192.168.1.100:8080/sampleHashCamelContext" pattern="InOnly" />
    </camel:route>
    </camel:camelContext>


    In the no-error case everything works perfectly, one of the CXF endpoints gets called asynchronously and the results get sent to an http endpoint.

    To test the error handling I change the CXF endpoints to point to TCP ports that aren't listening.
    When I do this for one endpoint everything continues to work correctly.
    When I change two endpoints I get the following error:
    Interceptor for {http://spudsoft.co.uk/}Hash#{http://spudsoft.co.uk/}HashFiles has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
    at org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer.java:218)[136:org.apache.camel.camel-cxf:2.7.1]
    ...
    Caused by: java.lang.ClassCastException: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
    at org.apache.camel.component.jms.JmsProducer.setMessageId(JmsProducer.java:365)[155:org.apache.camel.camel-jms:2.7.1]
    ...

    In the docs for transactional-client there is an example of a similar route that has to explicitly create a new transaction for the second stage.
    Should I be doing this?
    If so, how does camel know that it should wrap the three routes in a single transaction (i.e. if something else were to dequeue messages wouldn't that leave the
    transaction hanging?)

    If I don't need to explicitly declare transaction policies, what is causing the error?

    Thanks.

    Jim


    --
    Claus Ibsen
    -----------------
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    CamelOne 2011: http://fusesource.com/camelone2011/
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/
  • Claus Ibsen at May 17, 2011 at 12:26 pm

    On Tue, May 17, 2011 at 11:23 AM, James Talbut wrote:
    Thanks Claus,

    Does that mean it's not currently possible to run this set of routes with multiple failures?
    Is there any way to workaround it?
    I dont have time to look into a workaround. Just spotted the exception
    and fixed the camel-jms component.
    Thanks

    Jim

    On Tue, May 17, 2011 at 10:59:36AM +0200, Claus Ibsen wrote:
    Hi

    I have created a ticket to fix that class cast exception
    https://issues.apache.org/jira/browse/CAMEL-3979
    On Tue, May 17, 2011 at 10:46 AM, James Talbut wrote:
    Hi,

    I've got the following three routes:
    <camel:camelContext id="sampleHashCamelContext" >
    <camel:route>
    <camel:from uri="cxf:bean:serviceEndpoint" />
    <camel:transacted />
    <camel:to uri="activemq:queue:SampleAsyncHashCamelQueue" pattern="InOnly" />
    </camel:route>

    <camel:route streamCache="true" handleFault="false">
    <camel:from uri="activemq:queue:SampleAsyncHashCamelQueue" />
    <camel:transacted />
    <camel:loadBalance>
    <camel:roundRobin />
    <camel:to uri="cxf:bean:targetEndpoint1"/>
    <camel:to uri="cxf:bean:targetEndpoint2"/>
    <camel:to uri="cxf:bean:targetEndpoint3"/>
    </camel:loadBalance>
    <camel:to uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
    </camel:route>

    <camel:route>
    <camel:from uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
    <camel:transacted />
    <camel:to uri="http://192.168.1.100:8080/sampleHashCamelContext" pattern="InOnly" />
    </camel:route>
    </camel:camelContext>


    In the no-error case everything works perfectly, one of the CXF endpoints gets called asynchronously and the results get sent to an http endpoint.

    To test the error handling I change the CXF endpoints to point to TCP ports that aren't listening.
    When I do this for one endpoint everything continues to work correctly.
    When I change two endpoints I get the following error:
    Interceptor for {http://spudsoft.co.uk/}Hash#{http://spudsoft.co.uk/}HashFiles has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
    at org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer.java:218)[136:org.apache.camel.camel-cxf:2.7.1]
    ...
    Caused by: java.lang.ClassCastException: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
    at org.apache.camel.component.jms.JmsProducer.setMessageId(JmsProducer.java:365)[155:org.apache.camel.camel-jms:2.7.1]
    ...

    In the docs for transactional-client there is an example of a similar route that has to explicitly create a new transaction for the second stage.
    Should I be doing this?
    If so, how does camel know that it should wrap the three routes in a single transaction (i.e. if something else were to dequeue messages wouldn't that leave the
    transaction hanging?)

    If I don't need to explicitly declare transaction policies, what is causing the error?

    Thanks.

    Jim


    --
    Claus Ibsen
    -----------------
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    CamelOne 2011: http://fusesource.com/camelone2011/
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/


    --
    Claus Ibsen
    -----------------
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    CamelOne 2011: http://fusesource.com/camelone2011/
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/
  • James Talbut at May 17, 2011 at 3:39 pm
    No worries, I found out what was causing the out message to be accessed (getOut without calling hasOut first in a TraceEventHandler) and with that fixed it's working.

    Jim
    On Tue, May 17, 2011 at 02:26:02PM +0200, Claus Ibsen wrote:
    On Tue, May 17, 2011 at 11:23 AM, James Talbut wrote:
    Thanks Claus,

    Does that mean it's not currently possible to run this set of routes with multiple failures?
    Is there any way to workaround it?
    I dont have time to look into a workaround. Just spotted the exception
    and fixed the camel-jms component.
    Thanks

    Jim

    On Tue, May 17, 2011 at 10:59:36AM +0200, Claus Ibsen wrote:
    Hi

    I have created a ticket to fix that class cast exception
    https://issues.apache.org/jira/browse/CAMEL-3979
    On Tue, May 17, 2011 at 10:46 AM, James Talbut wrote:
    Hi,

    I've got the following three routes:
    <camel:camelContext id="sampleHashCamelContext" >
    <camel:route>
    <camel:from uri="cxf:bean:serviceEndpoint" />
    <camel:transacted />
    <camel:to uri="activemq:queue:SampleAsyncHashCamelQueue" pattern="InOnly" />
    </camel:route>

    <camel:route streamCache="true" handleFault="false">
    <camel:from uri="activemq:queue:SampleAsyncHashCamelQueue" />
    <camel:transacted />
    <camel:loadBalance>
    <camel:roundRobin />
    <camel:to uri="cxf:bean:targetEndpoint1"/>
    <camel:to uri="cxf:bean:targetEndpoint2"/>
    <camel:to uri="cxf:bean:targetEndpoint3"/>
    </camel:loadBalance>
    <camel:to uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
    </camel:route>

    <camel:route>
    <camel:from uri="activemq:queue:SampleAsyncHashCamelQueueReply" />
    <camel:transacted />
    <camel:to uri="http://192.168.1.100:8080/sampleHashCamelContext" pattern="InOnly" />
    </camel:route>
    </camel:camelContext>


    In the no-error case everything works perfectly, one of the CXF endpoints gets called asynchronously and the results get sent to an http endpoint.

    To test the error handling I change the CXF endpoints to point to TCP ports that aren't listening.
    When I do this for one endpoint everything continues to work correctly.
    When I change two endpoints I get the following error:
    Interceptor for {http://spudsoft.co.uk/}Hash#{http://spudsoft.co.uk/}HashFiles has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
    at org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer.java:218)[136:org.apache.camel.camel-cxf:2.7.1]
    ...
    Caused by: java.lang.ClassCastException: org.apache.camel.impl.DefaultMessage cannot be cast to org.apache.camel.component.jms.JmsMessage
    at org.apache.camel.component.jms.JmsProducer.setMessageId(JmsProducer.java:365)[155:org.apache.camel.camel-jms:2.7.1]
    ...

    In the docs for transactional-client there is an example of a similar route that has to explicitly create a new transaction for the second stage.
    Should I be doing this?
    If so, how does camel know that it should wrap the three routes in a single transaction (i.e. if something else were to dequeue messages wouldn't that leave the
    transaction hanging?)

    If I don't need to explicitly declare transaction policies, what is causing the error?

    Thanks.

    Jim


    --
    Claus Ibsen
    -----------------
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    CamelOne 2011: http://fusesource.com/camelone2011/
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/


    --
    Claus Ibsen
    -----------------
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    CamelOne 2011: http://fusesource.com/camelone2011/
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.blogspot.com/
    Author of Camel in Action: http://www.manning.com/ibsen/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedMay 17, '11 at 8:45a
activeMay 17, '11 at 3:39p
posts5
users2
websitecamel.apache.org

2 users in discussion

James Talbut: 3 posts Claus Ibsen: 2 posts

People

Translate

site design / logo © 2022 Grokbase