Camel
  1. Camel
  2. CAMEL-3539

Add route endpoint to let end users send messages to other routes using route scheme naming

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 3.0.0
    • Component/s: camel-core
    • Labels:
      None

      Description

      For example

      ...
      <to uri="route:sendMail"/>
      ...
      

      And then we can have a route for that

      <route>
         <from uri="route:sendMail"/>
         ...
      </route>
      

      In reality its just like a direct: endpoint but using route as scheme name. And in this case the id of the route will use the name from the uri, so it will name the route sendMail. Then you dont need to assign an explicit id.

      Now suppose the sendMail route also have another source input such as from a jms queue

      <route id="sendMail>
         <from uri="jms:queue:mail.out"/>
         ...
      </route>
      

      This route is now having the id sendMail which you can send message to using the scheme route:sendMail.
      But the route also consumes messages from a JMS queue.

        Activity

        Hide
        Claus Ibsen added a comment -

        IMHO it should be based on the routeId and not endpoint uri.

        To keep it simple we can do

        <route id="sendMail>
           <from uri="seda:mail"/>
           ...
        </route>
        

        And then you can send a message to the route

        template.sendBodyAndHeader("route:sendMail", "Hello this is a mail to send", "to", "someone@somewhere.com");
        

        The trick is how to send the message to the route, either using a "hidden" direct component. Or some other means of sending the message to the route.

        Lets revisit this when we have improved the routing engine to be more dynamic. Then we got better hooks for that
        http://camel.apache.org/camel-30-roadmap.html

        Show
        Claus Ibsen added a comment - IMHO it should be based on the routeId and not endpoint uri. To keep it simple we can do <route id="sendMail> <from uri= "seda:mail" /> ... </route> And then you can send a message to the route template.sendBodyAndHeader( "route:sendMail" , "Hello this is a mail to send" , "to" , "someone@somewhere.com" ); The trick is how to send the message to the route, either using a "hidden" direct component. Or some other means of sending the message to the route. Lets revisit this when we have improved the routing engine to be more dynamic. Then we got better hooks for that http://camel.apache.org/camel-30-roadmap.html
        Hide
        Ben O'Day added a comment -

        please review

        Show
        Ben O'Day added a comment - please review
        Hide
        Ben O'Day added a comment -

        I originally created Route component classes that extended the Direct component with the hopes of simply overriding APIs to support this use case. Instead though, I ended up needing to modify the CamelContext's getEndpoint() method (to avoid more invasive framework changes). So, I minimized the Route component to just using the Direct component classes directly. Either way, if this is not an acceptable approach, I'll rework it...thanks

        Show
        Ben O'Day added a comment - I originally created Route component classes that extended the Direct component with the hopes of simply overriding APIs to support this use case. Instead though, I ended up needing to modify the CamelContext's getEndpoint() method (to avoid more invasive framework changes). So, I minimized the Route component to just using the Direct component classes directly. Either way, if this is not an acceptable approach, I'll rework it...thanks
        Hide
        Claus Ibsen added a comment -

        Thanks Ben we will look at it in a bit later. It complicates things a bit by having a "direct" under the covers to be able to send a message to that route. We may need a better way to do that under the covers.

        Show
        Claus Ibsen added a comment - Thanks Ben we will look at it in a bit later. It complicates things a bit by having a "direct" under the covers to be able to send a message to that route. We may need a better way to do that under the covers.
        Hide
        Ben O'Day added a comment -

        here is an initial patch attempt which does the following...

        -add new route component (as alias of direct)
        -enhance context.getEndpoint() to also find by routeId when "route" scheme is used
        -default the routeId for route components
        -add route component test case
        -add spring route component test case

        its a bit rough in areas...I'm hoping some feedback will help tighten it up...thanks

        Show
        Ben O'Day added a comment - here is an initial patch attempt which does the following... -add new route component (as alias of direct) -enhance context.getEndpoint() to also find by routeId when "route" scheme is used -default the routeId for route components -add route component test case -add spring route component test case its a bit rough in areas...I'm hoping some feedback will help tighten it up...thanks
        Hide
        Ben O'Day added a comment -

        This seems to overlap with new context/routebox components...is it still a desired feature?

        Show
        Ben O'Day added a comment - This seems to overlap with new context/routebox components...is it still a desired feature?

          People

          • Assignee:
            Unassigned
            Reporter:
            Claus Ibsen
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development