You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mick Knutson <mk...@baselogic.com> on 2008/09/27 01:45:22 UTC

Re: setting dead Letter header in catch block?

I have also tried:

        } catch (Exception e) {

log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            exchange.getOut().setHeader(Constants.EXCEPTION_MESSAGE,
e.getMessage() + ".....");
            throw new RuntimeException(e);
        }


But this does not work as my Mock still does not get the error:


resultErrorEndpoint.message(0).header(Constants.EXCEPTION_MESSAGE).isNotNull();


This is always null. Can someone help?



On Thu, Sep 25, 2008 at 5:18 PM, Mick Knutson <mk...@baselogic.com>wrote:

> I have the following block that fails:
>
>         } catch (Exception e) {
>
> log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
> *// i want to set deadLetter headers here ******
>             throw new RuntimeException(e);
>         }
>
>
> How can I set my dead letter headers as to the error that occurred? Or is
> there a better way?
>
>
> --
> ---
> 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

Re: setting dead Letter header in catch block?

Posted by Mick Knutson <mk...@baselogic.com>.
But this is also help on my test. The original issue of this email was
trying to add message failure information into header properties. Can you
help me with both items?



On Mon, Sep 29, 2008 at 9:02 AM, Mick Knutson <mk...@baselogic.com>wrote:

> 1. the api *"resultErrorEndpoint.exepectedMessagedReceived(1);"* did not
> exist, but "*resultErrorEndpoint.expectedMessageCount(1);"* was there. I
> was already using that and here is my entire test:
>
>     public void testCreateInvalidChangeRequest(String inputDestinationURI,
>                                                String messageInputBody,
>                                                String messageOutputBody
>     )
>             throws Exception {
>
>         // setup RouteBuilder...
>         setRoutes(inputDestinationURI, changeRequestControllerImpl);
>
>         resultEndpoint.expectedMessageCount(0);
>      *   resultErrorEndpoint.expectedMessageCount(1);* // is always zero
>
>         // Create and Send message to input queue
>         createMessage(producerTemplate, messageInputBody);
>
>         resultErrorEndpoint.expectedMessageCount(1);
>
> resultErrorEndpoint.message(0).header(Constants.EXCEPTION_MESSAGE).isNotNull();
>
>
>         MockEndpoint.assertIsSatisfied(resultEndpoint,
> resultErrorEndpoint);
>     }
>
>
> Here is the 1st error caused from *resultEndpoint*:
>
>      <message>
>               <![CDATA[mock:*outputDestinationURI *Received message count.
> Expected: <0> but was: <1>]]>
>             </message>
>
> Then I comment out the *resultEndpoint *check. And get this error from *
> resultErrorEndpoint*:
>
> <message>
>               <![CDATA[mock:*outputErrorDestinationURI *Received message
> count. Expected: <1> but was: <0>]]>
>             </message>
>
>
>
>
> On Fri, Sep 26, 2008 at 11:25 PM, Claus Ibsen <ci...@silverbullet.dk> wrote:
>
>> Hi
>>
>> Could you try adding:
>> resultErrorEndpoint.exepectedMessagedReceived(1);
>>
>> before this line:
>>
>> resultErrorEndpoint.message(0).header(Constants.EXCEPTION_MESSAGE).isNotNull();
>>
>>
>>
>> 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:mknutson@baselogic.com]
>> Sent: 27. september 2008 01:45
>> To: Active MQ; Camel
>> Subject: Re: setting dead Letter header in catch block?
>>
>> I have also tried:
>>
>>        } catch (Exception e) {
>>
>> log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>>            exchange.getOut().setHeader(Constants.EXCEPTION_MESSAGE,
>> e.getMessage() + ".....");
>>            throw new RuntimeException(e);
>>        }
>>
>>
>> But this does not work as my Mock still does not get the error:
>>
>>
>>
>> resultErrorEndpoint.message(0).header(Constants.EXCEPTION_MESSAGE).isNotNull();
>>
>>
>> This is always null. Can someone help?
>>
>>
>>
>> On Thu, Sep 25, 2008 at 5:18 PM, Mick Knutson <mknutson@baselogic.com
>> >wrote:
>>
>> > I have the following block that fails:
>> >
>> >         } catch (Exception e) {
>> >
>> > log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>> > *// i want to set deadLetter headers here ******
>> >             throw new RuntimeException(e);
>> >         }
>> >
>> >
>> > How can I set my dead letter headers as to the error that occurred? Or
>> is
>> > there a better way?
>> >
>> >
>> > --
>> > ---
>> > 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
>
>


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

Re: setting dead Letter header in catch block?

Posted by Mick Knutson <mk...@baselogic.com>.
1. the api *"resultErrorEndpoint.exepectedMessagedReceived(1);"* did not
exist, but "*resultErrorEndpoint.expectedMessageCount(1);"* was there. I was
already using that and here is my entire test:

    public void testCreateInvalidChangeRequest(String inputDestinationURI,
                                               String messageInputBody,
                                               String messageOutputBody
    )
            throws Exception {

        // setup RouteBuilder...
        setRoutes(inputDestinationURI, changeRequestControllerImpl);

        resultEndpoint.expectedMessageCount(0);
     *   resultErrorEndpoint.expectedMessageCount(1);* // is always zero

        // Create and Send message to input queue
        createMessage(producerTemplate, messageInputBody);

        resultErrorEndpoint.expectedMessageCount(1);

resultErrorEndpoint.message(0).header(Constants.EXCEPTION_MESSAGE).isNotNull();


        MockEndpoint.assertIsSatisfied(resultEndpoint, resultErrorEndpoint);
    }


Here is the 1st error caused from *resultEndpoint*:

     <message>
              <![CDATA[mock:*outputDestinationURI *Received message count.
Expected: <0> but was: <1>]]>
            </message>

Then I comment out the *resultEndpoint *check. And get this error from *
resultErrorEndpoint*:

<message>
              <![CDATA[mock:*outputErrorDestinationURI *Received message
count. Expected: <1> but was: <0>]]>
            </message>



On Fri, Sep 26, 2008 at 11:25 PM, Claus Ibsen <ci...@silverbullet.dk> wrote:

> Hi
>
> Could you try adding:
> resultErrorEndpoint.exepectedMessagedReceived(1);
>
> before this line:
>
> resultErrorEndpoint.message(0).header(Constants.EXCEPTION_MESSAGE).isNotNull();
>
>
>
> 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:mknutson@baselogic.com]
> Sent: 27. september 2008 01:45
> To: Active MQ; Camel
> Subject: Re: setting dead Letter header in catch block?
>
> I have also tried:
>
>        } catch (Exception e) {
>
> log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>            exchange.getOut().setHeader(Constants.EXCEPTION_MESSAGE,
> e.getMessage() + ".....");
>            throw new RuntimeException(e);
>        }
>
>
> But this does not work as my Mock still does not get the error:
>
>
>
> resultErrorEndpoint.message(0).header(Constants.EXCEPTION_MESSAGE).isNotNull();
>
>
> This is always null. Can someone help?
>
>
>
> On Thu, Sep 25, 2008 at 5:18 PM, Mick Knutson <mknutson@baselogic.com
> >wrote:
>
> > I have the following block that fails:
> >
> >         } catch (Exception e) {
> >
> > log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
> > *// i want to set deadLetter headers here ******
> >             throw new RuntimeException(e);
> >         }
> >
> >
> > How can I set my dead letter headers as to the error that occurred? Or is
> > there a better way?
> >
> >
> > --
> > ---
> > 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

RE: setting dead Letter header in catch block?

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi 

Could you try adding:
resultErrorEndpoint.exepectedMessagedReceived(1);

before this line:
resultErrorEndpoint.message(0).header(Constants.EXCEPTION_MESSAGE).isNotNull();



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:mknutson@baselogic.com] 
Sent: 27. september 2008 01:45
To: Active MQ; Camel
Subject: Re: setting dead Letter header in catch block?

I have also tried:

        } catch (Exception e) {

log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            exchange.getOut().setHeader(Constants.EXCEPTION_MESSAGE,
e.getMessage() + ".....");
            throw new RuntimeException(e);
        }


But this does not work as my Mock still does not get the error:


resultErrorEndpoint.message(0).header(Constants.EXCEPTION_MESSAGE).isNotNull();


This is always null. Can someone help?



On Thu, Sep 25, 2008 at 5:18 PM, Mick Knutson <mk...@baselogic.com>wrote:

> I have the following block that fails:
>
>         } catch (Exception e) {
>
> log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
> *// i want to set deadLetter headers here ******
>             throw new RuntimeException(e);
>         }
>
>
> How can I set my dead letter headers as to the error that occurred? Or is
> there a better way?
>
>
> --
> ---
> 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