FAQ
Hello,

We have a requirement wherein we need to do some database operations
(inserts/updates) immedialtely after the first and last routes are executed.

We would be writing two custom interceptors - one for the insert operation
after the first route is executed , and the other for the update operation
once the last route is executed.

We wanted to know if there is a way/method to know when the first route in
camel has been executed. Likewise is there a way to find out the last route
executed and then trigger the interceptor for updating the data in the
database.

As always, appreciate your help.

Thanks and Regards,
Bhavani



--
View this message in context: http://camel.465427.n5.nabble.com/Custom-interceptors-and-finding-the-first-and-last-camel-route-tp5726148.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Search Discussions

  • Lleclerc at Jan 26, 2013 at 5:36 am
    I don`t understand what you are asking.

    Usually you can just add a ".to(somethingElse)" at the end of your route. Or
    you can add some http://camel.apache.org/predicate.html to check if your
    request was succesful first.

    If your 2 routes should be in sync, why aren`t they on the same route ?
    Else you might try to use http://camel.apache.org/aggregator2.html and you
    will need to make sure it`s 2 matching messages and maybe skip some if only
    1 of your 2 routes success.



    --
    View this message in context: http://camel.465427.n5.nabble.com/Custom-interceptors-and-finding-the-first-and-last-camel-route-tp5726148p5726312.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Claus Ibsen at Jan 26, 2013 at 10:21 am

    On Thu, Jan 24, 2013 at 12:10 PM, BAnanth wrote:
    Hello,

    We have a requirement wherein we need to do some database operations
    (inserts/updates) immedialtely after the first and last routes are executed.

    We would be writing two custom interceptors - one for the insert operation
    after the first route is executed , and the other for the update operation
    once the last route is executed.
    What is the first route and the last route? Do you mean the 1st route
    a given Exchange starts with,
    and the last route the same Exchange ended at?
    We wanted to know if there is a way/method to know when the first route in
    camel has been executed. Likewise is there a way to find out the last route
    executed and then trigger the interceptor for updating the data in the
    database.
    There is also the tracer
    http://camel.apache.org/tracer

    And the event notifier api. We dont have to much docs about this but a
    little bit here
    http://camel.apache.org/eventnotifier-to-log-details-about-all-sent-exchanges.html




    As always, appreciate your help.

    Thanks and Regards,
    Bhavani



    --
    View this message in context: http://camel.465427.n5.nabble.com/Custom-interceptors-and-finding-the-first-and-last-camel-route-tp5726148.html
    Sent from the Camel - Users mailing list archive at Nabble.com.


    --
    Claus Ibsen
    -----------------
    Red Hat, Inc.
    FuseSource is now part of Red Hat
    Email: cibsen@redhat.com
    Web: http://fusesource.com
    Twitter: davsclaus
    Blog: http://davsclaus.com
    Author of Camel in Action: http://www.manning.com/ibsen
  • BAnanth at Feb 1, 2013 at 10:39 am
    Thanks everyone for your reply.

    I meant the first and last route within a given context.

    eg

    <context>

    <r1>
    from and to stmts
    <r2>
    from ...to
    <r3>
    from...to
    </context>

    We need to make an entry to the databas immediately after the first route
    (r1) "from-to" is executed in the first route. this is needed to persisit
    the original message and other details. (we are using tracer for this)


    The second requirement is to make an entry immeditely after the last route
    is executed (last from-to).
    We were planning to use OnCompleteion here. But the solution has to be
    generic , in the sense it should be able to trigger onCompletion
    irrespective of whether the user specifies onCompletion in his code. (the
    user could give the route id in a properties file and our program should be
    able to implement the onCOmpletion if the given route matches the route id
    in the properties file.)



    Thanks and Regards,
    bhavani





    --
    View this message in context: http://camel.465427.n5.nabble.com/Custom-interceptors-and-finding-the-first-and-last-camel-route-tp5726148p5726727.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Christian Müller at Jan 27, 2013 at 12:37 pm
    Please find my comments inline.

    Best,
    Christian
    On Thu, Jan 24, 2013 at 12:10 PM, BAnanth wrote:

    Hello,

    We have a requirement wherein we need to do some database operations
    (inserts/updates) immedialtely after the first and last routes are
    executed.
    What do you mean?
    After each exchanges was processed by the first endpoint on a route and
    after each exchange was processed by the last endpoint on a route?
    Or only for the first exchange?
    Or...?

    We would be writing two custom interceptors - one for the insert operation
    after the first route is executed , and the other for the update operation
    once the last route is executed.
    In org.apache.camel.processor.interceptor.DefaultTraceEventMessage you can
    check how to figure out what is/was the fromEndpoint, previousNode and
    nextNode. I think with this information you can determine in your
    interceptor whether it should do something or not.
    We wanted to know if there is a way/method to know when the first route in
    camel has been executed. Likewise is there a way to find out the last route
    executed and then trigger the interceptor for updating the data in the
    database.
    See above. May the nextNode is null if you passed the last endpoint. And
    fromEndpoint and previousNode may have the same values when you pased the
    first endpoint.
    As always, appreciate your help.

    Thanks and Regards,
    Bhavani



    --
    View this message in context:
    http://camel.465427.n5.nabble.com/Custom-interceptors-and-finding-the-first-and-last-camel-route-tp5726148.html
    Sent from the Camel - Users mailing list archive at Nabble.com.


    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedJan 24, '13 at 11:10a
activeFeb 1, '13 at 10:39a
posts5
users4
websitecamel.apache.org

People

Translate

site design / logo © 2022 Grokbase