本文整理汇总了Java中org.apache.activemq.command.ConsumerInfo.isDurable方法的典型用法代码示例。如果您正苦于以下问题:Java ConsumerInfo.isDurable方法的具体用法?Java ConsumerInfo.isDurable怎么用?Java ConsumerInfo.isDurable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.command.ConsumerInfo
的用法示例。
在下文中一共展示了ConsumerInfo.isDurable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToAlreadyInterestedConsumers
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
protected boolean addToAlreadyInterestedConsumers(ConsumerInfo info) {
// search through existing subscriptions and see if we have a match
if (info.isNetworkSubscription()) {
return false;
}
boolean matched = false;
for (DemandSubscription ds : subscriptionMapByLocalId.values()) {
DestinationFilter filter = DestinationFilter.parseFilter(ds.getLocalInfo().getDestination());
if (canConduit(ds) && filter.matches(info.getDestination())) {
LOG.debug("{} {} with ids {} matched (add interest) {}", new Object[]{
configuration.getBrokerName(), info, info.getNetworkConsumerIds(), ds
});
// add the interest in the subscription
if (!info.isDurable()) {
ds.add(info.getConsumerId());
} else {
ds.getDurableRemoteSubs().add(new SubscriptionInfo(info.getClientId(), info.getSubscriptionName()));
}
matched = true;
// continue - we want interest to any existing DemandSubscriptions
}
}
return matched;
}
示例2: createDemandSubscription
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
protected DemandSubscription createDemandSubscription(ConsumerInfo info) throws IOException {
if (addToAlreadyInterestedConsumers(info)) {
return null; // don't want this subscription added
}
//add our original id to ourselves
info.addNetworkConsumerId(info.getConsumerId());
if (info.isDurable()) {
// 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);
return doCreateDemandSubscription(info);
}
示例3: 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;
}
}
示例4: createSubscriptionName
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public static ObjectName createSubscriptionName(String brokerObjectName, String connectionClientId, ConsumerInfo info) throws MalformedObjectNameException {
String objectNameStr = brokerObjectName;
objectNameStr += createDestinationProperties(info.getDestination()) + ",endpoint=Consumer";
objectNameStr += ",clientId=" + JMXSupport.encodeObjectNamePart(connectionClientId);
objectNameStr += ",consumerId=";
if (info.isDurable()){
objectNameStr += "Durable(" + JMXSupport.encodeObjectNamePart(connectionClientId + ":" + info.getSubscriptionName()) +")";
} else {
objectNameStr += JMXSupport.encodeObjectNamePart(info.getConsumerId().toString());
}
return new ObjectName(objectNameStr);
}
示例5: removeConsumer
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
if (info.isDurable()) {
SubscriptionKey key = new SubscriptionKey(context.getClientId(), info.getSubscriptionName());
DurableTopicSubscription sub = durableSubscriptions.get(key);
if (sub != null) {
sub.deactivate(keepDurableSubsActive);
}
} else {
super.removeConsumer(context, info);
}
}
示例6: isDurable
import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
/**
* @return whether or not the subscriber is durable (persistent)
*/
@Override
public boolean isDurable() {
ConsumerInfo info = getConsumerInfo();
return info != null ? info.isDurable() : false;
}
示例7: 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);
}
}