camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller <christian.muel...@gmail.com>
Subject Re: Missing feature to handle errors in a route which reads from an activemq destination
Date Thu, 23 Jun 2011 11:36:10 GMT
Hello guys and thank you for your answers/opinions!

Sorry for my late reply, but I was busy with some other tasks. But I didn't
forgot you... ;-)

@Ben: Looks like we share the same thoughts. I think your suggestion is
really simple (I like simple solutions) and works for most of our
requirements. But I also see some improvements with my suggested solution:
- I would like to have the ability of an exponential back of delay per
message (make the first retry after a few secons, the second after one
minute, ...). One of our services has a really high throughput and we have
to process the messages as early as possible when the back end system is
available again.
- If we use this pattern in multiple services, I think it's a good idea to
generalize this and make it available without the need of the error route
duplication for each route which has this requirement.

@Willem: If I understood you correct, you suggest something like this:
<bean id="activemq1"
class="org.apache.activemq.camel.component.ActiveMQComponent">
  <property name="connectionFactory" ref="connectionFactory1" />
</bean>

<bean id="connectionFactory1"
class="org.apache.activemq.pool.PooledConnectionFactory">
  <constructor-arg
value="tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=10&amp;jms.redeliveryPolicy.deliveryDelay=60000&amp;jms.redeliveryPolicy.useExponentialBackOff=true&amp;jms.redeliveryPolicy.backOffMultiplier=2"/>
  <!-- some other properties -->
</bean>

<bean id="activemq2"
class="org.apache.activemq.camel.component.ActiveMQComponent">
  <property name="connectionFactory" ref="connectionFactory2" />
</bean>

<bean id="connectionFactory2"
class="org.apache.activemq.pool.PooledConnectionFactory">
  <constructor-arg
value="tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=5&amp;jms.redeliveryPolicy.deliveryDelay=1000&amp;jms.redeliveryPolicy.useExponentialBackOff=true&amp;jms.redeliveryPolicy.backOffMultiplier=5"/>
  <!-- some other properties -->
</bean>

from(activemq1:queue:foo) // configured this ActiveMQConnectionFactory to
  .transacted("REQUIRED")
  .to("cxf:bean:orderService")
  .to("activemq1:queue:bar");

from(activemq2:queue:bar) // configured this ActiveMQConnectionFactory to
  .transacted("REQUIRED")
  .to("cxf:bean:orderService")
  .to("activemq2:queue:baz");

What I dislike on this solution is, that we have to create a separate
ActiveMQConnectionFactory for each service which use a different redelivery
policy. At present, we use an OSGI lookup in SMX to get the
ActiveMQConnectionFactory which is exported by SMX (from
activemq-broker.xml). I think this is more resource friendly...
But I will take this into account as a good alternative until we have a
solution like the one I suggested... :-)

@Charles: I hope we will find the time to discuss this in 3.5 weeks, if you
are here in Frankfurt with us - or two weeks before if you plan to attend
the FUSE Community day in Frankfurt...
If I understood you correct, you suggest the following:
public void configure() throws Exception {
    RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
    redeliveryPolicy.setMaximumRedeliveries(10);
    redeliveryPolicy.setRedeliveryDelay(60000l);
    redeliveryPolicy.setUseExponentialBackOff(true);
    redeliveryPolicy.setBackOffMultiplier(2.0);

    TransactionErrorHandlerBuilder errorHandlerBuilder = new
TransactionErrorHandlerBuilder();
    errorHandlerBuilder.setRedeliveryPolicy(redeliveryPolicy);

    errorHandler(errorHandlerBuilder);

    from("activemq:queue:foo")
        .transacted("REQUIRED")
        .to("cxf:bean:orderService")
        .to("activemq:queue:bar");
}
I'm not sure I understood how the TransactionErrorHandler works exactly. If
we configure the redeliveryDelay (and all the other options), what happens
under the cover? Does the TransactionErrorHandler waits this time until it
propagates the exception to the TransactionManager? If this is the case, I
have the same bad feelings as in the "normal" RedeliveryErrorHandler I
explained in my first post.


So I still think the new "delay and schedule message delivery" [1] from
ActiveMQ 5.4 brings a good feature we should support in Camel. I will work
out a simple example which hopefully convince you. ;-)

[1] http://activemq.apache.org/delay-and-schedule-message-delivery.html

Best,
Christian

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message