/** * Constructs the instance. * * @param config the instance configuration */ public DefaultHazelcastMQInstance(HazelcastMQConfig config) { this.config = config; contextMap = new ConcurrentHashMap<>(); // Setup a subscription to the transactional topic queue. topicRelayer = new TopicMessageRelayer(); }
@Override public void shutdown() { // Stop all the contexts. The list of contexts is duplicated because they // will report being closed and removed from the map during this operation. List<HazelcastMQContext> contexts = new ArrayList<>(contextMap.values()); for (HazelcastMQContext context : contexts) { // Close the context unless it is the one being used by our internal // relayer. We'll do that last to make sure any pending topic messages // are properly relayed before shutdown. if (context != topicRelayer.getContext()) { context.close(); } } // Stop the topic relayer. topicRelayer.shutdown(); }