I can not se any ERROR in the console. They are all DEBUG, WARN etc. but no 
ERROR.

Try setting log4j loglevel to INFO to get rid of DEBUG logging.

Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Mick Knutson [mailto:[EMAIL PROTECTED] 
Sent: 25. september 2008 19:19
To: camel-user@activemq.apache.org
Subject: Re: Trying to understand how to deal with process() errors and 
creating an exceptionChannel for bad messages.

I looked at the test example again:
https://svn.apache.org/repos/asf/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java
*
So then I changed my test routing to:*

        *camelContext.addRoutes(new RouteBuilder() {
            public void configure() {

                from(inputUri).errorHandler(
                        deadLetterChannel(MOCK_OUTPUT_ERROR_DESTINATION_URI)
//.maximumRedeliveries(2)
                                //.initialRedeliveryDelay(1)
                                .loggingLevel(LoggingLevel.DEBUG)

                ).process(processor).to(MOCK_OUTPUT_DESTINATION_URI);
            }
        });
*
*
But I still have an error thrown in my console:*

*[myproject] DEBUG [ActiveMQ Transport Stopper: vm://localhost#10]
TransportConnection.doStop(927) | Stopping connection: vm://localhost#10
[myproject] DEBUG [DefaultMessageListenerContainer-1]
EndpointMessageListener.onMessage(61) |
Endpoint[activemq:queue:channel/changerequest/add] consumer receiving JMS
message: ActiveMQTextMessage {commandId = 5, responseRequired = true,
messageId = ID:mickknutson-2702-1222362317888-2:5:1:1:1, origi
nalDestination = null, originalTransactionId = null, producerId =
ID:mickknutson-2702-1222362317888-2:5:1:1, destination =
queue://channel/changerequest/add, transactionId = null, expiration = 0,
timestamp = 1222362321716, arrival = 0, brokerInTime = 1222362321716,
brokerOutTime = 1222362321716, cor
relationId = null, replyTo = null, persistent = true, type = null, priority
= 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed
= false, userID = null, content = null, marshalledProperties = null,
dataStructure = null, redeliveryCounter = 0, size = 1024, properties = null,
readOnlyProperties = true, readOnlyBody = true, droppable = false, text =
{"customerId":"abcd","changeRequestType":"BADREQUEST","quota":"xyz"}}
[myproject] INFO [DefaultMessageListenerContainer-1]
ChangeRequestControllerImpl.process(32) | *********************************
[myproject] INFO [DefaultMessageListenerContainer-1]
ChangeRequestControllerImpl.process(33) |
ChangeRequestControllerImpl.process(Exchange)
[myproject] INFO [DefaultMessageListenerContainer-1]
ChangeRequestControllerImpl.process(78) |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX
[myproject] DEBUG [DefaultMessageListenerContainer-1] Pipeline.process(67) |
Message exchange has failed so breaking out of pipeline:
Exchange[JmsMessage: ActiveMQTextMessage {commandId = 5, responseRequired =
true, messageId = ID:mickknutson-2702-1222362317888-2:5:1:1:1,
originalDestination = null,  originalTransactionId = null, producerId =
ID:mickknutson-2702-1222362317888-2:5:1:1, destination =
queue://channel/changerequest/add, transactionId = null, expiration = 0,
timestamp = 1222362321716, arrival = 0, brokerInTime = 1222362321716,
brokerOutTime = 1222362321716, correlationId = null, replyTo = null,
persistent = true, type = null, priority = 4, groupID = null, groupSequence
= 0, targetConsumerId = null, compressed = false, userID = null, content =
null, marshalledProperties = null, dataStructure = null, redeliveryCounter =
0, size = 1024, properties = null, readOnlyProperties = true, readOnlyBody =
true, droppable = false, text =
{"customerId":"abcd","changeRequestType":"BADREQUEST","quota":"xyz"}}]
exception: java.lang.RuntimeE
xception: org.codehaus.jettison.json.JSONException: JSONObject["customerId"]
is not a number. fault: null
[myproject] WARN [DefaultMessageListenerContainer-1]
EndpointMessageListener.onMessage(80) |
Endpoint[activemq:queue:channel/changerequest/add] consumer caught an
exception while processing JMS message: ActiveMQTextMessage {commandId = 5,
responseRequired = true, messageId =
ID:mickknutson-2702-1222362317888-2:5:1:1:1, originalDestination = null,
originalTransactionId = null, producerId =
ID:mickknutson-2702-1222362317888-2:5:1:1, destination =
queue://channel/changerequest/add, transactionId = null, expiration = 0,
timestamp = 1222362321716, arrival = 0, brokerInTime = 1222362321716,
brokerOu
tTime = 1222362321716, correlationId = null, replyTo = null, persistent =
true, type = null, priority = 4, groupID = null, groupSequence = 0,
targetConsumerId = null, compressed = false, userID = null, content = null,
marshalledProperties = null, dataStructure = null, redeliveryCounter = 0,
size = 1024, properties = null, readOnlyProperties = true, readOnlyBody =
true, droppable = false, text =
{"customerId":"abcd","changeRequestType":"BADREQUEST
","quota":"xyz"}} org.apache.camel.RuntimeCamelException:
java.lang.RuntimeException: org.codehaus.jettison.json.JSONException:
JSONObject["customerId"] is not a number.


*
1st issue, is why does my MOCK_OUTPUT_DESTINATION_URI get the message when a
RuntimeException is thrown.

2nd issue is why does my MOCK_OUTPUT_ERROR_DESTINATION_URI not get any
messages at all.


*Here is my TestNG results:*
          *<exception class="java.lang.AssertionError">
            <message>
              <![CDATA[mock:outputDestinationURI Received message
count. Expected:
<0> but was: <1>]]>
            </message>
*

*So I also added this to my test as per the Unit Test listed above:*

*Throwable t =
resultErrorEndpoint.getExchanges().get(0).getProperty(DeadLetterChannel.EXCEPTION_CAUSE_PROPERTY,
Throwable.class);
*

*Then I started getting:*

*<full-stacktrace>
              <![CDATA[java.lang.ArrayIndexOutOfBoundsException: 0
    at
java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:343)
    at
com.servepath.changerequest.ChangeRequestTest.testCreateInvalidChangeRequest(ChangeRequestTest.java:138)
*






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

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


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