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

-----Original Message-----
From: harinair [mailto:[EMAIL PROTECTED] 
Sent: 22. september 2008 21:19
To: camel-user@activemq.apache.org
Subject: RE: Some questions


Sorry - I did not get the full answer... I think I am not asking the question
correctly. I have figured out the routing - that was pretty easy. I have a
route similar to this:

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

Now based on the ROUTE_HEADER, some endpoint may handle sending of this
message. Now after the message is send to the other system (possibilities
are SFTP, FTP, HTTP/HTTPS), I need to get the control after the
transmission, check the status of exchange and update the database. So for
that do I have to add a DelegatingProcessor before the recipientList?
Something like this? Is this what need to be done?

DelegatingProcessor myProcessor = new MyDelegatingProcessor();
from("jms:delivery-queue").intercept(myProcessor)
.recipientList().header(Constants.ROUTE_HEADER);


in MyDelegatingProcessor.process()
public void process(Exchange exchange) {
processNext();
if (exchange.isFailed()) {
// update the DB as failed
} else {
// update the DB as successful
}
}

Am I making sense?
Hari Gangadharan


Claus Ibsen wrote:
> 
> Hi
> 
> Answer on some of your questions.
> 
> Exchange has methods: isFailed, getException
> http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Exchange.html
>  
> 
> I guess you can also configure your error handler to multicast the failed
> message to 2 destinations such as:
> 
> errorHandler(deadLetterHandler().maximumRedeliveries(2)).multicast().to("seda:dlc",
> "xmpp:xxx");
> 
> Then you get the dead message in a queue and also a notification. If you
> want "redeliver" of the "xmpp:xxx" then this can be split into 2 routes
> using a seda queue in the middle.
> 
> errorHandler(deadLetterHandler().maximumRedeliveries(2)).multicast().to("seda:dlc",
> "seda:xxx");
> 
> from("seda:xxx").errorHandler(deadLetterHandler().maximumRedeliveries(5)).to("xmpp:xxx");
> 
> The combinations is nearly endless, a bit scary ;)
> 
> I think we might have a few DSL for detecting if a message is failed, but
> I haven't used them to much. But you can always check from a processor
> with java code, or use bean or some kind of EL language.
> 
> Well try a bit more and maybe post a sample of how far you got. Then we
> can look at it again later.
> 
> You can also intercept specific exceptions and route them to your xmpp as
> well
> 
> Here is some links to check:
> http://activemq.apache.org/camel/error-handler.html
> http://activemq.apache.org/camel/exception-clause.html
> http://activemq.apache.org/camel/dead-letter-channel.html 
> 
> 
> 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.

Reply via email to