Skip to content

Commit

Permalink
wait 3s for shutdown condition; output object id; refs #26688
Browse files Browse the repository at this point in the history
  • Loading branch information
Keelhaul committed Jan 23, 2025
1 parent 34eddb2 commit e23bee5
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class DefaultQueueListener {

private static final Logger log = LogManager.getLogger(DefaultQueueListener.class);

private final Object lock = new Object();
private final MessageQueueManager messageBroker;
private Thread thread = null;
private volatile boolean shouldStop = false;
Expand Down Expand Up @@ -119,12 +120,10 @@ void waitForMessage(Session sess, MessageConsumer consumer) {
try {
Message message = consumer.receive();
ViewerMessage ticket = null;
if (message instanceof TextMessage) {
TextMessage tm = (TextMessage) message;
if (message instanceof TextMessage tm) {
ticket = ViewerMessage.parseJSON(tm.getText());
}
if (message instanceof BytesMessage) {
BytesMessage bm = (BytesMessage) message;
if (message instanceof BytesMessage bm) {
byte[] bytes = new byte[(int) bm.getBodyLength()];
bm.readBytes(bytes);
ticket = ViewerMessage.parseJSON(new String(bytes));
Expand All @@ -136,13 +135,13 @@ void waitForMessage(Session sess, MessageConsumer consumer) {
if (!shouldStop) {
// back off a little bit, maybe we have a problem with the connection or we are shutting down
try {
Thread.sleep(1500);
Thread.sleep(3000);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
return;
}
if (!shouldStop) {
log.error("Message listener has encountered an error. Attempting to resume listener", e);
log.error("Message listener {} has encountered an error. Attempting to resume listener", this, e);
}
}
}
Expand Down Expand Up @@ -216,7 +215,7 @@ public void interruptTask() {

public void close() {
this.shouldStop = true;
log.info("Stopping MessageQueue listener...");
log.info("Stopping MessageQueue listener {}...", this);
try {
if (this.thread != null) {
this.thread.join(1000);
Expand Down

0 comments on commit e23bee5

Please sign in to comment.