public void destroyDestination(ActiveMQDestination destination) throws JMSException { checkClosedOrFailed(); ensureConnectionInfoSent(); DestinationInfo info = new DestinationInfo(); info.setConnectionId(this.info.getConnectionId()); info.setOperationType(DestinationInfo.REMOVE_OPERATION_TYPE); info.setDestination(destination); info.setTimeout(0); syncSendPacket(info); }
@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; }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { DestinationInfo info = (DestinationInfo)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConnectionId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); dataOut.writeByte(info.getOperationType()); looseMarshalLong(wireFormat, info.getTimeout(), dataOut); looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); } }
public Response visit(CommandVisitor visitor) throws Exception { if (isAddOperation()) { return visitor.processAddDestination(this); } else if (isRemoveOperation()) { return visitor.processRemoveDestination(this); } throw new IOException("Unknown operation type: " + getOperationType()); }
public ActiveMQDestination createTempDestination(String name, boolean topic) { ActiveMQDestination rc = tempDestinations.get(name); if( rc == null ) { if (topic) { rc = new ActiveMQTempTopic(connectionId, tempDestinationGenerator.getNextSequenceId()); } else { rc = new ActiveMQTempQueue(connectionId, tempDestinationGenerator.getNextSequenceId()); } sendToActiveMQ(new DestinationInfo(connectionId, DestinationInfo.ADD_OPERATION_TYPE, rc), null); tempDestinations.put(name, rc); tempDestinationAmqToStompMap.put(rc.getQualifiedName(), name); } return rc; }
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); } }
@Override public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception { super.removeDestination(context, destination, timeout); DestinationInfo info = destinations.remove(destination); if (info != null) { for (ConsumerInfo consumerInfo : virtualDestinationConsumers.keySet()) { VirtualDestination virtualDestination = virtualDestinationConsumers.get(consumerInfo); info = info.copy(); info.setDestination(destination); info.setOperationType(DestinationInfo.REMOVE_OPERATION_TYPE); ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination); fireAdvisory(context, topic, info); for (ActiveMQTopic advisoryDestination : advisoryDestinations) { try { next.removeDestination(context, advisoryDestination, -1); } catch (Exception expectedIfDestinationDidNotExistYet) {
for (Iterator<ConnectionInfo> iter = connections.values().iterator(); iter.hasNext(); ) { ConnectionInfo value = iter.next(); ActiveMQTopic topic = AdvisorySupport.getConnectionAdvisoryTopic(); for (DestinationInfo destination : destinations.values()) { if (destination.getDestination().isTemporary()) { ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination.getDestination()); fireAdvisory(context, topic, destination, info.getConsumerId()); for (DestinationInfo destination : destinations.values()) { ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination.getDestination()); fireAdvisory(context, topic, destination, info.getConsumerId());
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); DestinationInfo info = (DestinationInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setOperationType(dataIn.readByte()); info.setTimeout(looseUnmarshalLong(wireFormat, dataIn)); if (dataIn.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; for( int i=0; i < size; i++ ) { value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn); } info.setBrokerPath(value); } else { info.setBrokerPath(null); } }
@Override public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception { ActiveMQDestination destination = info.getDestination(); next.addDestinationInfo(context, info); if (!AdvisorySupport.isAdvisoryTopic(destination)) { DestinationInfo previous = destinations.putIfAbsent(destination, info); if (previous == null) { ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination); fireAdvisory(context, topic, info); } } }
@Override public void removeDestinationInfo(ConnectionContext context, DestinationInfo destInfo) throws Exception { super.removeDestinationInfo(context, destInfo); DestinationInfo info = destinations.remove(destInfo.getDestination()); if (info != null) { // ensure we don't modify (and loose/overwrite) an in-flight add advisory, so duplicate info = info.copy(); info.setDestination(destInfo.getDestination()); info.setOperationType(DestinationInfo.REMOVE_OPERATION_TYPE); ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destInfo.getDestination()); fireAdvisory(context, topic, info); ActiveMQTopic[] advisoryDestinations = AdvisorySupport.getAllDestinationAdvisoryTopics(destInfo.getDestination()); for (ActiveMQTopic advisoryDestination : advisoryDestinations) { try { next.removeDestination(context, advisoryDestination, -1); } catch (Exception expectedIfDestinationDidNotExistYet) { } } } }
/** * Create the DestinationInfo object for the temporary destination. * * @param topic - if its true topic, else queue. * @return DestinationInfo * @throws JMSException */ protected ActiveMQTempDestination createTempDestination(boolean topic) throws JMSException { // Check if Destination info is of temporary type. ActiveMQTempDestination dest; if (topic) { dest = new ActiveMQTempTopic(info.getConnectionId(), tempDestinationIdGenerator.getNextSequenceId()); } else { dest = new ActiveMQTempQueue(info.getConnectionId(), tempDestinationIdGenerator.getNextSequenceId()); } DestinationInfo info = new DestinationInfo(); info.setConnectionId(this.info.getConnectionId()); info.setOperationType(DestinationInfo.ADD_OPERATION_TYPE); info.setDestination(dest); syncSendPacket(info); dest.setConnection(this); activeTempDestinations.put(dest, dest); return dest; }
@Override public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception { final SecurityContext securityContext = checkSecurityContext(context); if (!checkDestinationAdmin(securityContext, info.getDestination())) { throw new SecurityException("User " + securityContext.getUserName() + " is not authorized to remove: " + info.getDestination()); } securityContext.getAuthorizedWriteDests().remove(info.getDestination()); super.removeDestinationInfo(context, info); }
@Override public Destination addDestination(ConnectionContext context, ActiveMQDestination destination, boolean create) throws Exception { Destination answer = super.addDestination(context, destination, create); if (!AdvisorySupport.isAdvisoryTopic(destination)) { //for queues, create demand if isUseVirtualDestSubsOnCreation is true if (getBrokerService().isUseVirtualDestSubsOnCreation() && destination.isQueue()) { //check if this new destination matches a virtual destination that exists for (VirtualDestination virtualDestination : virtualDestinations) { if (virtualDestinationMatcher.matches(virtualDestination, destination)) { fireVirtualDestinationAddAdvisory(context, null, destination, virtualDestination); } } } DestinationInfo info = new DestinationInfo(context.getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, destination); DestinationInfo previous = destinations.putIfAbsent(destination, info); if (previous == null) { ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination); fireAdvisory(context, topic, info); } } return answer; }
BrokerId[] path = destInfo.getBrokerPath(); if (path != null && networkTTL > -1 && path.length >= networkTTL) { LOG.debug("{} Ignoring destination {} restricted to {} network hops only", new Object[]{ return; if (contains(destInfo.getBrokerPath(), localBrokerPath[0])) { LOG.debug("{} Ignoring destination {} already routed through this broker once", configuration.getBrokerName(), destInfo); return; destInfo.setConnectionId(localConnectionInfo.getConnectionId()); if (destInfo.getDestination() instanceof ActiveMQTempDestination) { ActiveMQTempDestination tempDest = (ActiveMQTempDestination) destInfo.getDestination(); tempDest.setConnectionId(localSessionInfo.getSessionId().getConnectionId()); destInfo.setBrokerPath(appendToBrokerPath(destInfo.getBrokerPath(), getRemoteBrokerPath())); LOG.trace("{} bridging {} destination on {} from {}, destination: {}", new Object[]{ configuration.getBrokerName(), (destInfo.isAddOperation() ? "add" : "remove"), localBroker, remoteBrokerName, destInfo }); if (destInfo.isRemoveOperation()) { for (Iterator<DemandSubscription> i = subscriptionMapByLocalId.values().iterator(); i.hasNext(); ) { DemandSubscription ds = i.next(); boolean removed = ds.removeForcedDurableConsumer(id);
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { DestinationInfo info = (DestinationInfo)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConnectionId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc+=tightMarshalLong1(wireFormat, info.getTimeout(), bs); rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs); return rc + 1; }
@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; }
/** * @return a new object instance */ public DataStructure createObject() { return new DestinationInfo(); }
public void removeTempDestination(ActiveMQDestination destination) { for (Iterator<DestinationInfo> iter = tempDestinations.iterator(); iter.hasNext();) { DestinationInfo di = iter.next(); if (di.getDestination().equals(destination)) { iter.remove(); } } }