How to fix several input per route in Camel 3.X.X?

1k Views Asked by At

I have a route that looks like this:

from(URL_A)
  .from(URL_B)
  .to(URL_C)
  .process(...)
  // logging
  .to(URL_D)

This route works perfectly in Camel 2.X.X but not in 3.7.X

The error message I get:

Only one input is allowed per route. Cannot accept input: From[direct:ABCD]

I checked the migration guide, but I cannot get how to migrate this sort of route.

Do you have any idea how to tackle it further?

2

There are 2 best solutions below

0
On BEST ANSWER

I think you can use direct component: https://camel.apache.org/components/3.4.x/direct-component.html

For example:

from(URL_A)
  .to(direct:collector)
from(URL_B)
  .to(direct:collector)
  
from(direct:collector)
  .to(URL_C)
  .process(...)
  // logging
  .to(URL_D)
1
On

@Stepan Shcherbakov suggested a solution, below will be an enhancement of it:

String [] sources = {URL_A, URL_B}
for (String source : sources) {
  from(source)
    .to(direct:collector)
}

from(direct:collector)
  .to(URL_C)
  .process(...)
  // logging
  .to(URL_D)