Skip to content

Commit 04b2881

Browse files
authored
Merge pull request #41 from mhuffman-r7/master
Allow consumer to stop processing messages upon closing
2 parents 721cd7d + 091d3e4 commit 04b2881

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
@@ -589,9 +589,14 @@ private javax.jms.Message messageHandler(MessageManager messageManager) throws J
589589
}
590590

591591
private boolean cannotDeliver() throws JMSException {
592-
if (isClosed() || !running) {
593-
return true;
592+
if (!running) {
593+
return true;
594594
}
595+
596+
if (isClosed()) {
597+
throw new JMSException("Cannot receive messages when the consumer is closed");
598+
}
599+
595600
if (messageListener != null) {
596601
throw new JMSException("Cannot receive messages synchronously after a message listener is set");
597602
}

0 commit comments

Comments
 (0)