本文整理汇总了Java中org.apache.activemq.broker.ConnectionContext.setClientId方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionContext.setClientId方法的具体用法?Java ConnectionContext.setClientId怎么用?Java ConnectionContext.setClientId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.broker.ConnectionContext
的用法示例。
在下文中一共展示了ConnectionContext.setClientId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDurableSubscriber
import org.apache.activemq.broker.ConnectionContext; //导入方法依赖的package包/类
@Override
public ObjectName createDurableSubscriber(String clientId, String subscriberName, String topicName,
String selector) throws Exception {
ConnectionContext context = new ConnectionContext();
context.setBroker(safeGetBroker());
context.setClientId(clientId);
ConsumerInfo info = new ConsumerInfo();
ConsumerId consumerId = new ConsumerId();
consumerId.setConnectionId(clientId);
consumerId.setSessionId(sessionIdCounter.incrementAndGet());
consumerId.setValue(0);
info.setConsumerId(consumerId);
info.setDestination(new ActiveMQTopic(topicName));
info.setSubscriptionName(subscriberName);
info.setSelector(selector);
Subscription subscription = safeGetBroker().addConsumer(context, info);
safeGetBroker().removeConsumer(context, info);
if (subscription != null) {
return subscription.getObjectName();
}
return null;
}
示例2: destroy
import org.apache.activemq.broker.ConnectionContext; //导入方法依赖的package包/类
/**
* Destroys the durable subscription so that messages will no longer be
* stored for this subscription
*/
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);
}
示例3: destroy
import org.apache.activemq.broker.ConnectionContext; //导入方法依赖的package包/类
/**
* Destroys the durable subscription so that messages will no longer be
* stored for this subscription
*/
public void destroy() throws Exception {
RemoveSubscriptionInfo info = new RemoveSubscriptionInfo();
info.setClientId(clientId);
info.setSubscriptionName(subscriptionName);
ConnectionContext context = new ConnectionContext();
context.setBroker(broker);
context.setClientId(clientId);
brokerService.getBroker().removeSubscription(context, info);
}
示例4: destroyDurableSubscriber
import org.apache.activemq.broker.ConnectionContext; //导入方法依赖的package包/类
@Override
public void destroyDurableSubscriber(String clientId, String subscriberName) throws Exception {
RemoveSubscriptionInfo info = new RemoveSubscriptionInfo();
info.setClientId(clientId);
info.setSubscriptionName(subscriberName);
ConnectionContext context = new ConnectionContext();
context.setBroker(safeGetBroker());
context.setClientId(clientId);
brokerService.getBroker().removeSubscription(context, info);
}
示例5: doDirectUnsubscribe
import org.apache.activemq.broker.ConnectionContext; //导入方法依赖的package包/类
public void doDirectUnsubscribe(boolean restart) throws Exception {
createSubscriptions();
createAdvisorySubscription();
Thread.sleep(1000);
assertCount(100, 0);
if (restart) {
restartBroker();
createAdvisorySubscription();
assertCount(100, 0);
}
for (int i = 0; i < 100; i++) {
RemoveSubscriptionInfo info = new RemoveSubscriptionInfo();
info.setClientId(getName());
info.setSubscriptionName("SubsId" + i);
ConnectionContext context = new ConnectionContext();
context.setBroker(broker.getRegionBroker());
context.setClientId(getName());
broker.getBroker().removeSubscription(context, info);
if (i % 20 == 0) {
Thread.sleep(1000);
assertCount(100 - i - 1, 0);
}
}
assertCount(0, 0);
if (restart) {
restartBroker();
createAdvisorySubscription();
assertCount(0, 0);
}
}