You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by spurcell <sc...@mastercard.com> on 2016/11/30 14:25:54 UTC

Route to two paths

In a project I am working on, I am parsing a large excel file, and during the
routing, I am performing some validation on the data. I have a route that
performs the validation, and if validation is good, I want to continue down
the same routes that exist. But if the data is invalid, I want to pass it to
a different route to process and handle database writes there.

I have went through all the EIP patterns, but do not see one that performs
what I call a sift, where the good ones go down one path and the bad ones go
down a different path.

Can someone assist with possible work arounds for this?

Thanks
Scott



--
View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route to two paths

Posted by Steve Huston <sh...@riverace.com>.
You could have a bean or processor check the data and set the next route in a header. Then use .toD after the bean/processor to send to the proper next step. 

Steve Huston
(sent from my iPhone - please excuse brevity and typos)

> On Nov 30, 2016, at 9:27 AM, spurcell <sc...@mastercard.com> wrote:
> 
> In a project I am working on, I am parsing a large excel file, and during the
> routing, I am performing some validation on the data. I have a route that
> performs the validation, and if validation is good, I want to continue down
> the same routes that exist. But if the data is invalid, I want to pass it to
> a different route to process and handle database writes there.
> 
> I have went through all the EIP patterns, but do not see one that performs
> what I call a sift, where the good ones go down one path and the bad ones go
> down a different path.
> 
> Can someone assist with possible work arounds for this?
> 
> Thanks
> Scott
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route to two paths

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,

> Am 30.11.2016 um 15:25 schrieb spurcell <sc...@mastercard.com>:
> 
> In a project I am working on, I am parsing a large excel file, and during the
> routing, I am performing some validation on the data. I have a route that
> performs the validation, and if validation is good, I want to continue down
> the same routes that exist. But if the data is invalid, I want to pass it to
> a different route to process and handle database writes there.
> 
> I have went through all the EIP patterns, but do not see one that performs
> what I call a sift, where the good ones go down one path and the bad ones go
> down a different path.

what about using a content bases router

http://camel.apache.org/content-based-router.html
http://camel.apache.org/why-can-i-not-use-when-or-otherwise-in-a-java-camel-route.html

Also take a look at the simple language for access to header and content information

http://camel.apache.org/simple.html

BR
Maruan

> 
> Can someone assist with possible work arounds for this?
> 
> Thanks
> Scott
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Route to two paths

Posted by souciance <so...@gmail.com>.
Set appropriate headers using .header("type",constant("good/bad"))
Then use the conditional operators to route accordingly..Something like.
.choice().when(header("type").isequalto("good")).to("direct:good").otherwise().to("direct:bad").end();

On Wed, Nov 30, 2016 at 3:30 PM, Claus Ibsen-2 [via Camel] <
ml-node+s465427n5790804h87@n5.nabble.com> wrote:

> There is the content based router pattern
>
> On Wed, Nov 30, 2016 at 3:25 PM, spurcell <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5790804&i=0>> wrote:
>
> > In a project I am working on, I am parsing a large excel file, and
> during the
> > routing, I am performing some validation on the data. I have a route
> that
> > performs the validation, and if validation is good, I want to continue
> down
> > the same routes that exist. But if the data is invalid, I want to pass
> it to
> > a different route to process and handle database writes there.
> >
> > I have went through all the EIP patterns, but do not see one that
> performs
> > what I call a sift, where the good ones go down one path and the bad
> ones go
> > down a different path.
> >
> > Can someone assist with possible work arounds for this?
> >
> > Thanks
> > Scott
> >
> >
> >
> > --
> > View this message in context: http://camel.465427.n5.nabble.
> com/Route-to-two-paths-tp5790803.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Route-to-two-paths-
> tp5790803p5790804.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803p5790806.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route to two paths

Posted by souciance <so...@gmail.com>.
Ok I would like at generate a new message containing the good ones and a a
message for the bad ones. You can see here for how to generate a new
message.
http://camel.apache.org/how-do-i-write-a-custom-processor-which-sends-multiple-messages.html

Essentially you would have to create a list of good objects and set the
exchange body to that list and route it depending on the good or bad. You
can set the destination in a header. Then in the next step have the
.toD(<someheader>).

On Wed, Nov 30, 2016 at 7:31 PM, spurcell [via Camel] <
ml-node+s465427n5790831h24@n5.nabble.com> wrote:

> Tried coding a dynamicRouter, but not understanding how to set the
> exchange for each different route.
>
> Let me step back.
> I have a list of Objects some good, some bad in my current exchange. So
> body would be akin to the following:
> A-GOOD
> B-GOOD
> C-GOOD
> ...
> F-BAD
> H-BAD
> I-BAD
> ...
>
> I want to take the good, create a new exchange, take the bad and create
> another exchange and route the good and bad to different routes.
>
> I do not want to use a splitter and have to reaggregate, and was hoping
> there was a workaround for this scenario.
>
> Googling has not found anything that would work. Dynamic routing
> documentation is a bit confusing, and I don't know how to create 2
> exchanges with it.
>
>
>
> Thanks,
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Route-to-two-paths-
> tp5790803p5790831.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803p5790835.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route to two paths

Posted by spurcell <sc...@mastercard.com>.
Tried coding a dynamicRouter, but not understanding how to set the exchange
for each different route.

Let me step back.
I have a list of Objects some good, some bad in my current exchange. So body
would be akin to the following:
A-GOOD
B-GOOD
C-GOOD
...
F-BAD
H-BAD
I-BAD
...

I want to take the good, create a new exchange, take the bad and create
another exchange and route the good and bad to different routes.

I do not want to use a splitter and have to reaggregate, and was hoping
there was a workaround for this scenario.

Googling has not found anything that would work. Dynamic routing
documentation is a bit confusing, and I don't know how to create 2 exchanges
with it.



Thanks,




--
View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803p5790831.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route to two paths

Posted by Claus Ibsen <cl...@gmail.com>.
There is also eips like routing slip and dynamic router.

On Wed, Nov 30, 2016 at 4:12 PM, spurcell <sc...@mastercard.com> wrote:
> Our team is trying to avoid doing another split, choice aggregate due to
> performance. In my current route, I can create a "good" list and a "bad"
> list, so basically the tech lead wants me to take the elements from the good
> list, send them to a specific route, and take the bad list and send them to
> a different route. Basically doing more of a "custom" split, or something
> more along that line.
>
> Thanks,
> Scott
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803p5790822.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Route to two paths

Posted by souciance <so...@gmail.com>.
I guess in that case you need to set the destination upon extracting the
list in a header and use the .toD() to do dynamic routing.

On Wed, Nov 30, 2016 at 4:12 PM, spurcell [via Camel] <
ml-node+s465427n5790822h45@n5.nabble.com> wrote:

> Our team is trying to avoid doing another split, choice aggregate due to
> performance. In my current route, I can create a "good" list and a "bad"
> list, so basically the tech lead wants me to take the elements from the
> good list, send them to a specific route, and take the bad list and send
> them to a different route. Basically doing more of a "custom" split, or
> something more along that line.
>
> Thanks,
> Scott
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Route-to-two-paths-
> tp5790803p5790822.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803p5790823.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route to two paths

Posted by spurcell <sc...@mastercard.com>.
Our team is trying to avoid doing another split, choice aggregate due to
performance. In my current route, I can create a "good" list and a "bad"
list, so basically the tech lead wants me to take the elements from the good
list, send them to a specific route, and take the bad list and send them to
a different route. Basically doing more of a "custom" split, or something
more along that line.

Thanks,
Scott



--
View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803p5790822.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route to two paths

Posted by Claus Ibsen <cl...@gmail.com>.
There is the content based router pattern

On Wed, Nov 30, 2016 at 3:25 PM, spurcell <sc...@mastercard.com> wrote:
> In a project I am working on, I am parsing a large excel file, and during the
> routing, I am performing some validation on the data. I have a route that
> performs the validation, and if validation is good, I want to continue down
> the same routes that exist. But if the data is invalid, I want to pass it to
> a different route to process and handle database writes there.
>
> I have went through all the EIP patterns, but do not see one that performs
> what I call a sift, where the good ones go down one path and the bad ones go
> down a different path.
>
> Can someone assist with possible work arounds for this?
>
> Thanks
> Scott
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Route to two paths

Posted by souciance <so...@gmail.com>.
Hello,

Set appropriate headers using .header("type",constant("good/bad"))
Then use the conditional operators to route accordingly..Something like.
.choice().when(header("type").isequalto("good")).to("direct:
good").otherwise().to("direct:bad").end();

Best
Souciance

On Wed, Nov 30, 2016 at 3:25 PM, spurcell [via Camel] <
ml-node+s465427n5790803h56@n5.nabble.com> wrote:

> In a project I am working on, I am parsing a large excel file, and during
> the routing, I am performing some validation on the data. I have a route
> that performs the validation, and if validation is good, I want to continue
> down the same routes that exist. But if the data is invalid, I want to pass
> it to a different route to process and handle database writes there.
>
> I have went through all the EIP patterns, but do not see one that performs
> what I call a sift, where the good ones go down one path and the bad ones
> go down a different path.
>
> Can someone assist with possible work arounds for this?
>
> Thanks
> Scott
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Route-to-two-paths-tp5790803p5790807.html
Sent from the Camel - Users mailing list archive at Nabble.com.