You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tom Ellis <te...@gmail.com> on 2013/09/18 11:07:05 UTC

Dynamic tokenizeXML tagname

Hi Everyone,

Is it possible to have a dynamic tagName parameter specified for the
tokenizeXML function of the Tokenizer language?

For example, say as part of a route I inspect a big incoming payload
and determine that it is of type Orders, so wish to set my tagName as
"order". However on the same route Parts could be sent, so I wish to
tokenize based on the tagName "part".

I was hoping that maybe I could build it using a Simple expression or
something, e.g.

from("file:inbox")
  .beanRef("inspectPayload") // adds payloadTag to the exchange header
which is the tag name we wish to tokenize on
  .split().tokenizeXML("${in.payloadTag}").streaming()
     .to("activemq:queue:tags");

but from the code it seems that tokenizeXML uses the tagName specified
to build the start and end tokens.

Does anyone have any ideas on how I could do this without having to
specify a route for each incoming type?

Cheers,

Tom

Re: Dynamic tokenizeXML tagname

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

6.1 will be released later this year.

We are moving towards our internal code-freeze deadline at the end of
this month.
And after that its the QA / release process / whatnot that takes it time.

There is EA binaries people can download and try. Though we only hand
out the link for people in private

On Wed, Sep 18, 2013 at 12:33 PM, Tom Ellis <te...@gmail.com> wrote:
> Unfortunately we're using Fuse 6.0 so stuck on 2.10 - but if I'm not
> mistaken I see the Fuse 6.1 ea has 2.12 in it, and the number of
> unresolved issues left for 6.1 on JIRA keep going down - any stab in
> the dark estimates of when 6.1 is released? ;)
>
> On 18 September 2013 11:28, Claus Ibsen <cl...@gmail.com> wrote:
>> Hi
>>
>> Yeah, or if you use Camel 2.12 you can use data format component
>> http://camel.apache.org/dataformat-component
>>
>> And with the "dynamic to"
>> http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html
>>
>> On Wed, Sep 18, 2013 at 12:22 PM, Tom Ellis <te...@gmail.com> wrote:
>>> In that same vein - how could I dynamically provide a data format to
>>> use when unmarshalling? Would it be appropriate to implement a custom
>>> data format and inside that create the correct data format and execute
>>> as required, and then configure with something like:
>>>
>>> split.method(MyTokenBean.class,
>>> "myTokenizeXML").streaming().unmarshal().custom("myDataFormat")..
>>>
>>> On 18 September 2013 10:37, Tom Ellis <te...@gmail.com> wrote:
>>>> Perfect, thanks Claus.
>>>>
>>>> On 18 September 2013 10:31, Claus Ibsen <cl...@gmail.com> wrote:
>>>>> You can use a method call expression and call a method on a pojo. And
>>>>> there use the tokenizexml language where you of course in java code
>>>>> can compute the tag names.
>>>>>
>>>>> public static Expression myTokenizeXML(String data) {
>>>>>   // figure out the tag name
>>>>>   return TokenizeLanguage.tokenizeXML(tagName, xxx);
>>>>> }
>>>>>
>>>>> split().method(MyTokenBean.class, "myTokenizeXML").streaming().
>>>>>
>>>>> On Wed, Sep 18, 2013 at 11:07 AM, Tom Ellis <te...@gmail.com> wrote:
>>>>>> Hi Everyone,
>>>>>>
>>>>>> Is it possible to have a dynamic tagName parameter specified for the
>>>>>> tokenizeXML function of the Tokenizer language?
>>>>>>
>>>>>> For example, say as part of a route I inspect a big incoming payload
>>>>>> and determine that it is of type Orders, so wish to set my tagName as
>>>>>> "order". However on the same route Parts could be sent, so I wish to
>>>>>> tokenize based on the tagName "part".
>>>>>>
>>>>>> I was hoping that maybe I could build it using a Simple expression or
>>>>>> something, e.g.
>>>>>>
>>>>>> from("file:inbox")
>>>>>>   .beanRef("inspectPayload") // adds payloadTag to the exchange header
>>>>>> which is the tag name we wish to tokenize on
>>>>>>   .split().tokenizeXML("${in.payloadTag}").streaming()
>>>>>>      .to("activemq:queue:tags");
>>>>>>
>>>>>> but from the code it seems that tokenizeXML uses the tagName specified
>>>>>> to build the start and end tokens.
>>>>>>
>>>>>> Does anyone have any ideas on how I could do this without having to
>>>>>> specify a route for each incoming type?
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Tom
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Claus Ibsen
>>>>> -----------------
>>>>> Red Hat, Inc.
>>>>> Email: cibsen@redhat.com
>>>>> Twitter: davsclaus
>>>>> Blog: http://davsclaus.com
>>>>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Dynamic tokenizeXML tagname

Posted by Tom Ellis <te...@gmail.com>.
Unfortunately we're using Fuse 6.0 so stuck on 2.10 - but if I'm not
mistaken I see the Fuse 6.1 ea has 2.12 in it, and the number of
unresolved issues left for 6.1 on JIRA keep going down - any stab in
the dark estimates of when 6.1 is released? ;)

On 18 September 2013 11:28, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Yeah, or if you use Camel 2.12 you can use data format component
> http://camel.apache.org/dataformat-component
>
> And with the "dynamic to"
> http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html
>
> On Wed, Sep 18, 2013 at 12:22 PM, Tom Ellis <te...@gmail.com> wrote:
>> In that same vein - how could I dynamically provide a data format to
>> use when unmarshalling? Would it be appropriate to implement a custom
>> data format and inside that create the correct data format and execute
>> as required, and then configure with something like:
>>
>> split.method(MyTokenBean.class,
>> "myTokenizeXML").streaming().unmarshal().custom("myDataFormat")..
>>
>> On 18 September 2013 10:37, Tom Ellis <te...@gmail.com> wrote:
>>> Perfect, thanks Claus.
>>>
>>> On 18 September 2013 10:31, Claus Ibsen <cl...@gmail.com> wrote:
>>>> You can use a method call expression and call a method on a pojo. And
>>>> there use the tokenizexml language where you of course in java code
>>>> can compute the tag names.
>>>>
>>>> public static Expression myTokenizeXML(String data) {
>>>>   // figure out the tag name
>>>>   return TokenizeLanguage.tokenizeXML(tagName, xxx);
>>>> }
>>>>
>>>> split().method(MyTokenBean.class, "myTokenizeXML").streaming().
>>>>
>>>> On Wed, Sep 18, 2013 at 11:07 AM, Tom Ellis <te...@gmail.com> wrote:
>>>>> Hi Everyone,
>>>>>
>>>>> Is it possible to have a dynamic tagName parameter specified for the
>>>>> tokenizeXML function of the Tokenizer language?
>>>>>
>>>>> For example, say as part of a route I inspect a big incoming payload
>>>>> and determine that it is of type Orders, so wish to set my tagName as
>>>>> "order". However on the same route Parts could be sent, so I wish to
>>>>> tokenize based on the tagName "part".
>>>>>
>>>>> I was hoping that maybe I could build it using a Simple expression or
>>>>> something, e.g.
>>>>>
>>>>> from("file:inbox")
>>>>>   .beanRef("inspectPayload") // adds payloadTag to the exchange header
>>>>> which is the tag name we wish to tokenize on
>>>>>   .split().tokenizeXML("${in.payloadTag}").streaming()
>>>>>      .to("activemq:queue:tags");
>>>>>
>>>>> but from the code it seems that tokenizeXML uses the tagName specified
>>>>> to build the start and end tokens.
>>>>>
>>>>> Does anyone have any ideas on how I could do this without having to
>>>>> specify a route for each incoming type?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Tom
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> -----------------
>>>> Red Hat, Inc.
>>>> Email: cibsen@redhat.com
>>>> Twitter: davsclaus
>>>> Blog: http://davsclaus.com
>>>> Author of Camel in Action: http://www.manning.com/ibsen
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen

Re: Dynamic tokenizeXML tagname

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah, or if you use Camel 2.12 you can use data format component
http://camel.apache.org/dataformat-component

And with the "dynamic to"
http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

On Wed, Sep 18, 2013 at 12:22 PM, Tom Ellis <te...@gmail.com> wrote:
> In that same vein - how could I dynamically provide a data format to
> use when unmarshalling? Would it be appropriate to implement a custom
> data format and inside that create the correct data format and execute
> as required, and then configure with something like:
>
> split.method(MyTokenBean.class,
> "myTokenizeXML").streaming().unmarshal().custom("myDataFormat")..
>
> On 18 September 2013 10:37, Tom Ellis <te...@gmail.com> wrote:
>> Perfect, thanks Claus.
>>
>> On 18 September 2013 10:31, Claus Ibsen <cl...@gmail.com> wrote:
>>> You can use a method call expression and call a method on a pojo. And
>>> there use the tokenizexml language where you of course in java code
>>> can compute the tag names.
>>>
>>> public static Expression myTokenizeXML(String data) {
>>>   // figure out the tag name
>>>   return TokenizeLanguage.tokenizeXML(tagName, xxx);
>>> }
>>>
>>> split().method(MyTokenBean.class, "myTokenizeXML").streaming().
>>>
>>> On Wed, Sep 18, 2013 at 11:07 AM, Tom Ellis <te...@gmail.com> wrote:
>>>> Hi Everyone,
>>>>
>>>> Is it possible to have a dynamic tagName parameter specified for the
>>>> tokenizeXML function of the Tokenizer language?
>>>>
>>>> For example, say as part of a route I inspect a big incoming payload
>>>> and determine that it is of type Orders, so wish to set my tagName as
>>>> "order". However on the same route Parts could be sent, so I wish to
>>>> tokenize based on the tagName "part".
>>>>
>>>> I was hoping that maybe I could build it using a Simple expression or
>>>> something, e.g.
>>>>
>>>> from("file:inbox")
>>>>   .beanRef("inspectPayload") // adds payloadTag to the exchange header
>>>> which is the tag name we wish to tokenize on
>>>>   .split().tokenizeXML("${in.payloadTag}").streaming()
>>>>      .to("activemq:queue:tags");
>>>>
>>>> but from the code it seems that tokenizeXML uses the tagName specified
>>>> to build the start and end tokens.
>>>>
>>>> Does anyone have any ideas on how I could do this without having to
>>>> specify a route for each incoming type?
>>>>
>>>> Cheers,
>>>>
>>>> Tom
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> Red Hat, Inc.
>>> Email: cibsen@redhat.com
>>> Twitter: davsclaus
>>> Blog: http://davsclaus.com
>>> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Dynamic tokenizeXML tagname

Posted by Tom Ellis <te...@gmail.com>.
In that same vein - how could I dynamically provide a data format to
use when unmarshalling? Would it be appropriate to implement a custom
data format and inside that create the correct data format and execute
as required, and then configure with something like:

split.method(MyTokenBean.class,
"myTokenizeXML").streaming().unmarshal().custom("myDataFormat")..

On 18 September 2013 10:37, Tom Ellis <te...@gmail.com> wrote:
> Perfect, thanks Claus.
>
> On 18 September 2013 10:31, Claus Ibsen <cl...@gmail.com> wrote:
>> You can use a method call expression and call a method on a pojo. And
>> there use the tokenizexml language where you of course in java code
>> can compute the tag names.
>>
>> public static Expression myTokenizeXML(String data) {
>>   // figure out the tag name
>>   return TokenizeLanguage.tokenizeXML(tagName, xxx);
>> }
>>
>> split().method(MyTokenBean.class, "myTokenizeXML").streaming().
>>
>> On Wed, Sep 18, 2013 at 11:07 AM, Tom Ellis <te...@gmail.com> wrote:
>>> Hi Everyone,
>>>
>>> Is it possible to have a dynamic tagName parameter specified for the
>>> tokenizeXML function of the Tokenizer language?
>>>
>>> For example, say as part of a route I inspect a big incoming payload
>>> and determine that it is of type Orders, so wish to set my tagName as
>>> "order". However on the same route Parts could be sent, so I wish to
>>> tokenize based on the tagName "part".
>>>
>>> I was hoping that maybe I could build it using a Simple expression or
>>> something, e.g.
>>>
>>> from("file:inbox")
>>>   .beanRef("inspectPayload") // adds payloadTag to the exchange header
>>> which is the tag name we wish to tokenize on
>>>   .split().tokenizeXML("${in.payloadTag}").streaming()
>>>      .to("activemq:queue:tags");
>>>
>>> but from the code it seems that tokenizeXML uses the tagName specified
>>> to build the start and end tokens.
>>>
>>> Does anyone have any ideas on how I could do this without having to
>>> specify a route for each incoming type?
>>>
>>> Cheers,
>>>
>>> Tom
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen

Re: Dynamic tokenizeXML tagname

Posted by Tom Ellis <te...@gmail.com>.
Perfect, thanks Claus.

On 18 September 2013 10:31, Claus Ibsen <cl...@gmail.com> wrote:
> You can use a method call expression and call a method on a pojo. And
> there use the tokenizexml language where you of course in java code
> can compute the tag names.
>
> public static Expression myTokenizeXML(String data) {
>   // figure out the tag name
>   return TokenizeLanguage.tokenizeXML(tagName, xxx);
> }
>
> split().method(MyTokenBean.class, "myTokenizeXML").streaming().
>
> On Wed, Sep 18, 2013 at 11:07 AM, Tom Ellis <te...@gmail.com> wrote:
>> Hi Everyone,
>>
>> Is it possible to have a dynamic tagName parameter specified for the
>> tokenizeXML function of the Tokenizer language?
>>
>> For example, say as part of a route I inspect a big incoming payload
>> and determine that it is of type Orders, so wish to set my tagName as
>> "order". However on the same route Parts could be sent, so I wish to
>> tokenize based on the tagName "part".
>>
>> I was hoping that maybe I could build it using a Simple expression or
>> something, e.g.
>>
>> from("file:inbox")
>>   .beanRef("inspectPayload") // adds payloadTag to the exchange header
>> which is the tag name we wish to tokenize on
>>   .split().tokenizeXML("${in.payloadTag}").streaming()
>>      .to("activemq:queue:tags");
>>
>> but from the code it seems that tokenizeXML uses the tagName specified
>> to build the start and end tokens.
>>
>> Does anyone have any ideas on how I could do this without having to
>> specify a route for each incoming type?
>>
>> Cheers,
>>
>> Tom
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen

Re: Dynamic tokenizeXML tagname

Posted by Claus Ibsen <cl...@gmail.com>.
You can use a method call expression and call a method on a pojo. And
there use the tokenizexml language where you of course in java code
can compute the tag names.

public static Expression myTokenizeXML(String data) {
  // figure out the tag name
  return TokenizeLanguage.tokenizeXML(tagName, xxx);
}

split().method(MyTokenBean.class, "myTokenizeXML").streaming().

On Wed, Sep 18, 2013 at 11:07 AM, Tom Ellis <te...@gmail.com> wrote:
> Hi Everyone,
>
> Is it possible to have a dynamic tagName parameter specified for the
> tokenizeXML function of the Tokenizer language?
>
> For example, say as part of a route I inspect a big incoming payload
> and determine that it is of type Orders, so wish to set my tagName as
> "order". However on the same route Parts could be sent, so I wish to
> tokenize based on the tagName "part".
>
> I was hoping that maybe I could build it using a Simple expression or
> something, e.g.
>
> from("file:inbox")
>   .beanRef("inspectPayload") // adds payloadTag to the exchange header
> which is the tag name we wish to tokenize on
>   .split().tokenizeXML("${in.payloadTag}").streaming()
>      .to("activemq:queue:tags");
>
> but from the code it seems that tokenizeXML uses the tagName specified
> to build the start and end tokens.
>
> Does anyone have any ideas on how I could do this without having to
> specify a route for each incoming type?
>
> Cheers,
>
> Tom



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen