0
votes

I'm trying to add Spring Cloud Stream to the existing project that uses Spring AMQP with RabbitMQ.

I have the following rabbit configuration:

Producer exchange name: producer.mail-sent.exchange

Consumer queue name: consumer.mail-sent.queue

On the producer's side I configure like this: spring: cloud: stream: bindings: output: contentType: application/json destination: producer.mail-sent.exchange

And using the following code:

@Autowired
private Source source;
...
source.output().send(MessageBuilder.withPayload(someStuff).build());
...

On the consumer's side I have the following config: spring: cloud: stream: bindings: input: contentType: application/json destination: producer.mail-sent.exchange group: consumer.mail-sent.queue

With the following code:

@EnableBinding(Sink.class)
...
@StreamListener(Sink.INPUT)
public void handle(String someStuff) {
    log.info("some stuff is received: " + someStuff);
}

And it seems that it works. :) But! On the rabbit's side I have a new queue named producer.mail-sent.exchange.consumer.mail-sent.queue, but I want it to use the existing queue named consumer.mail-sent.queue.

Is there any way to achieve this?

1

1 Answers

1
votes

It's not currently supported; while many properties are configurable (routing key etc), the queue name is always <destination>.<group>.

If you want to consume from an existing application, consider using a @RabbitListner instead of a @StreamListener.

Feel free to open a GitHub Issue referencing this post - many other "opinionated" configuration settings (such as routing key) are configurable, but not the queue name itself. Perhaps we could add a boolean includeDestInQueueName. Reference this question in the issue.