On Sun, May 8, 2011 at 1:48 PM, Arkadi Shishlov
<[email protected]> wrote:
> On Sat, 07 May 2011 17:54:11 +0300, Hanson <[email protected]> wrote:
>>
>> I just wonder what's the necessity of declaring a JMS component as
>> transactional basically. If not, when a JMS to JMS route fails, will the
>> message got lost, in case I have a DefaultErrorHandler and set redelivery
>> attempts to -1?
>>
>> What about a File to JMS route? File component should NOT support
>> transactions at all.
>>
>> Camel redelivery and transactions are both measures dealing with
>> exceptions.
>> And in most cases, is transactions necessary? I'd like to know your idea.
>
> If you have the Camel in Action book, Chapter 9. goes into details why and
> how transactions are working in Camel. If not, just buy an e-book, it worth
> the money 100%.
> As I understand it, if the route is not transacted() then in-flight messages
> are lost in case JVM or server crashes because message retrieval is
> auto-acknowledged by the ActiveMQ. So you need transacted() to be correct.
> Non-transactional endpoints could be compensated with onComplete() and
> custom Synchronization callbacks.
>
> But, what I believe is missing from the book is a discussion about how
> transacted route interacts with Error Handler redelivery policy. I know the
> ActiveMQ re-delivers the message (6 times, 1 sec interval by default).
> Surely this case is different, because transaction manager works with the
> same thread only, which conflicts with separate redelivery thread.
> So my additional questions are:

We once had a draft section about mixing TX with Camel redelivery. But
the chapter got to big
and we want to cover more important stuff.

If you use TX then you usually dont use Camel redelivery as well. But
its doable.
For example:
   from JMX
     process
     to FTP

Then you could let Camel try to redelivery in case there is a problem
uploading the message to the FTP server.
Without Camel redelivery the TX will rollback to the JMS queue.


> 1. Does JMS consumer always use separate re-delivery thread?

Yes. Although the consumer could have a thread pool. So in theory you
could end up with the same thread handling the re-delivery. But any
"state" is lost between redelivery attempts. Also if the JMS is
clustered you could actually have the JMS broker redelivery the
message on another node. That depends how you have setup the JMS
broker.

> 2. TransactionalErrorHandler is mentioned in in the book in Chapter 4., but
> not discussed in Chapter 9. nor it is present in the current version of
> Camel. Whats the deal?

When you use transacted in the DSL, Camel will automatic use the
TransactionErrorHandler.
So there is no reason to explicit configure and setup a
TransactionErrorHandler in Camel.

> 3. I use the following route to move the message between primary and
> secondary gateway queues based on exception thrown:
>
> String gatewayQueue = "activemq:queue:gateway-" + gateway.getId();
> ProcessorDefinition r = from(gatewayQueue).routeId("gateway-" +
> gateway.getId()); //.transacted();
> r = r.onException(SipPresenceIncompatible.class)
>        .maximumRedeliveries(0)
>        .handled(true)
>        .process(secondaryChannelProcessor)
>        .end()
>    .onException(Exception.class)
>        .retryWhile(new Predicate() {
>            public boolean matches(Exchange exchange) {
>            ...
>            }
>            })
>        .redeliveryDelay(5000)
>        .backOffMultiplier(2)
>        .handled(true)
>        .process(secondaryChannelProcessor)
>        .end()
>    .filter(ContentRouteSetup.filterExpired)
>    .process(removeJmsHeadersProcessor)
>    .to(gatewayUrl);
>
> It works beautifully in non-transactional mode. secondaryChannelProcessor
> moves exchanges into different gateway-# queue via ProducerTemplate or just
> discards them because they are already on secondary channel.
> What I can't make a sense of is how exceptions and producer template
> interacts with the ActiveMQ rollback in transactional mode. Any hints?
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to