public BlockingQueue getQueue(String key, int capacity) throws Exception { BlockingQueue queue = null; if (HazelcastManager.hasInstance()) { logger.info("Mule clustering is enabled; using Hazelcast queue"); HazelcastInstance instance = HazelcastManager.getInstance().getHazelcastInstance(); queue = instance.getQueue(key); } else { logger.info("Mule clustering is disabled; using local queue"); queue = registry.lookupObject(key); if (queue == null) { queue = new ArrayBlockingQueue<Long>(capacity); registry.registerObject(key, queue); } } return queue; }