コード例 #1
0
 public void addConsumerBrokerExchange(
     ConsumerId id, AMQSession amqSession, Map<ActiveMQDestination, AMQConsumer> consumerMap) {
   AMQConsumerBrokerExchange result = consumerExchanges.get(id);
   if (result == null) {
     if (consumerMap.size() == 1) {
       result =
           new AMQSingleConsumerBrokerExchange(amqSession, consumerMap.values().iterator().next());
     } else {
       result = new AMQCompositeConsumerBrokerExchange(amqSession, consumerMap);
     }
     synchronized (consumerExchanges) {
       result.setConnectionContext(context);
       SessionState ss = state.getSessionState(id.getParentId());
       if (ss != null) {
         ConsumerState cs = ss.getConsumerState(id);
         if (cs != null) {
           ConsumerInfo info = cs.getInfo();
           if (info != null) {
             if (info.getDestination() != null && info.getDestination().isPattern()) {
               result.setWildcard(true);
             }
           }
         }
       }
       consumerExchanges.put(id, result);
     }
   }
 }
コード例 #2
0
  @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;
  }
コード例 #3
0
  /**
   * Write a object instance to data output stream
   *
   * @param o the instance to be marshaled
   * @param dataOut the output stream
   * @throws IOException thrown if an error occurs
   */
  public void tightMarshal2(
      OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs)
      throws IOException {
    super.tightMarshal2(wireFormat, o, dataOut, bs);

    ConsumerInfo info = (ConsumerInfo) o;
    tightMarshalCachedObject2(wireFormat, (DataStructure) info.getConsumerId(), dataOut, bs);
    bs.readBoolean();
    tightMarshalCachedObject2(wireFormat, (DataStructure) info.getDestination(), dataOut, bs);
    dataOut.writeInt(info.getPrefetchSize());
    dataOut.writeInt(info.getMaximumPendingMessageLimit());
    bs.readBoolean();
    tightMarshalString2(info.getSelector(), dataOut, bs);
    tightMarshalString2(info.getSubscriptionName(), dataOut, bs);
    bs.readBoolean();
    bs.readBoolean();
    bs.readBoolean();
    dataOut.writeByte(info.getPriority());
    tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
    tightMarshalNestedObject2(
        wireFormat, (DataStructure) info.getAdditionalPredicate(), dataOut, bs);
    bs.readBoolean();
    bs.readBoolean();
    bs.readBoolean();
    tightMarshalObjectArray2(wireFormat, info.getNetworkConsumerPath(), dataOut, bs);
  }
コード例 #4
0
  /** Write the booleans that this object uses to a BooleanStream */
  public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut)
      throws IOException {

    ConsumerInfo info = (ConsumerInfo) o;

    super.looseMarshal(wireFormat, o, dataOut);
    looseMarshalCachedObject(wireFormat, (DataStructure) info.getConsumerId(), dataOut);
    dataOut.writeBoolean(info.isBrowser());
    looseMarshalCachedObject(wireFormat, (DataStructure) info.getDestination(), dataOut);
    dataOut.writeInt(info.getPrefetchSize());
    dataOut.writeInt(info.getMaximumPendingMessageLimit());
    dataOut.writeBoolean(info.isDispatchAsync());
    looseMarshalString(info.getSelector(), dataOut);
    looseMarshalString(info.getSubscriptionName(), dataOut);
    dataOut.writeBoolean(info.isNoLocal());
    dataOut.writeBoolean(info.isExclusive());
    dataOut.writeBoolean(info.isRetroactive());
    dataOut.writeByte(info.getPriority());
    looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
    looseMarshalNestedObject(wireFormat, (DataStructure) info.getAdditionalPredicate(), dataOut);
    dataOut.writeBoolean(info.isNetworkSubscription());
    dataOut.writeBoolean(info.isOptimizedAcknowledge());
    dataOut.writeBoolean(info.isNoRangeAcks());
    looseMarshalObjectArray(wireFormat, info.getNetworkConsumerPath(), dataOut);
  }
コード例 #5
0
  /** Write the booleans that this object uses to a BooleanStream */
  public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs)
      throws IOException {

    ConsumerInfo info = (ConsumerInfo) o;

    int rc = super.tightMarshal1(wireFormat, o, bs);
    rc += tightMarshalCachedObject1(wireFormat, (DataStructure) info.getConsumerId(), bs);
    bs.writeBoolean(info.isBrowser());
    rc += tightMarshalCachedObject1(wireFormat, (DataStructure) info.getDestination(), bs);
    bs.writeBoolean(info.isDispatchAsync());
    rc += tightMarshalString1(info.getSelector(), bs);
    rc += tightMarshalString1(info.getSubscriptionName(), bs);
    bs.writeBoolean(info.isNoLocal());
    bs.writeBoolean(info.isExclusive());
    bs.writeBoolean(info.isRetroactive());
    rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
    rc += tightMarshalNestedObject1(wireFormat, (DataStructure) info.getAdditionalPredicate(), bs);
    bs.writeBoolean(info.isNetworkSubscription());
    bs.writeBoolean(info.isOptimizedAcknowledge());
    bs.writeBoolean(info.isNoRangeAcks());
    rc += tightMarshalObjectArray1(wireFormat, info.getNetworkConsumerPath(), bs);

    return rc + 9;
  }