camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Hoffer <dhoff...@gmail.com>
Subject Re: How to retain exchange headers through RoutingSlip
Date Sun, 04 Oct 2015 14:20:35 GMT
I'm not trying to add any headers to the file when reading and
writing...I'm just adding them to the Camel Exchange so that when the file
is written in my Processor I have some 'metadata' about the file.  I need
the 'metadata' so I know where to write the file.  I get the bytes to write
from the exchange it seems only natural to get the 'metadata' from the same
exchange.  Why does Camel throw the headers away?  I'm pretty new to
Camel...not sure how to add a custom message transformation...any examples
of that?

Btw, I have no need for the header information after I write the file in my
processor...only before.

-Dave

On Sun, Oct 4, 2015 at 12:15 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:

> Hi
>
> Ah yeah read from a file and a file does not include any headers when
> you write to a file. The body is the content of the file. And all
> headers is not stored. You need to do some kind of custom message
> transformation if you want to include headers, and also when you read
> the file. eg where should the headers be stored in the file?
>
> On Sat, Oct 3, 2015 at 2:33 PM, David Hoffer <dhoffer6@gmail.com> wrote:
> > We add the headers where we create and/or call process on the routing
> > slip...
> >
> > exchange.getIn().setHeader("customHeader1", somedata1);
> > exchange.getIn().setHeader("customHeader2", somedata2);
> > exchange.getIn().setHeader(routingSlipHeaderName, toUris);
> > routingSlip.process(exchange);
> >
> > But then when when the message is handled by a processor bean we try to
> get
> > the header back via
> >
> > String data1 = (String) exchange.getIn().getHeader("customHeader1");
> >
> > This always returns null and it removed the 'routingSlipHeaderName'
> header
> > too that used used by the routing slip.  (Its okay that it removed this
> > one...but need the others.)
> >
> > Here is the XML config for the receiving route.  The CopyFileProcessor is
> > the one that does not get the custom headers.
> >
> > <bean id="backupProcessor"
> > class="com.issinc.jms.gangplank.impl.CopyFileProcessor">
> >     <property name="path" value="${gp.camel.backup.dir}"/>
> > </bean>
> >
> > <routeContext id="backup-endpoint"
> > xmlns="http://camel.apache.org/schema/spring">
> >     <route id="to_backup" autoStartup="{{gp.camel.backup.isConfigured}}">
> >         <from
> uri="file://{{gangplank.data}}/toBackup/?delete=true&amp;moveFailed=.error&amp;filter=#partialFilter&amp;delay=200"/>
> >         <process ref="backupProcessor" />
> >         <onException redeliveryPolicyRef="redeliveryProfile">
> >             <exception>java.lang.Exception</exception>
> >             <handled>
> >                 <constant>false</constant>
> >             </handled>
> >         </onException>
> >     </route>
> > </routeContext>
> >
> >
> >
> >
> > -Dave
> >
> > On Sat, Oct 3, 2015 at 2:27 AM, Claus Ibsen <claus.ibsen@gmail.com>
> wrote:
> >
> >> Where do you set those custom headers?
> >>
> >> On Fri, Oct 2, 2015 at 8:20 PM, David Hoffer <dhoffer6@gmail.com>
> wrote:
> >> > I'm using a RoutingSlip to route files but all custom headers set on
> the
> >> > Exchange are discarded.  I assume that's because Camel assumes custom
> >> > headers are not useful for file messages but I need a way to pass
> source
> >> > information from the RoutingSlip to the file Processors.
> >> >
> >> > How can I do this?  Is there a way I can override the default
> behavior of
> >> > removing all custom headers?
> >> >
> >> > -Dave
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> http://davsclaus.com @davsclaus
> >> Camel in Action 2nd edition:
> >> https://www.manning.com/books/camel-in-action-second-edition
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2nd edition:
> https://www.manning.com/books/camel-in-action-second-edition
>

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