Tabnine Logo
SubscriptionInfo
Code IndexAdd Tabnine to your IDE (free)

How to use
SubscriptionInfo
in
org.apache.activemq.command

Best Java code snippets using org.apache.activemq.command.SubscriptionInfo (Showing top 20 results out of 315)

Refine searchRefine arrow

  • ConsumerInfo
  • BrokerService
  • ActiveMQDestination
origin: apache/activemq

/**
 * Write the booleans that this object uses to a BooleanStream
 */
public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
  SubscriptionInfo info = (SubscriptionInfo)o;
  int rc = super.tightMarshal1(wireFormat, o, bs);
  rc += tightMarshalString1(info.getClientId(), bs);
  rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);
  rc += tightMarshalString1(info.getSelector(), bs);
  rc += tightMarshalString1(info.getSubscriptionName(), bs);
  return rc + 0;
}
origin: apache/activemq

@Override
public SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c, ActiveMQDestination destination)
    throws SQLException, IOException {
  PreparedStatement s = null;
  ResultSet rs = null;
  try {
    s = c.getConnection().prepareStatement(this.statements.getFindAllDurableSubsStatement());
    s.setString(1, destination.getQualifiedName());
    rs = s.executeQuery();
    ArrayList<SubscriptionInfo> rc = new ArrayList<SubscriptionInfo>();
    while (rs.next()) {
      SubscriptionInfo subscription = new SubscriptionInfo();
      subscription.setDestination(destination);
      subscription.setSelector(rs.getString(1));
      subscription.setSubscriptionName(rs.getString(2));
      subscription.setClientId(rs.getString(3));
      subscription.setSubscribedDestination(ActiveMQDestination.createDestination(rs.getString(4),
          ActiveMQDestination.QUEUE_TYPE));
      rc.add(subscription);
    }
    return rc.toArray(new SubscriptionInfo[rc.size()]);
  } finally {
    close(rs);
    close(s);
  }
}
origin: apache/activemq

public ConsumerInfo createInactiveConsumerInfo(SubscriptionInfo info) {
  ConsumerInfo rc = new ConsumerInfo();
  rc.setSelector(info.getSelector());
  rc.setSubscriptionName(info.getSubscriptionName());
  rc.setDestination(info.getSubscribedDestination());
  rc.setConsumerId(createConsumerId());
  rc.setNoLocal(info.isNoLocal());
  return rc;
}
origin: apache/activemq

  /**
   * Write the booleans that this object uses to a BooleanStream
   */
  public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {

    SubscriptionInfo info = (SubscriptionInfo)o;

    super.looseMarshal(wireFormat, o, dataOut);
    looseMarshalString(info.getClientId(), dataOut);
    looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);
    looseMarshalString(info.getSelector(), dataOut);
    looseMarshalString(info.getSubcriptionName(), dataOut);
    looseMarshalNestedObject(wireFormat, (DataStructure)info.getSubscribedDestination(), dataOut);
    dataOut.writeBoolean(info.isNoLocal());

  }
}
origin: apache/activemq

public ObjectName registerSubscription(ConnectionContext context, Subscription sub) {
  String connectionClientId = context.getClientId();
  SubscriptionKey key = new SubscriptionKey(context.getClientId(), sub.getConsumerInfo().getSubscriptionName());
  try {
    ObjectName objectName = BrokerMBeanSupport.createSubscriptionName(brokerObjectName, connectionClientId, sub.getConsumerInfo());
    SubscriptionView view;
    if (sub.getConsumerInfo().getConsumerId().getConnectionId().equals("OFFLINE")) {
      SubscriptionInfo info = new SubscriptionInfo();
      info.setClientId(context.getClientId());
      info.setSubscriptionName(sub.getConsumerInfo().getSubscriptionName());
      info.setDestination(sub.getConsumerInfo().getDestination());
      info.setSelector(sub.getSelector());
      addInactiveSubscription(key, info, sub);
    } else {
      String userName = brokerService.isPopulateUserNameInMBeans() ? context.getUserName() : null;
      if (sub.getConsumerInfo().isDurable()) {
        view = new DurableSubscriptionView(this, brokerService, context.getClientId(), userName, sub);
origin: apache/activemq

/**
 * 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);
  SubscriptionInfo info = (SubscriptionInfo)o;
  info.setClientId(tightUnmarshalString(dataIn, bs));
  info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
  info.setSelector(tightUnmarshalString(dataIn, bs));
  info.setSubscriptionName(tightUnmarshalString(dataIn, bs));
  info.setSubscribedDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
}
origin: apache/activemq

/**
 * 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);
  SubscriptionInfo info = (SubscriptionInfo)o;
  info.setClientId(looseUnmarshalString(dataIn));
  info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));
  info.setSelector(looseUnmarshalString(dataIn));
  info.setSubcriptionName(looseUnmarshalString(dataIn));
  info.setSubscribedDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
  info.setNoLocal(dataIn.readBoolean());
}
origin: apache/activemq

if (info.isNetworkSubscription() && info.getDestination().isQueue() &&
    !configuration.isConduitNetworkQueueSubscriptions()) {
  return false;
  DestinationFilter filter = DestinationFilter.parseFilter(ds.getLocalInfo().getDestination());
  if (canConduit(ds) && filter.matches(info.getDestination())) {
    LOG.debug("{} {} with ids {} matched (add interest) {}", new Object[]{
        addProxyNetworkSubscriptionClientId(ds, info.getClientId(), info.getSubscriptionName());
      } else {
        ds.getDurableRemoteSubs().add(new SubscriptionInfo(info.getClientId(), info.getSubscriptionName()));
origin: apache/activemq

  subscription.setSelector(subscription.getConsumerInfo().getSelector());
  synchronized (consumers) {
    consumers.remove(subscription);
info = new SubscriptionInfo();
info.setClientId(clientId);
info.setSelector(subscription.getConsumerInfo().getSelector());
info.setSubscriptionName(subscriptionName);
info.setDestination(getActiveMQDestination());
info.setNoLocal(subscription.getConsumerInfo().isNoLocal());
info.setSubscribedDestination(subscription.getConsumerInfo().getDestination());
origin: apache/activemq

protected void configureDemandSubscription(ConsumerInfo info, DemandSubscription sub) throws IOException {
  if (AdvisorySupport.isConsumerAdvisoryTopic(info.getDestination()) ||
      AdvisorySupport.isVirtualDestinationConsumerAdvisoryTopic(info.getDestination())) {
    sub.getLocalInfo().setDispatchAsync(true);
  } else {
    sub.getLocalInfo().setDispatchAsync(configuration.isDispatchAsync());
  }
  configureConsumerPrefetch(sub.getLocalInfo());
  subscriptionMapByLocalId.put(sub.getLocalInfo().getConsumerId(), sub);
  subscriptionMapByRemoteId.put(sub.getRemoteInfo().getConsumerId(), sub);
  sub.setNetworkBridgeFilter(createNetworkBridgeFilter(info));
  if (!info.isDurable()) {
    // This works for now since we use a VM connection to the local broker.
    // may need to change if we ever subscribe to a remote broker.
    sub.getLocalInfo().setAdditionalPredicate(sub.getNetworkBridgeFilter());
  } else {
    sub.setLocalDurableSubscriber(new SubscriptionInfo(info.getClientId(), info.getSubscriptionName()));
  }
}
origin: apache/activemq

protected void unregisterSubscription(ObjectName key, boolean addToInactive) throws Exception {
  queueSubscribers.remove(key);
  topicSubscribers.remove(key);
  temporaryQueueSubscribers.remove(key);
  temporaryTopicSubscribers.remove(key);
  if (registeredMBeans.remove(key)) {
    try {
      managementContext.unregisterMBean(key);
    } catch (Throwable e) {
      LOG.warn("Failed to unregister MBean {}", key);
      LOG.debug("Failure reason: ", e);
    }
  }
  DurableSubscriptionView view = (DurableSubscriptionView)durableTopicSubscribers.remove(key);
  if (view != null) {
    // need to put this back in the inactive list
    SubscriptionKey subscriptionKey = new SubscriptionKey(view.getClientId(), view.getSubscriptionName());
    if (addToInactive) {
      SubscriptionInfo info = new SubscriptionInfo();
      info.setClientId(subscriptionKey.getClientId());
      info.setSubscriptionName(subscriptionKey.getSubscriptionName());
      info.setDestination(new ActiveMQTopic(view.getDestinationName()));
      info.setSelector(view.getSelector());
      addInactiveSubscription(subscriptionKey, info, (brokerService.isKeepDurableSubsActive() ? view.subscription : null));
    }
  }
}
origin: apache/activemq

BrokerId[] path = info.getBrokerPath();
if (info.isBrowser()) {
  LOG.debug("{} Ignoring sub from {}, browsers explicitly suppressed", configuration.getBrokerName(), remoteBrokerName);
  return;
if (!isPermissableDestination(info.getDestination())) {
  addConsumerInfo(info);
} else {
  synchronized (brokerService.getVmConnectorURI()) {
    addConsumerInfo(info);
final SubscriptionInfo subscriptionInfo = new SubscriptionInfo(info.getClientId(), info.getSubscriptionName());
final boolean proxyBridgeSub = isProxyBridgeSubscription(subscriptionInfo.getClientId(),
    subscriptionInfo.getSubscriptionName());
for (Iterator<DemandSubscription> i = subscriptionMapByLocalId.values().iterator(); i.hasNext(); ) {
  DemandSubscription ds = i.next();
    subscriptionInfo.setClientId(getProxyBridgeClientId(subscriptionInfo.getClientId()));
    if (ds.getDurableRemoteSubs().contains(subscriptionInfo)) {
      ds.getDurableRemoteSubs().remove(subscriptionInfo);
origin: org.apache.activemq/activemq-all

  protected List<SubscriptionInfo> lookupSubscription(String clientId) throws MQTTProtocolException {
    List<SubscriptionInfo> result = new ArrayList<SubscriptionInfo>();
    RegionBroker regionBroker;

    try {
      regionBroker = (RegionBroker) brokerService.getBroker().getAdaptor(RegionBroker.class);
    } catch (Exception e) {
      throw new MQTTProtocolException("Error recovering durable subscriptions: " + e.getMessage(), false, e);
    }

    final TopicRegion topicRegion = (TopicRegion) regionBroker.getTopicRegion();
    List<DurableTopicSubscription> subscriptions = topicRegion.lookupSubscriptions(clientId);
    if (subscriptions != null) {
      for (DurableTopicSubscription subscription : subscriptions) {
        LOG.debug("Recovered durable sub:{} on connect", subscription);

        SubscriptionInfo info = new SubscriptionInfo();

        info.setDestination(subscription.getActiveMQDestination());
        info.setSubcriptionName(subscription.getSubscriptionKey().getSubscriptionName());
        info.setClientId(clientId);

        result.add(info);
      }
    }

    return result;
  }
}
origin: apache/activemq

/**
 * @return the destination name
 */
@Override
public String getDestinationName() {
  return subscriptionInfo.getDestination().getPhysicalName();
}
origin: apache/activemq

protected void addConsumerInfo(final ConsumerInfo consumerInfo) throws IOException {
  ConsumerInfo info = consumerInfo.copy();
  addRemoteBrokerToBrokerPath(info);
  DemandSubscription sub = createDemandSubscription(info);
  if (sub != null) {
    if (duplicateSuppressionIsRequired(sub)) {
      undoMapRegistration(sub);
    } else {
      if (consumerInfo.isDurable()) {
        //Handle the demand generated by proxy network subscriptions
        //The broker path is case is normal
        if (isProxyNSConsumerBrokerPath(sub.getRemoteInfo()) &&
            info.getSubscriptionName() != null && info.getSubscriptionName().startsWith(DURABLE_SUB_PREFIX)) {
          final BrokerId[] path = info.getBrokerPath();
          addProxyNetworkSubscriptionBrokerPath(sub, path, consumerInfo.getSubscriptionName());
        //This is the durable sync case on broker restart
        } else if (isProxyNSConsumerClientId(sub.getRemoteInfo().getClientId()) &&
            isProxyBridgeSubscription(info.getClientId(), info.getSubscriptionName())) {
          addProxyNetworkSubscriptionClientId(sub, sub.getRemoteInfo().getClientId(), consumerInfo.getSubscriptionName());
        } else {
          sub.getDurableRemoteSubs().add(new SubscriptionInfo(sub.getRemoteInfo().getClientId(), consumerInfo.getSubscriptionName()));
        }
      }
      addSubscription(sub);
      LOG.debug("{} new demand subscription: {}", configuration.getBrokerName(), sub);
    }
  }
}
origin: apache/activemq

/**
 * Destroys the durable subscription so that messages will no longer be
 * stored for this subscription
 */
@Override
public void destroy() throws Exception {
  RemoveSubscriptionInfo info = new RemoveSubscriptionInfo();
  info.setClientId(clientId);
  info.setSubscriptionName(subscriptionInfo.getSubscriptionName());
  ConnectionContext context = new ConnectionContext();
  context.setBroker(broker);
  context.setClientId(clientId);
  brokerService.getBroker().removeSubscription(context, info);
}
origin: apache/activemq

private void cleanupDurableSub(final DemandSubscription ds,
    Iterator<DemandSubscription> i) throws IOException {
  if (ds != null && ds.getLocalDurableSubscriber() != null && ds.getDurableRemoteSubs().isEmpty()
      && ds.getForcedDurableConsumersSize() == 0) {
    // deactivate subscriber
    RemoveInfo removeInfo = new RemoveInfo(ds.getLocalInfo().getConsumerId());
    localBroker.oneway(removeInfo);
    // remove subscriber
    RemoveSubscriptionInfo sending = new RemoveSubscriptionInfo();
    sending.setClientId(localClientId);
    sending.setSubscriptionName(ds.getLocalDurableSubscriber().getSubscriptionName());
    sending.setConnectionId(this.localConnectionInfo.getConnectionId());
    localBroker.oneway(sending);
    //remove subscriber from map
    i.remove();
  }
}
origin: apache/activemq

private boolean hasSelectorChanged(SubscriptionInfo info1, ConsumerInfo info2) {
  if (info1.getSelector() != null ^ info2.getSelector() != null) {
    return true;
  }
  if (info1.getSelector() != null && !info1.getSelector().equals(info2.getSelector())) {
    return true;
  }
  return false;
}
origin: apache/activemq

/**
 * Searches the set of subscriptions from the given persistence adapter and returns all those
 * that belong to the given ClientId value.
 *
 * @param adapter
 *        the persistence adapter instance to search within.
 * @param clientId
 *        the client ID value used to filter the subscription set.
 *
 * @return a list of all subscriptions belonging to the given client.
 *
 * @throws IOException if an error occurs while listing the stored subscriptions.
 */
static public List<SubscriptionInfo> listSubscriptions(PersistenceAdapter adapter, String clientId) throws IOException {
  ArrayList<SubscriptionInfo> rc = new ArrayList<SubscriptionInfo>();
  for (ActiveMQDestination destination : adapter.getDestinations()) {
    if (destination.isTopic()) {
      TopicMessageStore store = adapter.createTopicMessageStore((ActiveMQTopic) destination);
      for (SubscriptionInfo sub : store.getAllSubscriptions()) {
        if (clientId == sub.getClientId() || clientId.equals(sub.getClientId())) {
          rc.add(sub);
        }
      }
    }
  }
  return rc;
}
origin: apache/activemq

@Override
public void addSubscription(SubscriptionInfo subscriptionInfo, boolean retroactive) throws IOException {
  String subscriptionKey = subscriptionKey(subscriptionInfo.getClientId(), subscriptionInfo
      .getSubscriptionName());
  KahaSubscriptionCommand command = new KahaSubscriptionCommand();
  command.setDestination(dest);
  command.setSubscriptionKey(subscriptionKey.toString());
  command.setRetroactive(retroactive);
  org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(subscriptionInfo);
  command.setSubscriptionInfo(new Buffer(packet.getData(), packet.getOffset(), packet.getLength()));
  store(command, isEnableJournalDiskSyncs() && true, null, null);
  this.subscriptionCount.incrementAndGet();
}
org.apache.activemq.commandSubscriptionInfo

Javadoc

Used to represent a durable subscription.

Most used methods

  • getClientId
  • getSubscriptionName
  • <init>
  • getSelector
  • setClientId
  • setDestination
  • getDestination
    This is the a resolved destination that the subscription is receiving messages from. This will never
  • getSubscribedDestination
    The destination the client originally subscribed to.. This may not match the getDestination method i
  • setSelector
  • setSubscribedDestination
  • setSubscriptionName
  • getSubcriptionName
  • setSubscriptionName,
  • getSubcriptionName,
  • setSubcriptionName,
  • isNoLocal,
  • setNoLocal

Popular in Java

  • Running tasks concurrently on multiple threads
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onRequestPermissionsResult (Fragment)
  • setScale (BigDecimal)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now