You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Yash Ganthe <ya...@gmail.com> on 2023/02/06 15:03:57 UTC
Easier Content-based dynamic routing
Hi,
I have a text file that looks like:
my data, 342342, Q1
my data2, 342342, Q2
my data3, 342342, Q1
....
I would like to read each line, read the third field and use it as the name
of the queue to which the first and second field are written.
E.g.
from("file://myfile.txt").to("jmsqueue:"+Line[2])
Is something like this possible with Camel?
-Yash
Re: Easier Content-based dynamic routing
Posted by Claus Ibsen <cl...@gmail.com>.
Look at simple language with toD, or use a java bean method to calculate
the uri with recipient list (its also dynamic)
On Tue, Feb 7, 2023 at 6:14 AM Yash Ganthe <ya...@gmail.com> wrote:
> Hi,
>
> The toD will help in setting the destination. How do we get the value of
> the destination from the records?
> I looked at
> https://camel.apache.org/components/3.20.x/dataformats/csv-dataformat.html
>
> The unmarshall does give out a List<List<String>>. How can we use the 3rd
> field in the toD ?
> E.g. Can we do something like this?
> from("file://rider/csvfiles")
> .unmarshal().csv()
> .split(body()).toD("jms:queue:csv.record[2]");
>
> -Yash
>
> On Mon, 6 Feb 2023 at 20:41, Claus Ibsen <cl...@gmail.com> wrote:
>
> > Hi
> >
> > Yes, look at toD which is a dynamic "to".
> >
> >
> > On Mon, Feb 6, 2023 at 4:04 PM Yash Ganthe <ya...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > I have a text file that looks like:
> > > my data, 342342, Q1
> > > my data2, 342342, Q2
> > > my data3, 342342, Q1
> > > ....
> > >
> > > I would like to read each line, read the third field and use it as the
> > name
> > > of the queue to which the first and second field are written.
> > > E.g.
> > > from("file://myfile.txt").to("jmsqueue:"+Line[2])
> > >
> > > Is something like this possible with Camel?
> > >
> > > -Yash
> > >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>
--
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: Easier Content-based dynamic routing
Posted by Yash Ganthe <ya...@gmail.com>.
Hi,
The toD will help in setting the destination. How do we get the value of
the destination from the records?
I looked at
https://camel.apache.org/components/3.20.x/dataformats/csv-dataformat.html
The unmarshall does give out a List<List<String>>. How can we use the 3rd
field in the toD ?
E.g. Can we do something like this?
from("file://rider/csvfiles")
.unmarshal().csv()
.split(body()).toD("jms:queue:csv.record[2]");
-Yash
On Mon, 6 Feb 2023 at 20:41, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Yes, look at toD which is a dynamic "to".
>
>
> On Mon, Feb 6, 2023 at 4:04 PM Yash Ganthe <ya...@gmail.com> wrote:
>
> > Hi,
> >
> > I have a text file that looks like:
> > my data, 342342, Q1
> > my data2, 342342, Q2
> > my data3, 342342, Q1
> > ....
> >
> > I would like to read each line, read the third field and use it as the
> name
> > of the queue to which the first and second field are written.
> > E.g.
> > from("file://myfile.txt").to("jmsqueue:"+Line[2])
> >
> > Is something like this possible with Camel?
> >
> > -Yash
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
Re: Easier Content-based dynamic routing
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Yes, look at toD which is a dynamic "to".
On Mon, Feb 6, 2023 at 4:04 PM Yash Ganthe <ya...@gmail.com> wrote:
> Hi,
>
> I have a text file that looks like:
> my data, 342342, Q1
> my data2, 342342, Q2
> my data3, 342342, Q1
> ....
>
> I would like to read each line, read the third field and use it as the name
> of the queue to which the first and second field are written.
> E.g.
> from("file://myfile.txt").to("jmsqueue:"+Line[2])
>
> Is something like this possible with Camel?
>
> -Yash
>
--
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2