@Override public Destination addDestination(ConnectionContext context, ActiveMQDestination destination,boolean createIfTemporary) throws Exception { Destination result = next.addDestination(context, destination,createIfTemporary); Broker brokers[] = getListeners(); for (int i = 0; i < brokers.length; i++) { brokers[i].addDestination(context, destination,createIfTemporary); } return result; }
@Override public Destination addDestination(ConnectionContext context, ActiveMQDestination destination,boolean createIfTemporary) throws Exception { return getNext().addDestination(context, destination,createIfTemporary); }
/** * Looks up and lazily creates if necessary the destination for the given * JMS name */ public Destination getDestination(ActiveMQDestination destination) throws Exception { return getBroker().addDestination(getAdminConnectionContext(), destination,false); }
protected Destination lookup(ConnectionContext context, ActiveMQDestination destination,boolean createTemporary) throws Exception { Destination dest = null; destinationsLock.readLock().lock(); try { dest = destinations.get(destination); } finally { destinationsLock.readLock().unlock(); } if (dest == null) { if (isAutoCreateDestinations()) { // Try to auto create the destination... re-invoke broker // from the // top so that the proper security checks are performed. dest = context.getBroker().addDestination(context, destination, createTemporary); } if (dest == null) { throw new JMSException("The destination " + destination + " does not exist."); } } return dest; }
protected void importDestinations() throws Exception { BufferedReader reader = null; try { if (location.exists()) { reader = new BufferedReader(new FileReader(location)); String destination; Broker broker = getBrokerService().getBroker(); while ((destination = reader.readLine()) != null) { broker.addDestination(getBrokerService().getAdminConnectionContext(), ActiveMQDestination.createDestination(destination, ActiveMQDestination.QUEUE_TYPE), true); } } } catch (Exception e) { LOG.warn("Exception loading destinations", e); } finally { if (reader != null) { reader.close(); } } }
@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(); } } }
@Override public final void start() throws Exception { started = true; Set<ActiveMQDestination> inactiveDests = getInactiveDestinations(); for (Iterator<ActiveMQDestination> iter = inactiveDests.iterator(); iter.hasNext();) { ActiveMQDestination dest = iter.next(); ConnectionContext context = new ConnectionContext(); context.setBroker(broker.getBrokerService().getBroker()); context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); context.getBroker().addDestination(context, dest, false); } destinationsLock.readLock().lock(); try{ for (Iterator<Destination> i = destinations.values().iterator(); i.hasNext();) { Destination dest = i.next(); dest.start(); } } finally { destinationsLock.readLock().unlock(); } }
protected void startVirtualConsumerDestinations() throws Exception { checkStartException(); ConnectionContext adminConnectionContext = getAdminConnectionContext(); Set<ActiveMQDestination> destinations = destinationFactory.getDestinations(); DestinationFilter filter = getVirtualTopicConsumerDestinationFilter(); if (!destinations.isEmpty()) { for (ActiveMQDestination destination : destinations) { if (filter.matches(destination) == true) { broker.addDestination(adminConnectionContext, destination, false); } } } }
/** * Starts any configured destinations on startup */ protected void startDestinations() throws Exception { if (destinations != null) { ConnectionContext adminConnectionContext = getAdminConnectionContext(); for (int i = 0; i < destinations.length; i++) { ActiveMQDestination destination = destinations[i]; getBroker().addDestination(adminConnectionContext, destination,true); } } if (isUseVirtualTopics()) { startVirtualConsumerDestinations(); } }
@Override public void create(Broker broker, ConnectionContext context, ActiveMQDestination destination) throws Exception { if (destination.isQueue() && destination.isPattern()) { DestinationFilter filter = DestinationFilter.parseFilter(new ActiveMQQueue(prefix + DestinationFilter.ANY_DESCENDENT)); if (filter.matches(destination)) { broker.addDestination(context, destination, false); } } }
@Override public void addQueue(String name) throws Exception { safeGetBroker().getContextBroker() .addDestination(BrokerSupport.getConnectionContext(safeGetBroker().getContextBroker()), new ActiveMQQueue(name), true); }
@Override public void addTopic(String name) throws Exception { safeGetBroker().getContextBroker() .addDestination(BrokerSupport.getConnectionContext(safeGetBroker().getContextBroker()), new ActiveMQTopic(name), true); }
@Override public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception { ActiveMQDestination destination = message.getDestination(); message.setBrokerInTime(System.currentTimeMillis()); if (producerExchange.isMutable() || producerExchange.getRegion() == null || (producerExchange.getRegionDestination() != null && producerExchange.getRegionDestination().isDisposed())) { // ensure the destination is registered with the RegionBroker producerExchange.getConnectionContext().getBroker() .addDestination(producerExchange.getConnectionContext(), destination, isAllowTempAutoCreationOnSend()); producerExchange.setRegion(getRegion(destination)); producerExchange.setRegionDestination(null); } producerExchange.getRegion().send(producerExchange, message); // clean up so these references aren't kept (possible leak) in the producer exchange // especially since temps are transitory if (producerExchange.isMutable()) { producerExchange.setRegionDestination(null); producerExchange.setRegion(null); } }
@Override public Destination addDestination(ConnectionContext context, ActiveMQDestination destination,boolean createIfTemporary) throws Exception { Destination result = next.addDestination(context, destination,createIfTemporary); Broker brokers[] = getListeners(); for (int i = 0; i < brokers.length; i++) { brokers[i].addDestination(context, destination,createIfTemporary); } return result; }
@Override public Destination addDestination(ConnectionContext context, ActiveMQDestination destination,boolean createIfTemporary) throws Exception { Destination result = next.addDestination(context, destination,createIfTemporary); Broker brokers[] = getListeners(); for (int i = 0; i < brokers.length; i++) { brokers[i].addDestination(context, destination,createIfTemporary); } return result; }
@Override public Destination addDestination(ConnectionContext context, ActiveMQDestination destination,boolean createIfTemporary) throws Exception { return getNext().addDestination(context, destination,createIfTemporary); }
/** * Looks up and lazily creates if necessary the destination for the given * JMS name */ public Destination getDestination(ActiveMQDestination destination) throws Exception { return getBroker().addDestination(getAdminConnectionContext(), destination,false); }
@Override public void create(Broker broker, ConnectionContext context, ActiveMQDestination destination) throws Exception { if (destination.isQueue() && destination.isPattern()) { DestinationFilter filter = DestinationFilter.parseFilter(new ActiveMQQueue(prefix + DestinationFilter.ANY_DESCENDENT)); if (filter.matches(destination)) { broker.addDestination(context, destination, false); } } }
@Override public void addTopic(String name) throws Exception { safeGetBroker().getContextBroker() .addDestination(BrokerSupport.getConnectionContext(safeGetBroker().getContextBroker()), new ActiveMQTopic(name), true); }
@Override public void addQueue(String name) throws Exception { safeGetBroker().getContextBroker() .addDestination(BrokerSupport.getConnectionContext(safeGetBroker().getContextBroker()), new ActiveMQQueue(name), true); }