Skip to content

Commit 9b43c06

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 059fe5e commit 9b43c06

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-2017 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.
@@ -677,9 +677,6 @@ private void consumeFromQueue(String queue) throws IOException {
677677
else {
678678
logger.error("Null consumer tag received for queue " + queue);
679679
}
680-
if (this.applicationEventPublisher != null) {
681-
this.applicationEventPublisher.publishEvent(new ConsumeOkEvent(this, queue, consumerTag));
682-
}
683680
}
684681

685682
private void attemptPassiveDeclarations() {
@@ -875,7 +872,12 @@ private final class InternalConsumer extends DefaultConsumer {
875872
public void handleConsumeOk(String consumerTag) {
876873
super.handleConsumeOk(consumerTag);
877874
if (logger.isDebugEnabled()) {
878-
logger.debug("ConsumeOK : " + BlockingQueueConsumer.this);
875+
logger.debug("ConsumeOK: " + BlockingQueueConsumer.this);
876+
}
877+
if (BlockingQueueConsumer.this.applicationEventPublisher != null) {
878+
String queueName = BlockingQueueConsumer.this.consumerTags.get(consumerTag);
879+
BlockingQueueConsumer.this.applicationEventPublisher
880+
.publishEvent(new ConsumeOkEvent(this, queueName, consumerTag));
879881
}
880882
}
881883

0 commit comments

Comments
 (0)