-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we have a Receiver example with no Sender? #106
Comments
The sender is used to create the queue the receiver will consume from. Which API would you suggest to use to create this queue? Raw Java client? |
Looks like it's a call into this.rabbitTemplate.execute((channel) -> {
DeclareOk[] declared = this.declareQueues(channel, queue);
return declared.length > 0 ? declared[0].getQueue() : null;
}) This ultimately ends up going to Rabbit's client In fact, couldn't this code simply migrate to the public Mono<AMQP.Queue.DeclareOk> declareQueue(QueueSpecification specification, ResourceManagementOptions options) {
Mono<? extends Channel> channelMono = getChannelMonoForResourceManagement(options);
AMQP.Queue.Declare declare;
if (specification.getName() == null) {
declare = new AMQImpl.Queue.Declare.Builder()
.queue("")
.durable(false)
.exclusive(true)
.autoDelete(true)
.arguments(specification.getArguments())
.build();
} else {
declare = new AMQImpl.Queue.Declare.Builder()
.queue(specification.getName())
.durable(specification.isDurable())
.exclusive(specification.isExclusive())
.autoDelete(specification.isAutoDelete())
.passive(specification.isPassive())
.arguments(specification.getArguments())
.build();
}
return channelMono.map(channel -> {
try {
return channel.asyncCompletableRpc(declare);
} catch (IOException e) {
throw new RabbitFluxException("Error during RPC call", e);
}
}).flatMap(future -> Mono.fromCompletionStage(future))
.flatMap(command -> Mono.just((AMQP.Queue.DeclareOk) command.getMethod()))
.publishOn(resourceManagementScheduler);
} |
If I'm using an anonymous queue for each |
I mean the RabbitMQ Java client ( reactor-rabbitmq/src/test/java/reactor/rabbitmq/SenderTests.java Lines 50 to 56 in 9794c4c
|
So why not put that into |
As suggested in #107 comments,
Not sure. Exchanges and queues need to be bound in some way, following this reasoning, where should binding management go? |
Agree that you could create an For more comparison, I adore using this tactic when I use Spring AMQP: @RabbitListener(bindings = @QueueBinding( //
value = @Queue, //
exchange = @Exchange("hacking-spring-boot"), //
key = "new-items-spring-amqp")) Putting aside the automated tie in to method invocation, this signals to create an anonymous queue, and bind it to an exchange with a key. I'm not saying you need to adopt annotation-based bindings, but the |
Reading the samples to grok the API, I found it confusing to see
Sender
-based code smack dab inside theReceiveSample
.Motivation
A clear separation of
Sender
fromReceiver
seems to me the cleanest way to demonstrate the API. It drove me to using Spring AMQP'sAmqpAdmin
to put together the exchange, queue, and binding.Additional context
I am doing a side-by-side comparison of Spring AMQP vs. Reactor RabbitMQ and learning what "magic" is provided by Spring Boot + Spring AMQP and it's annotations.
The text was updated successfully, but these errors were encountered: