@Override protected DemandSubscription createDemandSubscription(ConsumerInfo info) throws IOException { boolean isForcedDurable = NetworkBridgeUtils.isForcedDurable( info, dynamicallyIncludedDestinations, staticallyIncludedDestinations); if (addToAlreadyInterestedConsumers(info, isForcedDurable)) { return null; // don't want this subscription added } // add our original id to ourselves info.addNetworkConsumerId(info.getConsumerId()); ConsumerId forcedDurableId = isForcedDurable ? info.getConsumerId() : null; if (info.isDurable() || isForcedDurable) { // set the subscriber name to something reproducible info.setSubscriptionName(getSubscriberName(info.getDestination())); // and override the consumerId with something unique so that it won't // be removed if the durable subscriber (at the other end) goes away info.setConsumerId( new ConsumerId(localSessionInfo.getSessionId(), consumerIdGenerator.getNextSequenceId())); } info.setSelector(null); DemandSubscription demandSubscription = doCreateDemandSubscription(info); if (forcedDurableId != null) { demandSubscription.addForcedDurableConsumer(forcedDurableId); forcedDurableRemoteId.add(forcedDurableId); } return demandSubscription; }
/** * 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 tightUnmarshal( OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); ConsumerInfo info = (ConsumerInfo) o; info.setConsumerId( (org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setBrowser(bs.readBoolean()); info.setDestination( (org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setPrefetchSize(dataIn.readInt()); info.setMaximumPendingMessageLimit(dataIn.readInt()); info.setDispatchAsync(bs.readBoolean()); info.setSelector(tightUnmarshalString(dataIn, bs)); info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); info.setNoLocal(bs.readBoolean()); info.setExclusive(bs.readBoolean()); info.setRetroactive(bs.readBoolean()); info.setPriority(dataIn.readByte()); if (bs.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) tightUnmarsalNestedObject(wireFormat, dataIn, bs); } info.setBrokerPath(value); } else { info.setBrokerPath(null); } info.setAdditionalPredicate( (org.apache.activemq.filter.BooleanExpression) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); info.setNetworkSubscription(bs.readBoolean()); info.setOptimizedAcknowledge(bs.readBoolean()); info.setNoRangeAcks(bs.readBoolean()); if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.ConsumerId value[] = new org.apache.activemq.command.ConsumerId[size]; for (int i = 0; i < size; i++) { value[i] = (org.apache.activemq.command.ConsumerId) tightUnmarsalNestedObject(wireFormat, dataIn, bs); } info.setNetworkConsumerPath(value); } else { info.setNetworkConsumerPath(null); } }
@Override protected void populateObject(Object object) throws Exception { super.populateObject(object); ConsumerInfo info = (ConsumerInfo) object; info.setConsumerId(createConsumerId("ConsumerId:1")); info.setBrowser(true); info.setDestination(createActiveMQDestination("Destination:2")); info.setPrefetchSize(1); info.setMaximumPendingMessageLimit(2); info.setDispatchAsync(false); info.setSelector("Selector:3"); info.setSubscriptionName("SubscriptionName:4"); info.setNoLocal(true); info.setExclusive(false); info.setRetroactive(true); info.setPriority((byte) 1); { BrokerId value[] = new BrokerId[2]; for (int i = 0; i < 2; i++) { value[i] = createBrokerId("BrokerPath:5"); } info.setBrokerPath(value); } info.setAdditionalPredicate(createBooleanExpression("AdditionalPredicate:6")); info.setNetworkSubscription(false); info.setOptimizedAcknowledge(true); info.setNoRangeAcks(false); { ConsumerId value[] = new ConsumerId[2]; for (int i = 0; i < 2; i++) { value[i] = createConsumerId("NetworkConsumerPath:7"); } info.setNetworkConsumerPath(value); } }