0

I have a flow that I've defined using camel but I ended up using 6+ routes to accomplish what I wanted. Is there a way to do this with one or fewer than 4 routes?

I've outlined the routes below. The first one reads a message (containing an ID) from MQ1 and produces N-messages (expected to be in thousands) in MQ2 based on what it finds in a database for that one ID (db is not shown here). The messages produced in MQ2 have a type field defined, and based on that the choice element filters the messages to put them in the right MQ. Then each MQ(3,4,5) is processed by it's own processor (ProcessorMQ3,4,5). Once that's done, they output the result of the processing to MQ6 and ProcessorMQ6 reads the result and updates the database (also not shown).

Route 1: [Start]--->[MQ1]--->[ProcessorMQ1]--->[MQ2]

Route 2: [MQ2]--->[Choice]--->[MQ3,MQ4,MQ5 based on header value]

Route 3: [MQ3]--->[ProcessorMQ3]--->[MQ6]

Route 4: [MQ4]--->[ProcessorMQ4]--->[MQ6]

Route 5: [MQ5]--->[ProcessorMQ5]--->[MQ6]

Route 6: [MQ6]--->[ProcessorMQ6]--->[End]

Is there a way to do this using one route or am I doing this correctly? I will need to introduce 10 more "types" so the range MQ3-5 will increase by 10.

7
  • This looks fine, no problem. Depending on error/tx handling semantics and performance requirements you could replace MQ3-5 with direct, but in general sending it off to a queue is better.
    – raphaëλ
    Jul 20, 2016 at 8:43
  • What does direct do? How would it be used if I were to replace MQ3-5 with direct? Is it like an endpoint that I can share between routes?
    – McJagger
    Jul 20, 2016 at 12:11
  • Yes. It is a synchronous call (using the same thread) to another route in the same CamelContext. It really depends on your requirements if that is better here (normally it is not)
    – raphaëλ
    Jul 20, 2016 at 12:24
  • There's a question of whether you CAN make it one route and whether you SHOULD. It sounds like you don't think you can, Why? Could you explain that. For instance, putting the [Choice] after ProcessorMQ1, and routing to ProcessorMQ3, 4, 5... etc. Once you know that you can, you can evaluate the pros and cons between the two options: single or multiple.
    – Darius X.
    Jul 20, 2016 at 12:58
  • You are correct, there are two questions here; Can I merge these routes and should I merge these routes. I don't know the answer to either of those questions.
    – McJagger
    Jul 20, 2016 at 15:24

1 Answer 1

1

As far as I can see, your route design looks better now. Why do you want to minimise ? It will complicate your exception handling at the least.

I would always prefer to create micro routes which are functionally independent to each other, that way its makes life easier to write exception handling & unit test cases in a better way. (Even it is very good for refactoring, in the future if you want to move these routes to its own unit of deployment)

Yes, you are doing it in a correct way !

Cheers

2
  • The team lead says that I should be able to do it with one route but then he said to get the first few integration routes going however I wanted so we can refactor later. Having this as a single route would be easier to manage I guess, but I don't think it's possible.
    – McJagger
    Jul 20, 2016 at 12:10
  • Yeah, not a bad approach . Also it's not going to be tough to have your kind of design straight away. Anyways it depends on any other challenges you have :) Good luck
    – gnanagurus
    Jul 20, 2016 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.