0

picturised.. I know that it is possible to call routes from from different RouteContext xml,

How do I achieve it in hybrid manner, for an instance..

        <route id=A>
        <from uri="direct:A"/>
        <to uri="bean:someprocess....."/>
        <to uri="direct:endp_inside_routeBuilder"/>

        <route id=B>
        <from uri="direct:A"/>
        <to uri="bean:routeBuilder?method=routeBuilderMethod"/>
        <to uri="mock:endp"/>

is it possible to route to the consumer inside the bean...!

or is it possible to import the routeContext/route configured in Spring into the JavaDSL ?..

peaceUser
  • 457
  • 5
  • 19
  • I am not 100% sure what you are trying to ask. Yes You can write a route in either JavaDSL or XML. You can also create new routes at runtime and add them to a context. I do not understand what you mean by "route to the consumer inside the bean" or a "Hybrid manner". If you mean you want to have a Spring DSL route call a JavaDSL route they are the same thing at runtime. you could simply have one route send: to("direct:otherRoute") and another route read: from("direct:otherRoute") – Matthew Fontana May 18 '16 at 12:36
  • not possible to call the "direct" component , since its synchronous, where as I don't want to use the seda/vm, which will hamper the transaction..! – peaceUser May 19 '16 at 14:46
  • Your question is still quite unclear. You want to maintain a transaction over a route that is asynchronous? In order to do something like that you need to a have a single transactional flow. You could push your message to something like ActiveMQ and then read from ActiveMQ from a different route. This will support transactions over each individual message – Matthew Fontana May 19 '16 at 14:52
  • let me try the messaging components and update.. :) – peaceUser May 19 '16 at 15:08
  • for ActiveMQ you will either need to run that product in standalone or an embedded mode. – Matthew Fontana May 19 '16 at 15:21
  • sorry Matthew, its not working.., have you got a chance to try with direct component? – peaceUser May 20 '16 at 14:20
  • Would you be able to update your question with a sample use case? It looks like you're trying to parallelize a transaction's work over two routes or so. Can you break it down a bit cleaner? – Matthew Fontana May 21 '16 at 00:54
  • Matthew, I have embedded a picture, take a look into it.. – peaceUser May 21 '16 at 10:31
  • Based on your picture it looks like all you need to know how to do is add a route to a context am I correct? If so here is an existing post that shows how: http://stackoverflow.com/questions/10451444/add-camel-route-at-runtime-in-java – Matthew Fontana May 22 '16 at 10:55
  • This works, but only for a single request, if we request again to the consumer, it will throw, Failed to start route route2 because of Multiple consumers for the same endpoint is not allowed: Endpoint[direct://newEndp], in this case, one more problem, is every time the request is made, it will create new Endpoint for the producer. Which can be an huge impact for performance, if bulk of requests arrives.. – peaceUser May 23 '16 at 06:08
  • Yes You can't fire up multiple consumers from a direct endpoint. You could switch it to a seda endpoint if that was the desired behavior. Yes the endpoint creation can be expensive. Are you just trying to have part of a route be parallel processing? – Matthew Fontana May 23 '16 at 11:07
  • is there any way to initialize an endpoint only once, for each request, it should not create individual endpoints.. – peaceUser Jun 07 '16 at 15:01
  • By default every route is only initialized once. If you want a single execution path you can leverage a Queue based pattern and then support transactions from the queue as well as support parallelism – Matthew Fontana Jun 07 '16 at 15:35
  • if you try to use toD, for each request, the endpoint is created the request number of times. – peaceUser Jun 08 '16 at 07:46
  • You can use a direct with multiple consumers if you use a queue. You can use activemq, rabbitmq, webspheremq, any kind of queue platform. I recommend activemq for this case since you can embed it into a service mix container with your came route and just use a vm transport. This will let you still maintain transactions from the queue and have parallelism – Matthew Fontana Jun 08 '16 at 10:41

0 Answers0