Quantcast

Flatpack Example

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Flatpack Example

Chris Geer
If there an example anywhere demonstrating how to use the flatpack
component? I've been playing with it with very little success. I've got the
very simple case working:

      <camel:camelContext id="flatpackTest" trace="true">
        <camel:route>
          <camel:from uri="file:///tmp/inttest"/>
          <camel:to uri="flatpack:foo"/>
        </camel:route>
        <camel:route>
          <camel:from uri="flatpack:foo"/>
          <camel:to uri="log:test2?showAll=true"/>
        </camel:route>
    </camel:camelContext>

This will create a message on the second route for each line in my file but
it is essentially useless because it can't parse it without config data.
Flatpack seems to have a way to pass in a config file using the uri
"flatpack:[fixed|delim]:<config>" but when I try and use it I can't get it
to work.

      <camel:camelContext id="flatpackTest" trace="true">
        <camel:route>
          <camel:from uri="file:///tmp/inttest"/>
          <camel:to uri="flatpack:fixed:config.pzmap"/>
          <camel:to uri="log:firstRoute?showAll=true"/>
        </camel:route>
        <camel:route>
          <camel:from uri="flatpack:fixed:config.pzmap"/>
          <camel:to uri="log:secondRoute?showAll=true"/>
        </camel:route>
    </camel:camelContext>

I'm just not sure what the from in the second route should be. I've tried
all sorts of combinations but none of them work and the second route never
gets triggered. The log in the first route will trigger but it just shows
the body of the message as the Generic File.

In looking through the code it looks like flatpack copies the original
exchange and passes the messages along to a load balancer. Anyone know what
the correct "from" uri is for the second route to get all the messages?

Thanks,
Chris
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Flatpack Example

Claus Ibsen-2
Hi

Just a quick suggestion. Have you looked at the unit tests of camel-flatpack?
Often there is "good" examples there.

Also when something doesn't work, mention the Camel version, and what
runtime you use, eg Tomcat, ServiceMix etc.
And especially with OSGi, loading resources on classpath can be tricky.


On Tue, May 22, 2012 at 1:26 AM, Chris Geer <[hidden email]> wrote:

> If there an example anywhere demonstrating how to use the flatpack
> component? I've been playing with it with very little success. I've got the
> very simple case working:
>
>      <camel:camelContext id="flatpackTest" trace="true">
>        <camel:route>
>          <camel:from uri="file:///tmp/inttest"/>
>          <camel:to uri="flatpack:foo"/>
>        </camel:route>
>        <camel:route>
>          <camel:from uri="flatpack:foo"/>
>          <camel:to uri="log:test2?showAll=true"/>
>        </camel:route>
>    </camel:camelContext>
>
> This will create a message on the second route for each line in my file but
> it is essentially useless because it can't parse it without config data.
> Flatpack seems to have a way to pass in a config file using the uri
> "flatpack:[fixed|delim]:<config>" but when I try and use it I can't get it
> to work.
>
>      <camel:camelContext id="flatpackTest" trace="true">
>        <camel:route>
>          <camel:from uri="file:///tmp/inttest"/>
>          <camel:to uri="flatpack:fixed:config.pzmap"/>
>          <camel:to uri="log:firstRoute?showAll=true"/>
>        </camel:route>
>        <camel:route>
>          <camel:from uri="flatpack:fixed:config.pzmap"/>
>          <camel:to uri="log:secondRoute?showAll=true"/>
>        </camel:route>
>    </camel:camelContext>
>
> I'm just not sure what the from in the second route should be. I've tried
> all sorts of combinations but none of them work and the second route never
> gets triggered. The log in the first route will trigger but it just shows
> the body of the message as the Generic File.
>
> In looking through the code it looks like flatpack copies the original
> exchange and passes the messages along to a load balancer. Anyone know what
> the correct "from" uri is for the second route to get all the messages?
>
> Thanks,
> Chris



--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Flatpack Example

Claus Ibsen-2
On Tue, May 22, 2012 at 8:10 AM, Chris Geer <[hidden email]> wrote:

> Sorry Claus for the lack of details...
>  - Camel 2.9.2
>  - Karaf 2.2.4
>
> I did look at the unit tests and they matched what I had. You are correct
> though that there are some good examples in there.
>
> I did finally find my problem though. I am using a fixed length file and I
> had tried two thing:
> 1) Setting the config to the full length of a line
> 2) Setting the config to only deal with a subset of the line.
>
> As it turns out, I was off by 1 character (747 vs 748) when I tried the
> full length, when I adjusted it properly it started to work better. The
> challenge/frustration was that when I was off by one character or just
> tried the subset of the line there was no indication of a problem, it just
> failed silently because the flatpack error messages aren't processed based
> on a quick look through the code.
>
> So, it looks like there are some additions that could be made to flatpack
> to make it a little more user friendly and flexible. I'll take some time
> tomorrow to craft up some JIRA items and put together some patches possibly.
>

Great we love contributions.

> On a side note, the Endpoint uses a round robin load balancer internally to
> process the messages. Does that imply you can somehow register multiple
> outputs from the component? How would you do that exactly?
>

No not really. That was the coding style back from the 1.x.
Just use the EIPs in the DSL if you want to load balance, multicast,
split, or whatnot.


> Thanks,
> Chris
>
> On Mon, May 21, 2012 at 8:49 PM, Claus Ibsen <[hidden email]> wrote:
>
>> Hi
>>
>> Just a quick suggestion. Have you looked at the unit tests of
>> camel-flatpack?
>> Often there is "good" examples there.
>>
>> Also when something doesn't work, mention the Camel version, and what
>> runtime you use, eg Tomcat, ServiceMix etc.
>> And especially with OSGi, loading resources on classpath can be tricky.
>>
>>
>> On Tue, May 22, 2012 at 1:26 AM, Chris Geer <[hidden email]> wrote:
>> > If there an example anywhere demonstrating how to use the flatpack
>> > component? I've been playing with it with very little success. I've got
>> the
>> > very simple case working:
>> >
>> >      <camel:camelContext id="flatpackTest" trace="true">
>> >        <camel:route>
>> >          <camel:from uri="file:///tmp/inttest"/>
>> >          <camel:to uri="flatpack:foo"/>
>> >        </camel:route>
>> >        <camel:route>
>> >          <camel:from uri="flatpack:foo"/>
>> >          <camel:to uri="log:test2?showAll=true"/>
>> >        </camel:route>
>> >    </camel:camelContext>
>> >
>> > This will create a message on the second route for each line in my file
>> but
>> > it is essentially useless because it can't parse it without config data.
>> > Flatpack seems to have a way to pass in a config file using the uri
>> > "flatpack:[fixed|delim]:<config>" but when I try and use it I can't get
>> it
>> > to work.
>> >
>> >      <camel:camelContext id="flatpackTest" trace="true">
>> >        <camel:route>
>> >          <camel:from uri="file:///tmp/inttest"/>
>> >          <camel:to uri="flatpack:fixed:config.pzmap"/>
>> >          <camel:to uri="log:firstRoute?showAll=true"/>
>> >        </camel:route>
>> >        <camel:route>
>> >          <camel:from uri="flatpack:fixed:config.pzmap"/>
>> >          <camel:to uri="log:secondRoute?showAll=true"/>
>> >        </camel:route>
>> >    </camel:camelContext>
>> >
>> > I'm just not sure what the from in the second route should be. I've tried
>> > all sorts of combinations but none of them work and the second route
>> never
>> > gets triggered. The log in the first route will trigger but it just shows
>> > the body of the message as the Generic File.
>> >
>> > In looking through the code it looks like flatpack copies the original
>> > exchange and passes the messages along to a load balancer. Anyone know
>> what
>> > the correct "from" uri is for the second route to get all the messages?
>> >
>> > Thanks,
>> > Chris
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
>> FuseSource
>> Email: [hidden email]
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>



--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Loading...