Skip to content

Commit 8fc94eb

Browse files
artembilangaryrussell
authored andcommitted
AMQP-801: Move ConsumeOkEvent to handleConsumeOk
JIRA: https://jira.spring.io/browse/AMQP-801 The proper place to emit the `ConsumeOkEvent` is really a `handleConsumeOk()` callback when broker answers us that consumer has been subscribed to the queue **Cherry-pick to 1.7.x**
1 parent e2fb3f8 commit 8fc94eb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/BlockingQueueConsumer.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -684,9 +684,6 @@ private void consumeFromQueue(String queue) throws IOException {
684684
else {
685685
logger.error("Null consumer tag received for queue " + queue);
686686
}
687-
if (this.applicationEventPublisher != null) {
688-
this.applicationEventPublisher.publishEvent(new ConsumeOkEvent(this, queue, consumerTag));
689-
}
690687
}
691688

692689
private void attemptPassiveDeclarations() {
@@ -885,7 +882,12 @@ private InternalConsumer(Channel channel) {
885882
public void handleConsumeOk(String consumerTag) {
886883
super.handleConsumeOk(consumerTag);
887884
if (logger.isDebugEnabled()) {
888-
logger.debug("ConsumeOK : " + BlockingQueueConsumer.this);
885+
logger.debug("ConsumeOK: " + BlockingQueueConsumer.this);
886+
}
887+
if (BlockingQueueConsumer.this.applicationEventPublisher != null) {
888+
String queueName = BlockingQueueConsumer.this.consumerTags.get(consumerTag);
889+
BlockingQueueConsumer.this.applicationEventPublisher
890+
.publishEvent(new ConsumeOkEvent(this, queueName, consumerTag));
889891
}
890892
}
891893

0 commit comments

Comments
 (0)