Re: Functions in Camel

2024-01-08 Thread ski n
I also seem to recall that routeTemplates haven't all functionality from
Kamelets, and you can't call all routeTemplates exactly the same from the
Kamelet component, but maybe this is not a limitation anymore.

btw In my own runtime (Assimbly) I do load all Kamelets by default, so they
are straight to use.

Raymond

On Mon, Jan 8, 2024 at 4:24 PM ski n  wrote:

> Yeah, calling a Kamelet has the advantage that the subroute is dynamically
> created.
>
> - Still need the to, not a separate EIP.
> - Beginners would not search for "Kamelet", but function would be more
> common
> - You still need a from statement within the Kamelet
> - Kamelet is not really part of the route, but a separate (sub)route
>
> But yeah this comes close. Maybe just call it with
> function("template").parameters() or routeTemplate("").parameters()in
> the DSL would be enough for most.
>
> Raymond
>
>
>
>
>
>
> On Mon, Jan 8, 2024 at 4:00 PM Andrea Cosentino  wrote:
>
>> It really seems the Kamelets' mission
>>
>> Il lun 8 gen 2024, 15:59 Pasquale Congiusti > >
>> ha scritto:
>>
>> > Hi Raymond,
>> > Can't be a Kamelet considered for such a feature? I think it's one of
>> its
>> > purposes as well.
>> >
>> > Pasquale.
>> >
>> > On Mon, Jan 8, 2024 at 3:21 PM ski n  wrote:
>> >
>> > > Question/Discussion:
>> > >
>> > > Do you think "functions" in the Camel DSL make sense?
>> > >
>> > > Explanation:
>> > >
>> > > Say you have to following route:
>> > >
>> > > from("direct:a")
>> > > .setHeader("myHeader", constant("test"))
>> > > .to("direct:b");
>> > >
>> > > And then you have a similar route:
>> > >
>> > > from("direct:c")
>> > > .setHeader("myHeader2", constant("test"))
>> > > .to("direct:d");
>> > >
>> > > As you are setting it more or less the same you could make a
>> > routeTemplate:
>> > >
>> > > routeTemplate("someFunction")
>> > > // here we define the required input parameters (with a
>> > default
>> > > value)
>> > >  .templateParameter("headerName", "myHeader")
>> > > .from("direct:a")
>> > >  .setHeader("{{headerName}}", constant("test"))
>> > >
>> > > And then you can:
>> > >
>> > > from("direct:a")
>> > > .to("direct:someFunction")
>> > > .to("direct:b");
>> > >
>> > > And for the second route:
>> > >
>> > > from("direct:c")
>> > > .to("direct:someFunction")
>> > > .to("direct:d");
>> > >
>> > >
>> > > This however seems a bit cumbersome, because:
>> > >
>> > > 1. I must have a from statement in my subroute (which should be just a
>> > > function).
>> > > 2. I need to know the component of the from statement and call it
>> with a
>> > > "to" statement.
>> > > 3. I need to create the route from routeTemplates before the route
>> starts
>> > > and I need to do this everytime I use that 'function'.
>> > > 4. If I want to use the same code then I need to call the same route
>> > > multiple times,
>> > >but in certain cases this can become a bottle-neck (think of Seda
>> of
>> > JMS
>> > > Queues).
>> > >Especially when call it from hundreds of places, this maybe
>> > troublesome
>> > > (throughput or memory).
>> > >
>> > >
>> > > Would be easier and more direct to have like this:
>> > >
>> > > function("someFunction")
>> > > .parameter("headerName", "myHeader")
>> > > .setHeader("{{headerName}}", constant("test"))
>> > >
>> > > And then call it:
>> > >
>> > > from("direct:a")
>> > > .function("someFunction")
>> > > .to("direct:b");
>> > >
>> > > And:
>> > >
>> > > from("direct:c")
>> > > .function("someFunction")
>> > > .parameter("myHeader2")
>> > > .to("direct:d");
>> > >
>> > > On install the routes are exactly the same as the first and second
>> route
>> > > (only reused).
>> > >
>> > > What do think?
>> > >
>> > > Raymond
>> > >
>> >
>>
>


Re: Functions in Camel

2024-01-08 Thread ski n
Yeah, calling a Kamelet has the advantage that the subroute is dynamically
created.

- Still need the to, not a separate EIP.
- Beginners would not search for "Kamelet", but function would be more
common
- You still need a from statement within the Kamelet
- Kamelet is not really part of the route, but a separate (sub)route

But yeah this comes close. Maybe just call it with
function("template").parameters() or routeTemplate("").parameters()in
the DSL would be enough for most.

Raymond






On Mon, Jan 8, 2024 at 4:00 PM Andrea Cosentino  wrote:

> It really seems the Kamelets' mission
>
> Il lun 8 gen 2024, 15:59 Pasquale Congiusti 
> ha scritto:
>
> > Hi Raymond,
> > Can't be a Kamelet considered for such a feature? I think it's one of its
> > purposes as well.
> >
> > Pasquale.
> >
> > On Mon, Jan 8, 2024 at 3:21 PM ski n  wrote:
> >
> > > Question/Discussion:
> > >
> > > Do you think "functions" in the Camel DSL make sense?
> > >
> > > Explanation:
> > >
> > > Say you have to following route:
> > >
> > > from("direct:a")
> > > .setHeader("myHeader", constant("test"))
> > > .to("direct:b");
> > >
> > > And then you have a similar route:
> > >
> > > from("direct:c")
> > > .setHeader("myHeader2", constant("test"))
> > > .to("direct:d");
> > >
> > > As you are setting it more or less the same you could make a
> > routeTemplate:
> > >
> > > routeTemplate("someFunction")
> > > // here we define the required input parameters (with a
> > default
> > > value)
> > >  .templateParameter("headerName", "myHeader")
> > > .from("direct:a")
> > >  .setHeader("{{headerName}}", constant("test"))
> > >
> > > And then you can:
> > >
> > > from("direct:a")
> > > .to("direct:someFunction")
> > > .to("direct:b");
> > >
> > > And for the second route:
> > >
> > > from("direct:c")
> > > .to("direct:someFunction")
> > > .to("direct:d");
> > >
> > >
> > > This however seems a bit cumbersome, because:
> > >
> > > 1. I must have a from statement in my subroute (which should be just a
> > > function).
> > > 2. I need to know the component of the from statement and call it with
> a
> > > "to" statement.
> > > 3. I need to create the route from routeTemplates before the route
> starts
> > > and I need to do this everytime I use that 'function'.
> > > 4. If I want to use the same code then I need to call the same route
> > > multiple times,
> > >but in certain cases this can become a bottle-neck (think of Seda of
> > JMS
> > > Queues).
> > >Especially when call it from hundreds of places, this maybe
> > troublesome
> > > (throughput or memory).
> > >
> > >
> > > Would be easier and more direct to have like this:
> > >
> > > function("someFunction")
> > > .parameter("headerName", "myHeader")
> > > .setHeader("{{headerName}}", constant("test"))
> > >
> > > And then call it:
> > >
> > > from("direct:a")
> > > .function("someFunction")
> > > .to("direct:b");
> > >
> > > And:
> > >
> > > from("direct:c")
> > > .function("someFunction")
> > > .parameter("myHeader2")
> > > .to("direct:d");
> > >
> > > On install the routes are exactly the same as the first and second
> route
> > > (only reused).
> > >
> > > What do think?
> > >
> > > Raymond
> > >
> >
>


Re: Functions in Camel

2024-01-08 Thread Andrea Cosentino
It really seems the Kamelets' mission

Il lun 8 gen 2024, 15:59 Pasquale Congiusti 
ha scritto:

> Hi Raymond,
> Can't be a Kamelet considered for such a feature? I think it's one of its
> purposes as well.
>
> Pasquale.
>
> On Mon, Jan 8, 2024 at 3:21 PM ski n  wrote:
>
> > Question/Discussion:
> >
> > Do you think "functions" in the Camel DSL make sense?
> >
> > Explanation:
> >
> > Say you have to following route:
> >
> > from("direct:a")
> > .setHeader("myHeader", constant("test"))
> > .to("direct:b");
> >
> > And then you have a similar route:
> >
> > from("direct:c")
> > .setHeader("myHeader2", constant("test"))
> > .to("direct:d");
> >
> > As you are setting it more or less the same you could make a
> routeTemplate:
> >
> > routeTemplate("someFunction")
> > // here we define the required input parameters (with a
> default
> > value)
> >  .templateParameter("headerName", "myHeader")
> > .from("direct:a")
> >  .setHeader("{{headerName}}", constant("test"))
> >
> > And then you can:
> >
> > from("direct:a")
> > .to("direct:someFunction")
> > .to("direct:b");
> >
> > And for the second route:
> >
> > from("direct:c")
> > .to("direct:someFunction")
> > .to("direct:d");
> >
> >
> > This however seems a bit cumbersome, because:
> >
> > 1. I must have a from statement in my subroute (which should be just a
> > function).
> > 2. I need to know the component of the from statement and call it with a
> > "to" statement.
> > 3. I need to create the route from routeTemplates before the route starts
> > and I need to do this everytime I use that 'function'.
> > 4. If I want to use the same code then I need to call the same route
> > multiple times,
> >but in certain cases this can become a bottle-neck (think of Seda of
> JMS
> > Queues).
> >Especially when call it from hundreds of places, this maybe
> troublesome
> > (throughput or memory).
> >
> >
> > Would be easier and more direct to have like this:
> >
> > function("someFunction")
> > .parameter("headerName", "myHeader")
> > .setHeader("{{headerName}}", constant("test"))
> >
> > And then call it:
> >
> > from("direct:a")
> > .function("someFunction")
> > .to("direct:b");
> >
> > And:
> >
> > from("direct:c")
> > .function("someFunction")
> > .parameter("myHeader2")
> > .to("direct:d");
> >
> > On install the routes are exactly the same as the first and second route
> > (only reused).
> >
> > What do think?
> >
> > Raymond
> >
>


Re: Functions in Camel

2024-01-08 Thread Pasquale Congiusti
Hi Raymond,
Can't be a Kamelet considered for such a feature? I think it's one of its
purposes as well.

Pasquale.

On Mon, Jan 8, 2024 at 3:21 PM ski n  wrote:

> Question/Discussion:
>
> Do you think "functions" in the Camel DSL make sense?
>
> Explanation:
>
> Say you have to following route:
>
> from("direct:a")
> .setHeader("myHeader", constant("test"))
> .to("direct:b");
>
> And then you have a similar route:
>
> from("direct:c")
> .setHeader("myHeader2", constant("test"))
> .to("direct:d");
>
> As you are setting it more or less the same you could make a routeTemplate:
>
> routeTemplate("someFunction")
> // here we define the required input parameters (with a default
> value)
>  .templateParameter("headerName", "myHeader")
> .from("direct:a")
>  .setHeader("{{headerName}}", constant("test"))
>
> And then you can:
>
> from("direct:a")
> .to("direct:someFunction")
> .to("direct:b");
>
> And for the second route:
>
> from("direct:c")
> .to("direct:someFunction")
> .to("direct:d");
>
>
> This however seems a bit cumbersome, because:
>
> 1. I must have a from statement in my subroute (which should be just a
> function).
> 2. I need to know the component of the from statement and call it with a
> "to" statement.
> 3. I need to create the route from routeTemplates before the route starts
> and I need to do this everytime I use that 'function'.
> 4. If I want to use the same code then I need to call the same route
> multiple times,
>but in certain cases this can become a bottle-neck (think of Seda of JMS
> Queues).
>Especially when call it from hundreds of places, this maybe troublesome
> (throughput or memory).
>
>
> Would be easier and more direct to have like this:
>
> function("someFunction")
> .parameter("headerName", "myHeader")
> .setHeader("{{headerName}}", constant("test"))
>
> And then call it:
>
> from("direct:a")
> .function("someFunction")
> .to("direct:b");
>
> And:
>
> from("direct:c")
> .function("someFunction")
> .parameter("myHeader2")
> .to("direct:d");
>
> On install the routes are exactly the same as the first and second route
> (only reused).
>
> What do think?
>
> Raymond
>


Functions in Camel

2024-01-08 Thread ski n
Question/Discussion:

Do you think "functions" in the Camel DSL make sense?

Explanation:

Say you have to following route:

from("direct:a")
.setHeader("myHeader", constant("test"))
.to("direct:b");

And then you have a similar route:

from("direct:c")
.setHeader("myHeader2", constant("test"))
.to("direct:d");

As you are setting it more or less the same you could make a routeTemplate:

routeTemplate("someFunction")
// here we define the required input parameters (with a default
value)
 .templateParameter("headerName", "myHeader")
.from("direct:a")
 .setHeader("{{headerName}}", constant("test"))

And then you can:

from("direct:a")
.to("direct:someFunction")
.to("direct:b");

And for the second route:

from("direct:c")
.to("direct:someFunction")
.to("direct:d");


This however seems a bit cumbersome, because:

1. I must have a from statement in my subroute (which should be just a
function).
2. I need to know the component of the from statement and call it with a
"to" statement.
3. I need to create the route from routeTemplates before the route starts
and I need to do this everytime I use that 'function'.
4. If I want to use the same code then I need to call the same route
multiple times,
   but in certain cases this can become a bottle-neck (think of Seda of JMS
Queues).
   Especially when call it from hundreds of places, this maybe troublesome
(throughput or memory).


Would be easier and more direct to have like this:

function("someFunction")
.parameter("headerName", "myHeader")
.setHeader("{{headerName}}", constant("test"))

And then call it:

from("direct:a")
.function("someFunction")
.to("direct:b");

And:

from("direct:c")
.function("someFunction")
.parameter("myHeader2")
.to("direct:d");

On install the routes are exactly the same as the first and second route
(only reused).

What do think?

Raymond


Re: Camel JMS headers not updated by producer

2024-01-08 Thread Ephemeris Lappis
Hello.

If it's confirmed, it means that I can't retrieve the actual resulting
queue the message is sent to ?
I'd need to retrieve it in some event notifiers, out of the Camel
routes code, that spies all the exchanges, the same way I do for
generated files retrieving the header "CamelFileNameProduced".

Not any other way to identify the destination ?

Thanks for your help.

Regards.

Le dim. 7 janv. 2024 à 15:50, Jeremy Ross  a écrit :
>
> I think Camel only sets those headers when a JMS message is received.
>
> https://camel.apache.org/components/4.0.x/jms-component.html#_message_format_when_receiving
>
> On Thu, Jan 4, 2024 at 5:56 AM Ephemeris Lappis 
> wrote:
>
> > Hello.
> >
> > I've observed that some JMS headers are not updated after a message is
> > sent.
> >
> > For example, using this statement :
> >
> >   > uri="jms:{{my.queue.prefix}}.${headers.entity}.{{my.queue.suffix}}?connectionFactory=#myJMS"
> > /
> >
> > I expected to have the header "JMSDestination" set on the Camel
> > message with the destination, but instead of that I still have the
> > input JMS message's queue name.
> >
> > The same with the header "JMSMessageID" that seems not to be updated.
> >
> > Is it normal behavior of the JMS component ?
> >
> > I use Camel 3.21.3 and ActiveMQ 5.18.3.
> >
> > Thanks for your help.
> >