Skip to content

Commit

Permalink
fixed bug caused by static variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mjfelis committed Apr 8, 2024
1 parent 614330a commit dc32254
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/main/java/io/twentysixty/sa/client/jms/AbstractConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public class AbstractConsumer<M> implements ConsumerInterface<M> {

private static final Logger logger = Logger.getLogger(AbstractConsumer.class);

private static Map<UUID,Object> lockObjs = new HashMap<UUID,Object>();
private static Map<UUID,Boolean> runnings = new HashMap<UUID,Boolean>();
private static Map<UUID,Boolean> starteds = new HashMap<UUID,Boolean>();
private static Map<UUID,JMSContext> contexts = new HashMap<UUID,JMSContext>();
private Map<UUID,Object> lockObjs = new HashMap<UUID,Object>();
private Map<UUID,Boolean> runnings = new HashMap<UUID,Boolean>();
private Map<UUID,Boolean> starteds = new HashMap<UUID,Boolean>();
private Map<UUID,JMSContext> contexts = new HashMap<UUID,JMSContext>();


private static ExecutorService executor = Executors.newCachedThreadPool();
Expand Down Expand Up @@ -81,7 +81,7 @@ private void stopConsumers() {
}

for (UUID uuid: keySet) {
logger.info("stopConsumers: stopping consumer " + uuid + " for " + queueName);
if (debug) logger.info("stopConsumers: stopping consumer " + uuid + " for " + queueName);
setStoppedConsumer(uuid);

JMSContext context = null;
Expand All @@ -90,10 +90,18 @@ private void stopConsumers() {
context = contexts.get(uuid);
}

if (context != null) context.close();


if (context != null) {
if (debug) logger.info("stopConsumers: closing context " + uuid);
context.close();
}

if (debug) logger.info("stopConsumers: closing context done, calling stopConsumer " + uuid);
stopConsumer(uuid);


if (debug) logger.info("stopConsumers: removing lockObj " + uuid);

synchronized (lockObjs) {
lockObjs.remove(uuid);
}
Expand Down

0 comments on commit dc32254

Please sign in to comment.