Pregunta

I'm writing a message listener that needs to accept messages from a named Queue. Using spring-amqp, I'm wondering if it's possible to configure this listener such that consumption of messages via a queue will happen regardless of what its backing exchange type is.

For example:

<rabbit:admin id="amqpAdmin" connection-factory="reconciliationAmqpConnectionFactory"/>

<rabbit:queue id="queue" name="exampleQueue" />

This will bind this example queue to a direct exchange, but what if the consumer should bind the queue to either a direct, fanout, headers, or topic exchange? Essentially, I'm wondering if there is a way to decouple the consuming listener's queue binding from having to know the exact type of its backing exchange at runtime.

¿Fue útil?

Solución

I don't think I understand the question.

There's no such thing as a "backing exchange".

Consumers consume from queues; they have no idea what the upstream exchange is or how the queue is bound. Yes, there is a default direct exchange that queues get bound to by name, but that's just for convenience; it is unusual to use that in production.

You create exchanges, queues, bindings and consumers consume from queues; producers send to exchanges.

Perhaps your confusion is because most examples show all the configuration in a single place.

You can build whatever upstream infrastructure you want but the key is that consumers consume from queues.

Take a look at the Spring Integration sample for some config examples.

See the stocks sample for some Java config examples.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top