0

From my spring-boot service(with camel) I need to connect to two RabbitMQ instances;not cluster, but altogether different instances(with diff IP, vhost and credentials)

Versions: spring-boot: 1.5.12 and camel: 2.21.5

I want to create multiple connection factories and specify them in the camel endpoint name like this. rabbitmq:exchange1?connectionFactory=#customFactory1
rabbitmq:exchange2?connectionFactory=#customFactory2

Currently this is not supported as RabbitAnnotationDrivenConfiguration class expects only one instance of ConnectionFactory

Even if I qualify the ConnectionFactory Beans with @Qualifier/@Primary the connectionFactory query param used in camel endpoint is ignored (or) properties from camel.component.rabbitmq are taking priority

I'm now using a workaround to specify all the connection properties in the endpoint name like rabbitmq:exchange1?host=<host>&vhost=<vhost>&username=something&password=something

Is there a better way to achieve this...?

Sai Surya Kattamuri
  • 1,046
  • 12
  • 22
  • check this out .. https://stackoverflow.com/questions/28520784/rabbitmq-rpc-across-multiple-rabbitmq-instances – Lalit Mehra Jul 23 '19 at 09:12
  • These customFactory1 and customFactory2, Are they autowired instances? – Sunand Padmanabhan Jul 23 '19 at 19:59
  • @SunandPadmanabhan Yes, they are, Camel expects connectionFactory as spring bean – Sai Surya Kattamuri Jul 24 '19 at 03:46
  • @LalitMehra I've seen that already, but that solution works well with spring-amqp and RabbitTemplate, but in my case I'll just specify the endpoint name, camel(camel-rabbitmq-starter is the library) chooses the connectionFactory, so when I tried, it couldn't resolve the conflict btw two connFactories – Sai Surya Kattamuri Jul 24 '19 at 04:25

0 Answers0