简体   繁体   中英

Bind an alternate exchange to an exchange using spring-cloud-stream

I'm looking a way to declare an alternate exchange upon a exchange using spring-cloud-stream. We use 3.2.2 and this fonctionnality does not exist.

It would be used in case the producer send its first messages before the receiver creates its queue. The producer must declare an alternate-exchange on the exchange and a queue associated to the exchange to retrieve messages that has not been routed to an existing queue.

There is tons of applications related to alternate-exchange that looks not address by the spring cloud stream lib right now. https://www.rabbitmq.com/ae.html

Thanks

I think this has nothing to do with Spring Cloud Stream.

According that RabbitMQ docs, we just can do on the client side:

Map<String, Object> args = new HashMap<String, Object>();
args.put("alternate-exchange", "my-ae");
channel.exchangeDeclare("my-direct", "direct", false, false, args);
channel.exchangeDeclare("my-ae", "fanout");
channel.queueDeclare("routed");
channel.queueBind("routed", "my-direct", "key1");
channel.queueDeclare("unrouted");
channel.queueBind("unrouted", "my-ae", "");

So, technically you just declare respective beans according Spring AMQP API: https://docs.spring.io/spring-amqp/docs/current/reference/html/#broker-configuration

Or as that docs points out: use policies on the broker to modify an exchange for this alternate-exchange feature.

If you still see a value in some high-level API for this, feel free to raise a GH issue against Spring AMQP project: https://github.com/spring-projects/spring-amqp/issues .

Or in Spring Cloud Stream if you find existing Spring AMQP capabilities as enough, but still think that Spring Cloud Stream destination provisioner could be improved with some extra properties: https://github.com/spring-cloud/spring-cloud-stream

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM