Skip to content

Commit 091d3e4

Browse files
Allow consumer to stop processing messages upon closing
1 parent ec0677b commit 091d3e4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/com/amazon/sqs/javamessaging/SQSMessageConsumerPrefetch.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,14 @@ private javax.jms.Message messageHandler(MessageManager messageManager) throws J
570570
}
571571

572572
private boolean cannotDeliver() throws JMSException {
573-
if (isClosed() || !running) {
574-
return true;
573+
if (!running) {
574+
return true;
575575
}
576+
577+
if (isClosed()) {
578+
throw new JMSException("Cannot receive messages when the consumer is closed");
579+
}
580+
576581
if (messageListener != null) {
577582
throw new JMSException("Cannot receive messages synchronously after a message listener is set");
578583
}

0 commit comments

Comments
 (0)