The deadLetterChannel that I talk about is a implementation of the ErrorHandler[1] I studied your code, you just need to throw the exception where you find the message is not processable, The deadLetterChannel will send the exchange into the CR_INPUT_ERROR_CHANNEL if you define it like this.

errorHandler(deadLetterChannel(CR_INPUT_ERROR_CHANNEL).maximumRedeliveries(2).initialRedeliveryDelay(1) );

[1] http://activemq.apache.org/camel/error-handler.html

Willem
Mick Knutson wrote:
But I understand deadLetter to be a message that is not picked up. I am
talking about a message that is not processable.


On Tue, Sep 23, 2008 at 7:39 PM, Willem Jiang <[EMAIL PROTECTED]>wrote:

Hi

You don't need to call the exchange.isFailed(),  it just check if the
exchange's  fault message  or exception  is set.
Here is a Unit test of DeadLetterChannel[1],  which shows what you want.
Please check it out.

[1]
https://svn.apache.org/repos/asf/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java

Willem


Mick Knutson wrote:

To give some background here is my process:

   *public void process(Exchange exchange)
           throws Exception {
       log.info("process ChangeRequestInputTransformer request");

       String body = (String) exchange.getIn().getBody();

       // Get a Map of Items from the input message
       JSONObject jsonIn = new JSONObject(body);

       // validate input message, route to verifyErrorEndpoint if there
are
errors.
       String customerId = jsonIn.getString(Constants.CUSTOMER_ID);
       String type = jsonIn.getString(Constants.CHANGEREQUST_TYPE);
       String quota = jsonIn.getString(Constants.QUOTA);

       ChangeRequest changeRequest = null;

       try {

           if (type.equalsIgnoreCase(Constants.PROVISION)) {
               log.info("***** PROVISION *****");
               changeRequest = createProvisionChangeRequest(customerId,
quota); // can throw Exception
               exchange.getOut().setHeader(Constants.REQUEST_DESTINATION,
Constants.REQUEST_OUTPUT_CHANNEL);

           } else if (type.equalsIgnoreCase(Constants.DEPROVISION)) {
               log.info("DEPROVISION");
           } else {
               log.error("Invalid Change Request");
               exchange.getOut().setHeader(Constants.REQUEST_DESTINATION,
Constants.REQUEST_INPUT_ERROR_CHANNEL);
           }

           String jsonOut = toJSON(body);


 exchange.getOut().setMessageId(changeRequest.getChangeRequestId()
+ "");
           exchange.getOut().setHeader(Constants.CORRELATION_ID,
changeRequest.getChangeRequestId());
           exchange.getOut().setHeader(Constants.TIMEOUT, new
Integer(5000)); // fixme: 5 seconds....
           exchange.getOut().setHeader(Constants.CUSTOMER_ID,
changeRequest.getCustomerId());

           exchange.getOut().setBody(jsonOut);

           //todo need to rout to CR_INPUT_ERROR_CHANNEL if there is an
error.

           log.info("*********************************");
       } catch (Exception e) {
           exchange.isFailed();
           throw new Exception("Error creating Change Request");
       }
   }
*

Now, I get an exception with
*exchange.getOut().setMessageId(changeRequest.getChangeRequestId()
+ ""); *but my mock still gets the expected number of messages.

so I need to understand how to stop the current message, and redirect this
to an error channel instead.




On Tue, Sep 23, 2008 at 1:50 PM, Mick Knutson <[EMAIL PROTECTED]
wrote:

I have input messages that I am trying to process, and when there is an
error, I want to create a new exceptionMessage and put it onto an
inputErrorChannel .



--
---
Thank You…

Mick Knutson
BASE Logic, inc.
(415) 354-4215

Website: http://baselogic.com
Blog: http://baselogic.com/blog
BLiNC Magazine: http://blincmagazine.com
Linked IN: http://linkedin.com/in/mickknutson
DJ Mick: http://djmick.com
MySpace: http://myspace.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com









Reply via email to