You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cbuxbaum <cb...@tradestonesoftware.com> on 2012/02/02 17:28:20 UTC

how can I do this?

Hello,

I have a route that takes a file from one location and processes it to
another.  On Exception, I would like to have the file deposited in a
deadletter location (note, a location, not a queue).  So I have that feature
working, but additionally, I would like to retrieve the exception from the
exchange, and create a log file next to the file in the dead letter
location, something like,

Demo1.ai
Demo1.ai.error.log

There does not seem to be any way to intercept the dead letter processing
just before or after moving to the dead letter queue in order to create the
log file.  I can think of other ways of doing this, but I like the retry
feature of the deadletter channel, and just want to add some processing to
the end.

Thanks,

Carl

--
View this message in context: http://camel.465427.n5.nabble.com/how-can-I-do-this-tp5451194p5451194.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: how can I do this?

Posted by Carl Buxbaum <cb...@tradestonesoftware.com>.
Thanks, fyi this is how I implemented in spring:

<errorHandler id = "aiErrorHandler" type="DeadLetterChannel" deadLetterUri="direct:myDLC" useOriginalMessage="true"/>     
<route errorHandlerRef="aiErrorHandler">
...
</route>
<route>
   <from uri="direct:myDLC"/>
       <process ref="myDeadLetterChannel" />
   <to uri="file://c:/tmp/data/failed"/>
</route>  

Carl


-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Thursday, February 02, 2012 11:35 AM
To: users@camel.apache.org
Subject: Re: how can I do this?

Hi

You can use a direct endpoint as the DLC

errorHandler(deadLetterChannel("direct:myDLC"));

And then a route where you write the error file, and then afterwards
the original file.

from(file:inbox?delete=true)
   ....



from("direct:myDLC")
   .bean(new WriteErrorFileBean());
   .to("file:error");


public class WriteErroBean {

   public void writeErrorReport(File file, Exception cause,
CamelContext context) {
     ... write a error file based on the error message
     .. you can use a camel producer template to save the file, but of
course use Java File API also works
   }

}



On Thu, Feb 2, 2012 at 5:28 PM, cbuxbaum
<cb...@tradestonesoftware.com> wrote:
> Hello,
>
> I have a route that takes a file from one location and processes it to
> another.  On Exception, I would like to have the file deposited in a
> deadletter location (note, a location, not a queue).  So I have that feature
> working, but additionally, I would like to retrieve the exception from the
> exchange, and create a log file next to the file in the dead letter
> location, something like,
>
> Demo1.ai
> Demo1.ai.error.log
>
> There does not seem to be any way to intercept the dead letter processing
> just before or after moving to the dead letter queue in order to create the
> log file.  I can think of other ways of doing this, but I like the retry
> feature of the deadletter channel, and just want to add some processing to
> the end.
>
> Thanks,
>
> Carl
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/how-can-I-do-this-tp5451194p5451194.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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

DISCLAIMER: 
E-mails and attachments from TradeStone Software, Inc. are confidential.
If you are not the intended recipient, please notify the sender immediately by
replying to the e-mail, and then delete it without making copies or using it
in any way. No representation is made that this email or any attachments are
free of viruses. Virus scanning is recommended and is the responsibility of
the recipient.

Re: how can I do this?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can use a direct endpoint as the DLC

errorHandler(deadLetterChannel("direct:myDLC"));

And then a route where you write the error file, and then afterwards
the original file.

from(file:inbox?delete=true)
   ....



from("direct:myDLC")
   .bean(new WriteErrorFileBean());
   .to("file:error");


public class WriteErroBean {

   public void writeErrorReport(File file, Exception cause,
CamelContext context) {
     ... write a error file based on the error message
     .. you can use a camel producer template to save the file, but of
course use Java File API also works
   }

}



On Thu, Feb 2, 2012 at 5:28 PM, cbuxbaum
<cb...@tradestonesoftware.com> wrote:
> Hello,
>
> I have a route that takes a file from one location and processes it to
> another.  On Exception, I would like to have the file deposited in a
> deadletter location (note, a location, not a queue).  So I have that feature
> working, but additionally, I would like to retrieve the exception from the
> exchange, and create a log file next to the file in the dead letter
> location, something like,
>
> Demo1.ai
> Demo1.ai.error.log
>
> There does not seem to be any way to intercept the dead letter processing
> just before or after moving to the dead letter queue in order to create the
> log file.  I can think of other ways of doing this, but I like the retry
> feature of the deadletter channel, and just want to add some processing to
> the end.
>
> Thanks,
>
> Carl
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/how-can-I-do-this-tp5451194p5451194.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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