当前位置: 首页>>代码示例>>Java>>正文


Java ConsumerInfo.getDestination方法代码示例

本文整理汇总了Java中org.apache.activemq.command.ConsumerInfo.getDestination方法的典型用法代码示例。如果您正苦于以下问题:Java ConsumerInfo.getDestination方法的具体用法?Java ConsumerInfo.getDestination怎么用?Java ConsumerInfo.getDestination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.command.ConsumerInfo的用法示例。


在下文中一共展示了ConsumerInfo.getDestination方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addConsumer

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
/**
 * Add new message consumer.
 *
 * @param context
 * @param info
 * @return
 * @throws Exception
 * @see org.apache.activemq.broker.BrokerFilter#addConsumer(org.apache.activemq.broker.ConnectionContext, org.apache.activemq.command.ConsumerInfo)
 */
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {

    ActiveMQDestination dest = info.getDestination();
    Connection conn = context.getConnection();
    if (dest != null) {
        String destName = info.getDestination().getPhysicalName();
        String clientId = context.getClientId();
        String allowedDest = userMap.get(clientId);

        logger.info(">>> Got Consumer Add request { Destination: " + destName
                + ", Remote Address: " + conn.getRemoteAddress()
                + ", ClientID: " + clientId
                + " }");
        if (allowedDest != null && (allowedDest.equals("*") || allowedDest.equals(destName) || destName.startsWith("ActiveMQ"))) {
            logger.info(">>> Subscription allowed");
        } else {
            logger.error(">>> Destination not allowed. Subscription denied!");
            throw new CmsAuthException(">>> Subscription denied!");
        }
    } else {
        logger.error("<<< Got Consumer Add request from Remote Address:" + conn.getRemoteAddress() + ". But destination is NULL.");
    }
    return super.addConsumer(context, info);
}
 
开发者ID:oneops,项目名称:oneops,代码行数:34,代码来源:OneopsAuthBroker.java

示例2: createSubscription

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info) throws JMSException {
    if (info.isDurable()) {
        throw new JMSException("A durable subscription cannot be created for a temporary topic.");
    }
    try {
        TopicSubscription answer = new TopicSubscription(broker, context, info, usageManager);
        // lets configure the subscription depending on the destination
        ActiveMQDestination destination = info.getDestination();
        if (destination != null && broker.getDestinationPolicy() != null) {
            PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination);
            if (entry != null) {
                entry.configure(broker, usageManager, answer);
            }
        }
        answer.init();
        return answer;
    } catch (Exception e) {
        LOG.error("Failed to create TopicSubscription ", e);
        JMSException jmsEx = new JMSException("Couldn't create TopicSubscription");
        jmsEx.setLinkedException(e);
        throw jmsEx;
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:24,代码来源:TempTopicRegion.java

示例3: addConsumer

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
    final SecurityContext securityContext = checkSecurityContext(context);

    Set<?> allowedACLs = null;
    if (!info.getDestination().isTemporary()) {
        allowedACLs = authorizationMap.getReadACLs(info.getDestination());
    } else {
        allowedACLs = authorizationMap.getTempDestinationReadACLs();
    }

    if (!securityContext.isBrokerContext() && allowedACLs != null && !securityContext.isInOneOf(allowedACLs) ) {
        throw new SecurityException("User " + securityContext.getUserName() + " is not authorized to read from: " + info.getDestination());
    }
    securityContext.getAuthorizedReadDests().put(info.getDestination(), info.getDestination());

    /*
     * Need to think about this a little more. We could do per message
     * security checking to implement finer grained security checking. For
     * example a user can only see messages with price>1000 . Perhaps this
     * should just be another additional broker filter that installs this
     * type of feature. If we did want to do that, then we would install a
     * predicate. We should be careful since there may be an existing
     * predicate already assigned and the consumer info may be sent to a
     * remote broker, so it also needs to support being marshaled.
     * info.setAdditionalPredicate(new BooleanExpression() { public boolean
     * matches(MessageEvaluationContext message) throws JMSException { if(
     * !subject.getAuthorizedReadDests().contains(message.getDestination()) ) {
     * Set allowedACLs =
     * authorizationMap.getReadACLs(message.getDestination());
     * if(allowedACLs!=null && !subject.isInOneOf(allowedACLs)) return
     * false; subject.getAuthorizedReadDests().put(message.getDestination(),
     * message.getDestination()); } return true; } public Object
     * evaluate(MessageEvaluationContext message) throws JMSException {
     * return matches(message) ? Boolean.TRUE : Boolean.FALSE; } });
     */

    return super.addConsumer(context, info);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:40,代码来源:AuthorizationBroker.java

示例4: removeConsumer

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
    super.removeConsumer(context, info);

    // Don't advise advisory topics.
    ActiveMQDestination dest = info.getDestination();
    if (!AdvisorySupport.isAdvisoryTopic(dest)) {
        ActiveMQTopic topic = AdvisorySupport.getConsumerAdvisoryTopic(dest);
        consumers.remove(info);
        if (!dest.isTemporary() || destinations.containsKey(dest)) {
            fireConsumerAdvisory(context,dest, topic, info.createRemoveCommand());
        }
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:15,代码来源:AdvisoryBroker.java

示例5: getDestinationName

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
/**
 * @return the destination name
 */
@Override
public String getDestinationName() {
    ConsumerInfo info = getConsumerInfo();
    if (info != null) {
        ActiveMQDestination dest = info.getDestination();
        return dest.getPhysicalName();
    }
    return "NOTSET";
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:13,代码来源:SubscriptionView.java

示例6: isDestinationQueue

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
/**
 * @return true if the destination is a Queue
 */
@Override
public boolean isDestinationQueue() {
    ConsumerInfo info = getConsumerInfo();
    if (info != null) {
        ActiveMQDestination dest = info.getDestination();
        return dest.isQueue();
    }
    return false;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:13,代码来源:SubscriptionView.java

示例7: isDestinationTopic

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
/**
 * @return true of the destination is a Topic
 */
@Override
public boolean isDestinationTopic() {
    ConsumerInfo info = getConsumerInfo();
    if (info != null) {
        ActiveMQDestination dest = info.getDestination();
        return dest.isTopic();
    }
    return false;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:13,代码来源:SubscriptionView.java

示例8: isDestinationTemporary

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
/**
 * @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;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:13,代码来源:SubscriptionView.java

示例9: addConsumer

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
    ActiveMQDestination destination = info.getDestination();
    if (destinationInterceptor != null) {
        destinationInterceptor.create(this, context, destination);
    }
    inactiveDestinationsPurgeLock.readLock().lock();
    try {
        return getRegion(destination).addConsumer(context, info);
    } finally {
        inactiveDestinationsPurgeLock.readLock().unlock();
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:14,代码来源:RegionBroker.java

示例10: removeConsumer

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
    ActiveMQDestination destination = info.getDestination();
    inactiveDestinationsPurgeLock.readLock().lock();
    try {
        getRegion(destination).removeConsumer(context, info);
    } finally {
        inactiveDestinationsPurgeLock.readLock().unlock();
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:11,代码来源:RegionBroker.java

示例11: createConsumer

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public List<AMQConsumer> createConsumer(ConsumerInfo info,
                                        SlowConsumerDetectionListener slowConsumerDetectionListener) throws Exception {
   //check destination
   ActiveMQDestination dest = info.getDestination();
   ActiveMQDestination[] dests = null;
   if (dest.isComposite()) {
      dests = dest.getCompositeDestinations();
   } else {
      dests = new ActiveMQDestination[]{dest};
   }

   List<AMQConsumer> consumersList = new java.util.LinkedList<>();

   for (ActiveMQDestination openWireDest : dests) {
      boolean isInternalAddress = false;
      if (AdvisorySupport.isAdvisoryTopic(dest)) {
         if (!connection.isSuppportAdvisory()) {
            continue;
         }
         isInternalAddress = connection.isSuppressInternalManagementObjects();
      }
      if (openWireDest.isQueue()) {
         SimpleString queueName = new SimpleString(convertWildcard(openWireDest.getPhysicalName()));

         if (!checkAutoCreateQueue(queueName, openWireDest.isTemporary())) {
            throw new InvalidDestinationException("Destination doesn't exist: " + queueName);
         }
      }
      AMQConsumer consumer = new AMQConsumer(this, openWireDest, info, scheduledPool, isInternalAddress);

      long nativeID = consumerIDGenerator.generateID();
      consumer.init(slowConsumerDetectionListener, nativeID);
      consumersList.add(consumer);
   }

   return consumersList;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:38,代码来源:AMQSession.java

示例12: addConsumer

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
    if (info.isDurable()) {
        ActiveMQDestination destination = info.getDestination();
        if (!destination.isPattern()) {
            // Make sure the destination is created.
            lookup(context, destination,true);
        }
        String clientId = context.getClientId();
        String subscriptionName = info.getSubscriptionName();
        SubscriptionKey key = new SubscriptionKey(clientId, subscriptionName);
        DurableTopicSubscription sub = durableSubscriptions.get(key);
        if (sub != null) {
            if (sub.isActive()) {
                throw new JMSException("Durable consumer is in use for client: " + clientId + " and subscriptionName: " + subscriptionName);
            }
            // Has the selector changed??
            if (hasDurableSubChanged(info, sub.getConsumerInfo())) {
                // Remove the consumer first then add it.
                durableSubscriptions.remove(key);
                destinationsLock.readLock().lock();
                try {
                    for (Destination dest : destinations.values()) {
                        //Account for virtual destinations
                        if (dest instanceof Topic){
                            Topic topic = (Topic)dest;
                            topic.deleteSubscription(context, key);
                        }
                    }
                } finally {
                    destinationsLock.readLock().unlock();
                }
                super.removeConsumer(context, sub.getConsumerInfo());
                super.addConsumer(context, info);
                sub = durableSubscriptions.get(key);
            } else {
                // Change the consumer id key of the durable sub.
                if (sub.getConsumerInfo().getConsumerId() != null) {
                    subscriptions.remove(sub.getConsumerInfo().getConsumerId());
                }
                subscriptions.put(info.getConsumerId(), sub);
            }
        } else {
            super.addConsumer(context, info);
            sub = durableSubscriptions.get(key);
            if (sub == null) {
                throw new JMSException("Cannot use the same consumerId: " + info.getConsumerId() + " for two different durable subscriptions clientID: " + key.getClientId()
                                       + " subscriberName: " + key.getSubscriptionName());
            }
        }
        sub.activate(usageManager, context, info, broker);
        return sub;
    } else {
        return super.addConsumer(context, info);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:57,代码来源:TopicRegion.java


注:本文中的org.apache.activemq.command.ConsumerInfo.getDestination方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。