@Override public boolean isDestinationTemporary() { if (info != null) { if (info.getDestination() != null) { ActiveMQDestination dest = info.getDestination(); return dest.isTemporary(); } else if(lastUsedDestination != null) { return lastUsedDestination.isTemporary(); } } return false; }
/** * Retrieve a set of all Topics be used by the Broker * @return all Topics */ public Set<ActiveMQTopic> getTopics(){ Set<ActiveMQTopic> result = new HashSet<ActiveMQTopic>(); for (ActiveMQDestination destination:getDestinations()){ if (destination.isTopic() && !destination.isTemporary()){ result.add((ActiveMQTopic) destination); } } return result; }
/** * Retrieve a set of all Queues be used by the Broker * @return all Queues */ public Set<ActiveMQQueue> getQueues(){ Set<ActiveMQQueue> result = new HashSet<ActiveMQQueue>(); for (ActiveMQDestination destination:getDestinations()){ if (destination.isQueue() && !destination.isTemporary()){ result.add((ActiveMQQueue) destination); } } return result; }
/** * Retrieve a set of all TemporaryQueues be used by the Broker * @return all TemporaryQueues */ public Set<ActiveMQTempQueue> getTempQueues(){ Set<ActiveMQTempQueue> result = new HashSet<ActiveMQTempQueue>(); for (ActiveMQDestination destination:getDestinations()){ if (destination.isQueue() && destination.isTemporary()){ result.add((ActiveMQTempQueue) destination); } } return result; }
/** * Retrieve a set of all TemporaryTopics be used by the Broker * @return all TemporaryTopics */ public Set<ActiveMQTempTopic> getTempTopics(){ Set<ActiveMQTempTopic> result = new HashSet<ActiveMQTempTopic>(); for (ActiveMQDestination destination:getDestinations()){ if (destination.isTopic() && destination.isTemporary()){ result.add((ActiveMQTempTopic) destination); } } return result; }
/** * @return true if the destination is temporary */ @Override public boolean isDestinationTemporary() { ConsumerInfo info = getConsumerInfo(); if (info != null) { ActiveMQDestination dest = info.getDestination(); return dest.isTemporary(); } return false; }
@Override public Response processAddDestination(DestinationInfo info) { if (info != null) { ConnectionState cs = connectionStates.get(info.getConnectionId()); if (cs != null && info.getDestination().isTemporary()) { cs.addTempDestination(info); } } return TRACKED_RESPONSE_MARKER; }
private void fireVirtualDestinationRemoveAdvisory(ConnectionContext context, ConsumerInfo info) throws Exception { VirtualDestination virtualDestination = virtualDestinationConsumers.remove(info); if (virtualDestination != null) { LOG.debug("Virtual consumer removed: {}, for virtual destination: {}", info, virtualDestination); ActiveMQTopic topic = AdvisorySupport.getVirtualDestinationConsumerAdvisoryTopic(virtualDestination.getVirtualDestination()); ActiveMQDestination dest = info.getDestination(); if (!dest.isTemporary() || destinations.containsKey(dest)) { fireConsumerAdvisory(context, dest, topic, info.createRemoveCommand()); } } }
/** * Returns the root node for the given destination type */ protected DestinationMapNode getRootNode(ActiveMQDestination key) { if (key.isTemporary()) { if (key.isQueue()) { return tempQueueRootNode; } else { return tempTopicRootNode; } } else { if (key.isQueue()) { return queueRootNode; } else { return topicRootNode; } } }
@Override public Response processRemoveDestination(DestinationInfo info) { if (info != null) { ConnectionState cs = connectionStates.get(info.getConnectionId()); if (cs != null && info.getDestination().isTemporary()) { cs.removeTempDestination(info.getDestination()); } } return TRACKED_RESPONSE_MARKER; }
@Override public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { if (!AdvisorySupport.isAdvisoryTopic(info.getDestination()) && !info.getDestination().isTemporary()) { if (singleSelectorPerDestination) { String destinationName = info.getDestination().getQualifiedName(); Set<String> selectors = subSelectorCache.get(destinationName); if (info.getSelector() == null && selectors.size() > 1) { boolean removed = selectors.remove(MATCH_EVERYTHING); LOG.debug("A non-selector consumer has dropped. Removing the catchall matching pattern 'TRUE'. Successful? " + removed); } } } super.removeConsumer(context, info); }
private void processDestinationInfo(DestinationInfo dinfo) { ActiveMQDestination dest = dinfo.getDestination(); if (!dest.isTemporary()) { return; } ActiveMQTempDestination tempDest = (ActiveMQTempDestination)dest; if (dinfo.getOperationType() == DestinationInfo.ADD_OPERATION_TYPE) { if (tempDest.getConnection() != null) { tempDest = (ActiveMQTempDestination) tempDest.createDestination(tempDest.getPhysicalName()); } connection.activeTempDestinations.put(tempDest, tempDest); } else if (dinfo.getOperationType() == DestinationInfo.REMOVE_OPERATION_TYPE) { connection.activeTempDestinations.remove(tempDest); } }
protected boolean checkDestinationAdmin(SecurityContext securityContext, ActiveMQDestination destination) { Destination existing = this.getDestinationMap(destination).get(destination); if (existing != null) { return true; } if (!securityContext.isBrokerContext()) { Set<?> allowedACLs = null; if (!destination.isTemporary()) { allowedACLs = authorizationMap.getAdminACLs(destination); } else { allowedACLs = authorizationMap.getTempDestinationAdminACLs(); } if (allowedACLs != null && !securityContext.isInOneOf(allowedACLs)) { return false; } } return true; }
@Override public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception { super.removeProducer(context, info); // Don't advise advisory topics. ActiveMQDestination dest = info.getDestination(); if (info.getDestination() != null && !AdvisorySupport.isAdvisoryTopic(dest)) { ActiveMQTopic topic = AdvisorySupport.getProducerAdvisoryTopic(dest); producers.remove(info.getProducerId()); if (!dest.isTemporary() || destinations.containsKey(dest)) { fireProducerAdvisory(context, dest, topic, info.createRemoveCommand()); } } }
@Override public void removeDestination(Destination dest) { ActiveMQDestination destination = dest.getActiveMQDestination(); if (!destination.isTemporary()) { if (destination.isQueue()) { persistenceAdapter.removeQueueMessageStore((ActiveMQQueue) destination); } else if (!AdvisorySupport.isAdvisoryTopic(destination)) { persistenceAdapter.removeTopicMessageStore((ActiveMQTopic) destination); } } }
public TopicSubscription(Broker broker,ConnectionContext context, ConsumerInfo info, SystemUsage usageManager) throws Exception { super(broker, context, info); this.usageManager = usageManager; String matchedName = "TopicSubscription:" + CURSOR_NAME_COUNTER.getAndIncrement() + "[" + info.getConsumerId().toString() + "]"; if (info.getDestination().isTemporary() || broker.getTempDataStore()==null ) { this.matched = new VMPendingMessageCursor(false); } else { this.matched = new FilePendingMessageCursor(broker,matchedName,false); } this.scheduler = broker.getScheduler(); }
@Override public Response processAddDestination(DestinationInfo info) throws Exception { TransportConnectionState cs = lookupConnectionState(info.getConnectionId()); broker.addDestinationInfo(cs.getContext(), info); if (info.getDestination().isTemporary()) { cs.addTempDestination(info); } return null; }
@Override public Response processRemoveDestination(DestinationInfo info) throws Exception { TransportConnectionState cs = lookupConnectionState(info.getConnectionId()); broker.removeDestinationInfo(cs.getContext(), info); if (info.getDestination().isTemporary()) { cs.removeTempDestination(info.getDestination()); } return null; }
@Override public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception { final SecurityContext securityContext = checkSecurityContext(context); if (!securityContext.isBrokerContext() && info.getDestination() != null) { Set<?> allowedACLs = null; if (!info.getDestination().isTemporary()) { allowedACLs = authorizationMap.getWriteACLs(info.getDestination()); } else { allowedACLs = authorizationMap.getTempDestinationWriteACLs(); } if (allowedACLs != null && !securityContext.isInOneOf(allowedACLs)) { throw new SecurityException("User " + securityContext.getUserName() + " is not authorized to write to: " + info.getDestination()); } securityContext.getAuthorizedWriteDests().put(info.getDestination(), info.getDestination()); } super.addProducer(context, info); }
@Override public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final SecurityContext securityContext = checkSecurityContext(producerExchange.getConnectionContext()); if (!securityContext.isBrokerContext() && !securityContext.getAuthorizedWriteDests().containsValue(messageSend.getDestination())) { Set<?> allowedACLs = null; if (!messageSend.getDestination().isTemporary()) { allowedACLs = authorizationMap.getWriteACLs(messageSend.getDestination()); } else { allowedACLs = authorizationMap.getTempDestinationWriteACLs(); } if (allowedACLs != null && !securityContext.isInOneOf(allowedACLs)) { throw new SecurityException("User " + securityContext.getUserName() + " is not authorized to write to: " + messageSend.getDestination()); } securityContext.getAuthorizedWriteDests().put(messageSend.getDestination(), messageSend.getDestination()); } super.send(producerExchange, messageSend); }