The "mock:fail" is just for the testing, you can use your endpoint URI for the error message receiving. I just went through the codes in your mail, can you remove the below can from router configure and try again?

exception(Exception.class).process(changeRequestInputExceptionProcessor).to(MOCK_OUTPUT_ERROR_DESTINATION_URI);


Willem.

Mick Knutson wrote:
But my test throws an exception, and created a*MOCK_OUTPUT_ERROR_DESTINATION_URI
* Mock instead of the name used "mock:fail" or is there some reason I have
to use "mock:fail" instead of my endpoint?




On Wed, Sep 24, 2008 at 10:34 PM, Mick Knutson <[EMAIL PROTECTED]>wrote:

But my test throws an exception, and created

On Wed, Sep 24, 2008 at 8:23 PM, Willem Jiang <[EMAIL PROTECTED]>wrote:

Can you take a look at the below unit test, the message is only sent to
the "mock:fail" endpoint when the exception is thrown.


Willem Jiang 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







--
---
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