本文整理汇总了Java中org.apache.activemq.broker.region.RegionBroker类的典型用法代码示例。如果您正苦于以下问题:Java RegionBroker类的具体用法?Java RegionBroker怎么用?Java RegionBroker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegionBroker类属于org.apache.activemq.broker.region包,在下文中一共展示了RegionBroker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeSubscription
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
@Override
public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception {
SubscriptionKey key = new SubscriptionKey(context.getClientId(), info.getSubscriptionName());
DurableTopicSubscription sub = ((TopicRegion)((RegionBroker)next).getTopicRegion()).getDurableSubscription(key);
super.removeSubscription(context, info);
if (sub == null) {
LOG.warn("We cannot send an advisory message for a durable sub removal when we don't know about the durable sub");
return;
}
ActiveMQDestination dest = sub.getConsumerInfo().getDestination();
// Don't advise advisory topics.
if (!AdvisorySupport.isAdvisoryTopic(dest)) {
ActiveMQTopic topic = AdvisorySupport.getConsumerAdvisoryTopic(dest);
fireConsumerAdvisory(context, dest, topic, info);
}
}
示例2: testLoadTempAdvisoryTopics
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
public void testLoadTempAdvisoryTopics() throws Exception {
for (int i = 0; i < MESSAGE_COUNT; i++) {
TemporaryTopic tempTopic = session.createTemporaryTopic();
MessageConsumer consumer = session.createConsumer(tempTopic);
MessageProducer producer = session.createProducer(tempTopic);
consumer.close();
producer.close();
tempTopic.delete();
}
AdvisoryBroker ab = (AdvisoryBroker) broker.getBroker().getAdaptor(AdvisoryBroker.class);
assertTrue(ab.getAdvisoryDestinations().size() == 0);
assertTrue(ab.getAdvisoryConsumers().size() == 0);
assertTrue(ab.getAdvisoryProducers().size() == 0);
RegionBroker rb = (RegionBroker) broker.getBroker().getAdaptor(RegionBroker.class);
for (Destination dest : rb.getDestinationMap().values()) {
LOG.debug("Destination: {}", dest);
}
// there should be at least 2 destinations - advisories -
// 1 for the connection + 1 generic ones
assertTrue("Should be at least 2 destinations", rb.getDestinationMap().size() > 2);
}
示例3: getRegionSubscriptions
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
protected final Collection<Subscription> getRegionSubscriptions(ActiveMQDestination dest) {
RegionBroker region_broker = (RegionBroker) brokerService.getRegionBroker();
Region region;
Collection<Subscription> subs;
region = null;
switch (dest.getDestinationType()) {
case ActiveMQDestination.QUEUE_TYPE:
region = region_broker.getQueueRegion();
break;
case ActiveMQDestination.TOPIC_TYPE:
region = region_broker.getTopicRegion();
break;
case ActiveMQDestination.TEMP_QUEUE_TYPE:
region = region_broker.getTempQueueRegion();
break;
case ActiveMQDestination.TEMP_TOPIC_TYPE:
region = region_broker.getTempTopicRegion();
break;
}
if (region instanceof AbstractRegion) {
subs = ((AbstractRegion) region).getSubscriptions().values();
} else {
subs = null;
}
return subs;
}
示例4: rollbackStatsOnDuplicate
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
@Override
void rollbackStatsOnDuplicate(KahaDestination commandDestination) {
if (brokerService != null) {
RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker();
if (regionBroker != null) {
Set<Destination> destinationSet = regionBroker.getDestinations(convert(commandDestination));
for (Destination destination : destinationSet) {
destination.getDestinationStatistics().getMessages().decrement();
destination.getDestinationStatistics().getEnqueues().decrement();
}
}
}
}
示例5: newRegionBroker
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
public static RegionBroker newRegionBroker(ArtemisBrokerWrapper broker) {
Broker brokerProxy = null;
try {
brokerProxy = new RegionBrokerProxy(broker);
RegionBroker regionBroker = Mockito.mock(RegionBroker.class, delegatesTo(brokerProxy));
return regionBroker;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例6: testLoadTempAdvisoryQueues
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
public void testLoadTempAdvisoryQueues() throws Exception {
for (int i = 0; i < MESSAGE_COUNT; i++) {
TemporaryQueue tempQueue = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(tempQueue);
MessageProducer producer = session.createProducer(tempQueue);
consumer.close();
producer.close();
tempQueue.delete();
}
AdvisoryBroker ab = (AdvisoryBroker) broker.getBroker().getAdaptor(AdvisoryBroker.class);
assertTrue(ab.getAdvisoryDestinations().size() == 0);
assertTrue(ab.getAdvisoryConsumers().size() == 0);
assertTrue(ab.getAdvisoryProducers().size() == 0);
RegionBroker rb = (RegionBroker) broker.getBroker().getAdaptor(RegionBroker.class);
for (Destination dest : rb.getDestinationMap().values()) {
LOG.debug("Destination: {}", dest);
}
// there should be at least 2 destinations - advisories -
// 1 for the connection + 1 generic ones
assertTrue("Should be at least 2 destinations", rb.getDestinationMap().size() > 2);
}
示例7: validateConsumerPrefetch
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
private void validateConsumerPrefetch(String destination, long expectedCount) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
for (org.apache.activemq.broker.region.Destination dest : regionBroker.getQueueRegion().getDestinationMap().values()) {
if (dest.getName().equals(destination)) {
DestinationStatistics stats = dest.getDestinationStatistics();
LOG.info(">>>> inflight for : " + dest.getName() + ": " + stats.getInflight().getCount());
assertEquals("inflight for: " + dest.getName() + ": " + stats.getInflight().getCount() + " matches", expectedCount, stats.getInflight().getCount());
}
}
}
示例8: getDestinationMap
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
private static Map<ActiveMQDestination, org.apache.activemq.broker.region.Destination> getDestinationMap(
BrokerService target,
ActiveMQDestination destination) {
RegionBroker regionBroker = (RegionBroker) target.getRegionBroker();
if (destination.isTemporary()) {
return destination.isQueue() ? regionBroker.getTempQueueRegion().getDestinationMap() : regionBroker.getTempTopicRegion().getDestinationMap();
}
return destination.isQueue() ? regionBroker.getQueueRegion().getDestinationMap() : regionBroker.getTopicRegion().getDestinationMap();
}
示例9: verifyConsumerCount
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
private void verifyConsumerCount(BrokerService broker, int count, final Destination dest) throws Exception {
final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
waitFor(new Condition() {
@Override
public boolean isSatisified() throws Exception {
return !regionBroker.getDestinations(ActiveMQDestination.transform(dest)).isEmpty();
}
});
Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next();
LOG.info("Verify: consumer count on " + broker.getBrokerName() + " matches:" + count + ", val:" + internalQueue.getConsumers().size());
assertEquals("consumer count on " + broker.getBrokerName() + " matches for q: " + internalQueue, count, internalQueue.getConsumers().size());
}
示例10: logConsumerCount
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
private void logConsumerCount(BrokerService broker, int count, final Destination dest) throws Exception {
final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
waitFor(new Condition() {
@Override
public boolean isSatisified() throws Exception {
return !regionBroker.getDestinations(ActiveMQDestination.transform(dest)).isEmpty();
}
});
Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next();
LOG.info("Verify: consumer count on " + broker.getBrokerName() + " matches:" + count + ", val:" + internalQueue.getConsumers().size());
}
示例11: verifyConsumePriority
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
private void verifyConsumePriority(BrokerService broker, byte expectedPriority, Destination dest) throws Exception {
RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next();
for (Subscription consumer : internalQueue.getConsumers()) {
assertEquals("consumer on " + broker.getBrokerName() + " matches priority: " + internalQueue, expectedPriority, consumer.getConsumerInfo().getPriority());
}
}
示例12: testQueueNetworkWithConsumerFull
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
public void testQueueNetworkWithConsumerFull() throws Exception {
bridgeAllBrokers();
startAllBrokers();
Destination dest = createDestination("TEST.FOO", false);
sendMessages("Broker1", dest, 50);
CountDownLatch latch = new CountDownLatch(MESSAGE_COUNT);
createConsumer("Broker2", dest, latch);
assertConsumersConnect("Broker1", dest, 1, 30000);
sendMessages("Broker1", dest, MESSAGE_COUNT - 50);
// Wait for messages to be delivered
assertTrue("Missing " + latch.getCount() + " messages", latch.await(45, TimeUnit.SECONDS));
// verify stats, all messages acked
BrokerService broker1 = brokers.get("Broker1").broker;
RegionBroker regionBroker = (RegionBroker) broker1.getRegionBroker();
// give the acks a chance to flow
Thread.sleep(2000);
Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next();
assertTrue("All messages are consumed and acked from source:" + internalQueue, internalQueue.getMessages().isEmpty());
assertEquals("messages source:" + internalQueue, 0, internalQueue.getDestinationStatistics().getMessages().getCount());
assertEquals("inflight source:" + internalQueue, 0, internalQueue.getDestinationStatistics().getInflight().getCount());
}
示例13: waitForMinTopicRegionConsumerCount
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
protected void waitForMinTopicRegionConsumerCount(final String name, final int count) throws Exception {
final BrokerService broker = brokers.get(name).broker;
final TopicRegion topicRegion = (TopicRegion) ((RegionBroker) broker.getRegionBroker()).getTopicRegion();
assertTrue("found expected consumers in topic region of" + name, Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
LOG.info("topic consumers: " + name + ", " + topicRegion.getSubscriptions().toString());
return topicRegion.getSubscriptions().size() >= count;
}
}));
}
示例14: destinationExists
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
private boolean destinationExists(Destination dest) throws Exception {
RegionBroker rb = (RegionBroker) brokerService.getBroker().getAdaptor(RegionBroker.class);
return rb.getTopicRegion().getDestinationMap().containsKey(dest) || rb.getQueueRegion().getDestinationMap().containsKey(dest)
|| rb.getTempTopicRegion().getDestinationMap().containsKey(dest) || rb.getTempQueueRegion().getDestinationMap().containsKey(dest);
}
示例15: countBrokerTemporaryQueues
import org.apache.activemq.broker.region.RegionBroker; //导入依赖的package包/类
private int countBrokerTemporaryQueues() throws Exception {
return ((RegionBroker) brokerService.getRegionBroker()).getTempQueueRegion().getDestinationMap().size();
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:4,代码来源:PooledConnectionFactoryWithTemporaryDestinationsTest.java