@Override public Set<Destination> getDestinations(ActiveMQDestination destination) { try { return getRegion(destination).getDestinations(destination); } catch (JMSException jmse) { return Collections.emptySet(); } }
@Override public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception { if (consumerExchange.isWildcard() || consumerExchange.getRegion() == null) { ActiveMQDestination destination = ack.getDestination(); consumerExchange.setRegion(getRegion(destination)); } consumerExchange.getRegion().acknowledge(consumerExchange, ack); }
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { ActiveMQDestination destination = info.getDestination(); if (destinationInterceptor != null) { destinationInterceptor.create(this, context, destination); } inactiveDestinationsPurgeLock.readLock().lock(); try { return getRegion(destination).addConsumer(context, info); } finally { inactiveDestinationsPurgeLock.readLock().unlock(); } }
@Override public Map<ActiveMQDestination, Destination> getDestinationMap(ActiveMQDestination destination) { try { return getRegion(destination).getDestinationMap(); } catch (JMSException jmse) { return Collections.emptyMap(); } }
@Override public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception { message.setBrokerInTime(System.currentTimeMillis()); if (producerExchange.isMutable() || producerExchange.getRegion() == null || (producerExchange.getRegion() != null && producerExchange.getRegion().getDestinationMap().get(message.getDestination()) == null)) { ActiveMQDestination destination = message.getDestination(); // ensure the destination is registered with the RegionBroker producerExchange.getConnectionContext().getBroker().addDestination(producerExchange.getConnectionContext(), destination,false); Region region; switch (destination.getDestinationType()) { case ActiveMQDestination.QUEUE_TYPE: region = queueRegion; break; case ActiveMQDestination.TOPIC_TYPE: region = topicRegion; break; case ActiveMQDestination.TEMP_QUEUE_TYPE: region = tempQueueRegion; break; case ActiveMQDestination.TEMP_TOPIC_TYPE: region = tempTopicRegion; break; default: throw createUnknownDestinationTypeException(destination); } producerExchange.setRegion(region); producerExchange.setRegionDestination(null); } producerExchange.getRegion().send(producerExchange, message); }
@Override public Response messagePull(ConnectionContext context, MessagePull pull) throws Exception { ActiveMQDestination destination = pull.getDestination(); return getRegion(destination).messagePull(context, pull); }
@Override public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception { ActiveMQDestination destination = messageDispatchNotification.getDestination(); getRegion(destination).processDispatchNotification(messageDispatchNotification); }
@Override public void processConsumerControl(ConsumerBrokerExchange consumerExchange, ConsumerControl control) { ActiveMQDestination destination = control.getDestination(); try { getRegion(destination).processConsumerControl(consumerExchange, control); } catch (JMSException jmse) { LOG.warn("unmatched destination: {}, in consumerControl: {}", destination, control); } }
@Override public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception { ActiveMQDestination destination = info.getDestination(); if (destination != null) { inactiveDestinationsPurgeLock.readLock().lock(); try { // This seems to cause the destination to be added but without // advisories firing... context.getBroker().addDestination(context, destination, isAllowTempAutoCreationOnSend()); getRegion(destination).addProducer(context, info); } finally { inactiveDestinationsPurgeLock.readLock().unlock(); } } }
create = createIfTemp; answer = getRegion(destination).addDestination(context, destination, create); destinations.put(destination, answer); } finally {
@Override public Map<ActiveMQDestination, Destination> getDestinationMap() { Map<ActiveMQDestination, Destination> answer = new HashMap<ActiveMQDestination, Destination>(getQueueRegion().getDestinationMap()); answer.putAll(getTopicRegion().getDestinationMap()); return answer; }
@Override public Response messagePull(ConnectionContext context, MessagePull pull) throws Exception { ActiveMQDestination destination = pull.getDestination(); switch (destination.getDestinationType()) { case ActiveMQDestination.QUEUE_TYPE: return queueRegion.messagePull(context, pull); case ActiveMQDestination.TOPIC_TYPE: return topicRegion.messagePull(context, pull); case ActiveMQDestination.TEMP_QUEUE_TYPE: return tempQueueRegion.messagePull(context, pull); case ActiveMQDestination.TEMP_TOPIC_TYPE: return tempTopicRegion.messagePull(context, pull); default: throw createUnknownDestinationTypeException(destination); } }
@Override public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception { ActiveMQDestination destination = messageDispatchNotification.getDestination(); switch (destination.getDestinationType()) { case ActiveMQDestination.QUEUE_TYPE: queueRegion.processDispatchNotification(messageDispatchNotification); break; case ActiveMQDestination.TOPIC_TYPE: topicRegion.processDispatchNotification(messageDispatchNotification); break; case ActiveMQDestination.TEMP_QUEUE_TYPE: tempQueueRegion.processDispatchNotification(messageDispatchNotification); break; case ActiveMQDestination.TEMP_TOPIC_TYPE: tempTopicRegion.processDispatchNotification(messageDispatchNotification); break; default: throw createUnknownDestinationTypeException(destination); } }
@Override public void processConsumerControl(ConsumerBrokerExchange consumerExchange, ConsumerControl control) { ActiveMQDestination destination = control.getDestination(); switch (destination.getDestinationType()) { case ActiveMQDestination.QUEUE_TYPE: queueRegion.processConsumerControl(consumerExchange, control); break; case ActiveMQDestination.TOPIC_TYPE: topicRegion.processConsumerControl(consumerExchange, control); break; case ActiveMQDestination.TEMP_QUEUE_TYPE: tempQueueRegion.processConsumerControl(consumerExchange, control); break; case ActiveMQDestination.TEMP_TOPIC_TYPE: tempTopicRegion.processConsumerControl(consumerExchange, control); break; default: LOG.warn("unmatched destination: " + destination + ", in consumerControl: " + control); } }
@Override public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception { ActiveMQDestination destination = info.getDestination(); synchronized (purgeInactiveDestinationsTask) { if (destination != null) { // This seems to cause the destination to be added but without // advisories firing... context.getBroker().addDestination(context, destination, false); switch (destination.getDestinationType()) { case ActiveMQDestination.QUEUE_TYPE: queueRegion.addProducer(context, info); break; case ActiveMQDestination.TOPIC_TYPE: topicRegion.addProducer(context, info); break; case ActiveMQDestination.TEMP_QUEUE_TYPE: tempQueueRegion.addProducer(context, info); break; case ActiveMQDestination.TEMP_TOPIC_TYPE: tempTopicRegion.addProducer(context, info); break; } } } }
@Override public Destination addDestination(ConnectionContext context, ActiveMQDestination destination,boolean create) throws Exception { Destination answer; answer = destinations.get(destination); if (answer != null) { return answer; } switch (destination.getDestinationType()) { case ActiveMQDestination.QUEUE_TYPE: answer = queueRegion.addDestination(context, destination,true); break; case ActiveMQDestination.TOPIC_TYPE: answer = topicRegion.addDestination(context, destination,true); break; case ActiveMQDestination.TEMP_QUEUE_TYPE: answer = tempQueueRegion.addDestination(context, destination,create); break; case ActiveMQDestination.TEMP_TOPIC_TYPE: answer = tempTopicRegion.addDestination(context, destination,create); break; default: throw createUnknownDestinationTypeException(destination); } destinations.put(destination, answer); return answer; }
protected Message[] getSubscriberMessages(SubscriptionView view) { ActiveMQDestination destination = getTopicDestination(view); if (destination != null) { Destination topic = getTopicRegion().getDestinationMap().get(destination); return topic.browse(); } else { LOG.warn("can't determine topic to browse for sub:" + view); return new Message[]{}; } }
@Override public Set <Destination> getDestinations(ActiveMQDestination destination) { switch (destination.getDestinationType()) { case ActiveMQDestination.QUEUE_TYPE: return queueRegion.getDestinations(destination); case ActiveMQDestination.TOPIC_TYPE: return topicRegion.getDestinations(destination); case ActiveMQDestination.TEMP_QUEUE_TYPE: return tempQueueRegion.getDestinations(destination); case ActiveMQDestination.TEMP_TOPIC_TYPE: return tempTopicRegion.getDestinations(destination); default: return Collections.emptySet(); } }