camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yiannis Mavroukakis <imavrouka...@gameaccountnetwork.com>
Subject Re: Modifying an Exchange inside a @RoutingSlip Bean
Date Mon, 28 Feb 2011 15:06:23 GMT
The other thing I am not aware of, is whether I am receiving a copy of the
Exchange, or the actual Exchange itself, does anyone which is the case? If I
am receiving a copy, is there some mechanism that will allow me to insert
arbitrary attributes in it, or is this simply not possible?

Thanks,

Ioannis

On 25 February 2011 15:33, Yiannis Mavroukakis <
imavroukakis@gameaccountnetwork.com> wrote:

> Hi Donald,
>
> It is already an Integer object and should be getting autoboxed anyway on
> ++, otherwise the code wouldn't compile in the first place,
> unless of course the semantics of prepending the ++ operator on a boxed
> primitive are acting a bit weird..
>
>
> On 25 February 2011 15:16, Donald Whytock <dwhytock@gmail.com> wrote:
>
>> Exchange.setProperty() expects an Object.  Perhaps box your
>> retry_count in an Integer?
>>
>> On Fri, Feb 25, 2011 at 3:43 AM, Yiannis Mavroukakis
>> <imavroukakis@gameaccountnetwork.com> wrote:
>> > Hello,
>> >
>> > I'm trying to add some ancillary information to an Exchange getting
>> picked
>> > up from a dead message queue for retries. I'm
>> > basically trying to add a retry count so after a certain amount of
>> pickups
>> > from the dead queue the message is forwarded to
>> > a final queue and remains there for manual inspection. This is the code
>> that
>> > I have that does this
>> >
>> >    @RoutingSlip
>> >
>> >    public final String[ ] routeEvent( final Exchange exchange , final
>> Event
>> > event )
>> >
>> >    {
>> >
>> >        final Exception cause = exchange.getProperty( Exchange.
>> > EXCEPTION_CAUGHT , Exception.class );
>> >
>> >        final Date createdDate = exchange.getProperty( Exchange.
>> > CREATED_TIMESTAMP , Date.class );
>> >
>> >        Integer retryCount = exchange.getProperty( TOTAL_RETRIES ,
>> Integer.
>> > class );
>> >
>> >        final String[ ] route;
>> >
>> >        if( retryCount == null )
>> >
>> >        {
>> >
>> >            retryCount = 0;
>> >
>> >
>> >        }
>> >
>> >
>> >        if( retryCount > MAX_TOTAL_RETRIES )
>> >
>> >        {
>> >
>> >            LOG.info( "Max retry count of {} reached for message {}
>> > discarding" , retryCount , exchange.getExchangeId( ) );
>> >
>> >            route = reallyDead;
>> >
>> >        }
>> >
>> >        else
>> >
>> >        {
>> >
>> >            exchange.setProperty( TOTAL_RETRIES , ++retryCount );
>> >
>> >            LOG.info( "Retrying dead message, message created {},
>> exception
>> > " , createdDate , cause );
>> >
>> >            LOG.info( "{} retries left for message id {} " ,
>> > MAX_TOTAL_RETRIES - retryCount , exchange.getIn( )
>> >
>> >                    .getMessageId( ) );
>> >
>> >            route = super.routeEvent( event );
>> >
>> >        }
>> >
>> >        return route;
>> >
>> >    }
>> >
>> >
>> > While testing, the retryCount is always 0, which implies that the
>> Exchange
>> > modified is a copy and not the one I modified in the first
>> > pass of a failed message. I guess my question is, am I trying to do
>> > something that there's already some DSL, or am I simply using the
>> Exchange
>> > the wrong way, and I have to pass it on somehow?
>> >
>> > Thank you,
>> >
>> > Ioannis
>> >
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message