本文整理汇总了Java中org.apache.activemq.broker.jmx.BrokerViewMBean类的典型用法代码示例。如果您正苦于以下问题:Java BrokerViewMBean类的具体用法?Java BrokerViewMBean怎么用?Java BrokerViewMBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BrokerViewMBean类属于org.apache.activemq.broker.jmx包,在下文中一共展示了BrokerViewMBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBridgeRegistration
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
@Test
public void testBridgeRegistration() throws Exception {
BrokerService broker = new BrokerService();
broker.setBrokerName(BROKER_NAME);
broker.setUseJmx(true); // explicitly set this so no funny issues
broker.start();
broker.waitUntilStarted();
// now create network connector over JMX
ObjectName brokerObjectName = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + BROKER_NAME);
BrokerViewMBean proxy = (BrokerViewMBean) broker.getManagementContext().newProxyInstance(brokerObjectName, BrokerViewMBean.class, true);
assertNotNull("We could not retrieve the broker from JMX", proxy);
// let's add the NC
String connectoName = proxy.addNetworkConnector("static:(tcp://localhost:61617)");
assertEquals("NC", connectoName);
// Make sure we can retrieve the NC through JMX
ObjectName networkConnectorObjectName = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + BROKER_NAME +
",connector=networkConnectors,networkConnectorName=" + connectoName);
NetworkConnectorViewMBean nc = (NetworkConnectorViewMBean) broker.getManagementContext().newProxyInstance(networkConnectorObjectName, NetworkConnectorViewMBean.class, true);
assertNotNull(nc);
assertEquals("NC", nc.getName());
}
示例2: getBrokerName
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
@Override
public String getBrokerName() throws MessageQueueJmxException {
String settingsName = settingsDao.getBrokerName();
String viewBeanName = "";
if (settingsName == null) {
settingsName = "";
}
BrokerViewMBean viewMBean;
viewMBean = getMBean(brokerViewBeanObjectName, BrokerViewMBean.class);
if (viewMBean != null) {
viewBeanName = viewMBean.getBrokerName();
if (!StringUtils.equals(settingsName, viewBeanName)) {
settingsName += " (" + viewBeanName + ")";
}
}
return settingsName;
}
示例3: getBrokerQueues
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
@Override
public Set<BrokerQueue> getBrokerQueues() throws MessageQueueJmxException {
Set<BrokerQueue> res = new HashSet<BrokerQueue>();
ObjectName[] queueObjects = new ObjectName[0];
BrokerViewMBean viewMBean = getMBean(brokerViewBeanObjectName, BrokerViewMBean.class);
if (viewMBean != null) {
queueObjects = viewMBean.getQueues();
}
for (ObjectName objectName : queueObjects) {
QueueViewMBean queue = getMBean(objectName, QueueViewMBean.class);
BrokerQueue brokerQueue = new BrokerQueue();
brokerQueue.setName(queue.getName());
brokerQueue.setDispatchedMessagesCount(queue.getDequeueCount());
brokerQueue.setPendingMessagesCount(queue.getQueueSize());
res.add(brokerQueue);
}
return res;
}
示例4: getMessageHandlerConsumers
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
@Override
public MessageHandlerMQConsumer[] getMessageHandlerConsumers() throws MessageQueueJmxException {
Set<MessageHandlerMQConsumer> res = new HashSet<MessageHandlerMQConsumer>();
ObjectName[] subscriberObjects = new ObjectName[0];
BrokerViewMBean viewMBean = getMBean(brokerViewBeanObjectName, BrokerViewMBean.class);
if (viewMBean != null) {
subscriberObjects = viewMBean.getQueueSubscribers();
}
for (ObjectName objectName : subscriberObjects) {
SubscriptionViewMBean subscriber = getMBean(objectName, SubscriptionViewMBean.class);
MessageHandlerMQConsumer consumer = new MessageHandlerMQConsumer();
consumer.setSelector(subscriber.getSelector());
consumer.setDispatchedMessagesCount(subscriber.getDequeueCounter());
consumer.setPendingMessagesCount(subscriber
.getMessageCountAwaitingAcknowledge());
res.add(consumer);
}
MessageHandlerMQConsumer[] sortedRes = new MessageHandlerMQConsumer[res
.size()];
res.toArray(sortedRes);
Arrays.sort(sortedRes);
return sortedRes;
}
示例5: testDurableSubscriptionUnsubscribe
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testDurableSubscriptionUnsubscribe() throws Exception {
connection = createAmqpConnection();
connection.setClientID("DURABLE-AMQP");
connection.start();
assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
assertNotNull(session);
Topic topic = session.createTopic(name.getMethodName());
session.createDurableSubscriber(topic, getSubscriptionName()).close();
BrokerViewMBean broker = getProxyToBroker();
assertEquals(1, broker.getInactiveDurableTopicSubscribers().length);
session.unsubscribe(getSubscriptionName());
assertEquals(0, broker.getInactiveDurableTopicSubscribers().length);
assertEquals(0, broker.getDurableTopicSubscribers().length);
}
示例6: testDurableSubscriptionUnsubscribeNoExistingSubThrowsJMSEx
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testDurableSubscriptionUnsubscribeNoExistingSubThrowsJMSEx() throws Exception {
connection = createAmqpConnection();
connection.setClientID("DURABLE-AMQP");
connection.start();
assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
assertNotNull(session);
BrokerViewMBean broker = getProxyToBroker();
assertEquals(0, broker.getDurableTopicSubscribers().length);
assertEquals(0, broker.getInactiveDurableTopicSubscribers().length);
try {
session.unsubscribe(getSubscriptionName());
fail("Should have thrown an InvalidDestinationException");
} catch (InvalidDestinationException ide) {
}
}
示例7: testDeleteTemporaryQueue
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
@Test(timeout=30000)
public void testDeleteTemporaryQueue() throws Exception {
connection = createAmqpConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createTemporaryQueue();
assertNotNull(queue);
assertTrue(queue instanceof TemporaryQueue);
final BrokerViewMBean broker = getProxyToBroker();
assertEquals(1, broker.getTemporaryQueues().length);
TemporaryQueue tempQueue = (TemporaryQueue) queue;
tempQueue.delete();
assertTrue("Temp Queue should be deleted.", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return broker.getTemporaryQueues().length == 0;
}
}, TimeUnit.SECONDS.toMillis(30), TimeUnit.MILLISECONDS.toMillis(50)));
}
示例8: testDeleteTemporaryTopic
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
@Test(timeout=30000)
public void testDeleteTemporaryTopic() throws Exception {
connection = createAmqpConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = session.createTemporaryTopic();
assertNotNull(topic);
assertTrue(topic instanceof TemporaryTopic);
final BrokerViewMBean broker = getProxyToBroker();
assertEquals(1, broker.getTemporaryTopics().length);
TemporaryTopic tempTopic = (TemporaryTopic) topic;
tempTopic.delete();
assertTrue("Temp Topic should be deleted.", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return broker.getTemporaryTopics().length == 0;
}
}, TimeUnit.SECONDS.toMillis(30), TimeUnit.MILLISECONDS.toMillis(50)));
}
示例9: getProxyToBroker
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
protected BrokerViewMBean getProxyToBroker() throws MalformedObjectNameException, JMSException {
ObjectName brokerViewMBean = new ObjectName(
"org.apache.activemq:type=Broker,brokerName=" + brokerService.getBrokerName());
BrokerViewMBean proxy = (BrokerViewMBean) brokerService.getManagementContext()
.newProxyInstance(brokerViewMBean, BrokerViewMBean.class, true);
return proxy;
}
示例10: getProxyToBroker
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
protected BrokerViewMBean getProxyToBroker() throws MalformedObjectNameException, JMSException {
ObjectName brokerViewMBean = new ObjectName(
"org.apache.activemq:type=Broker,brokerName=localhost");
BrokerViewMBean proxy = (BrokerViewMBean) brokerService.getManagementContext()
.newProxyInstance(brokerViewMBean, BrokerViewMBean.class, true);
return proxy;
}
示例11: Jmx
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
public Jmx() throws IOException, MalformedObjectNameException {
// I got this from the log messages when I was starting ActiveMQ
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi");
JMXConnector connector = JMXConnectorFactory.connect(url);
connector.connect();
MBeanServerConnection connection = connector.getMBeanServerConnection();
// This is jmxDomain:ObjectName...see ActiveMQ MBeans Reference in http://activemq.apache.org/jmx.html
ObjectName name = new ObjectName("org.apache.activemq:brokerName=localhost,type=Broker");
BrokerViewMBean mbean = MBeanServerInvocationHandler.newProxyInstance(connection, name, BrokerViewMBean.class, true);
System.out.println(mbean.getTotalMessageCount());
}
示例12: getBrokerView
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
BrokerViewMBean getBrokerView() throws Exception {
if (this.brokerView == null) {
ObjectName brokerName = getBrokerService().getBrokerObjectName();
this.brokerView = (BrokerViewMBean) getBrokerService().getManagementContext().newProxyInstance(brokerName,
BrokerViewMBean.class, true);
}
return this.brokerView;
}
示例13: getBrokerViewMBean
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
/**
* Retrieves the MBean view from the ActiveMQ broker.
* @return a view into the broker MBeans.
*/
public BrokerViewMBean getBrokerViewMBean() {
try {
return getBrokerViewMBean(mBeanName);
} catch (UndeclaredThrowableException utEx) {
//ActiveMQ version is <5.8, set beanName and destination properties to pre-5.8 values
mBeanName = "org.apache.activemq:BrokerName=" + configurationService.getPlatformSettings().getJmxBroker() + ",Type=Broker";
destinationProperty = "Destination";
return getBrokerViewMBean(mBeanName);
}
}
示例14: assertQueueExistsOn
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
private void assertQueueExistsOn(BrokerService broker, String queueName) throws Exception {
BrokerViewMBean brokerView = broker.getAdminView();
ObjectName[] queueNames = brokerView.getQueues();
assertEquals(1, queueNames.length);
assertTrue(queueNames[0].toString().contains(queueName));
}
示例15: assertOneDurableSubOn
import org.apache.activemq.broker.jmx.BrokerViewMBean; //导入依赖的package包/类
@SuppressWarnings("unused")
private void assertOneDurableSubOn(BrokerService broker, String subName) throws Exception {
BrokerViewMBean brokerView = broker.getAdminView();
ObjectName[] activeDurableSubs = brokerView.getDurableTopicSubscribers();
ObjectName[] inactiveDurableSubs = brokerView.getInactiveDurableTopicSubscribers();
ObjectName[] allDurables = (ObjectName[]) ArrayUtils.addAll(activeDurableSubs, inactiveDurableSubs);
assertEquals(1, allDurables.length);
// at this point our assertions should prove that we have only on durable sub
DurableSubscriptionViewMBean durableSubView = (DurableSubscriptionViewMBean) broker.getManagementContext().newProxyInstance(allDurables[0], DurableSubscriptionViewMBean.class, true);
assertEquals(subName, durableSubView.getClientId());
}