Hi

Ah of course the DLC has to use an endpoint and not a processor ;) my bad.
The problem was that it's just easier to explain new users to use a processor 
than the bean. As a processor must implements the Process interface where you 
have the process method with the exchange object. Using a bean endpoint this is 
not needed you just create the method you like and Camel finds the best method 
to invoke and convert the payload to what type you have declared. But it is 
recommended to use bean as they are plain POJO and independent of Camel.

Then you can use a bean endpoint instead:
              
errorHandler(deadLetterChannel("bean:myBean").maximumRedeliveries(0));


MyBean can just implements Process and do the same code as a Processor.
Remember to register it in your spring XML as:
<bean id="myBean" class="xxx"/>


Ah you probably need to set the end ) correct with the receipent stuff:

                
errorHandler(deadLetterChannel("bean:MyBean?method=processIsBad").maximumRedeliveries(0));

                
from("jms:deliveryqueue").recipientList(header("xx")).to("bean:MyBean?method=processIsOK");

BTW: You can add the method parameter to bean so you can invoke the correct 
method and not need to compute if the exchange is failed or not.

http://activemq.apache.org/camel/bean.html




Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: harinair [mailto:[EMAIL PROTECTED] 
Sent: 24. september 2008 22:01
To: camel-user@activemq.apache.org
Subject: RE: Some questions


Sorry Claus...

I see that we cannot do:

from("jms:delivery-queue).recipientList().header(Constants.ROUTE_HEADER).to(myProcoessor));

I cannot use to on recipientList() or header(name)


Also I cannot do
errorHandler(deadLetterChannel(myProcessor).maximumRedeliveries(0);

deadLetterChannel accepts String definition of Endpoint or Endpoint object.
It does not accept a Processor. But I think that is fine - I can route it to
a dead letter queue and have a queue listener process the updates. Or even
write another route like:
from("jms:temp-dead-letter-queue").process(myProcessor).to("jms:dead-letter-queue");

Any other idea? What do you think?
Hari Gangadharan


Claus Ibsen wrote:
> 
> Hi
> 
> Camel will by default use DeadLetterChannel to handle failed exchanges
> where it will retry 6 times. So after 6 attempts and still a failure it
> will log it as ERROR.
> http://activemq.apache.org/camel/dead-letter-channel.html
> http://activemq.apache.org/camel/error-handler.html
> 
> 
> This behavior needs to be changed since you want to WRITE to a database
> about this ERROR. Also you want to write to the database if it's an OK.
> 
> So we need to instruct Camel to use send failure exchanges to your
> processor where you can write ERROR in the database.
> 
> // so we setup the error handler to use DLC but with your processor as
> destination and with 0 redeliveries. 
> MyProcessor myProcessor = new MyProcessor();
> errorHandler(deadLetterChannel(myProcessor).maximumRedeliveries(0);
> from("jms:delivery-queue).recipientList().header(Constants.ROUTE_HEADER);
> 
> 
> But we still need to set the OK situation. So we can just do it as adding
> a .to with your processor.
> 
> from("jms:delivery-queue).recipientList().header(Constants.ROUTE_HEADER).to(myProcoessor);
> 
> Then in myProcessor you can detect if the Exchange is failed or not
> 
> public class MyProcessor
> 
> public void process(Exchange exchange) {
>   Boolean failed = exchange.isFailed();
>   If (isFailed) {
>      // write ERROR in DB
>   } else {
>      // write OK in DB
>   }
> }
> 
> 
> 
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> -- 
> View this message in context:
> http://www.nabble.com/Some-questions-tp19564827s22882p19614697.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Some-questions-tp19564827s22882p19656721.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to