• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TopicViewMBean类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.activemq.broker.jmx.TopicViewMBean的典型用法代码示例。如果您正苦于以下问题:Java TopicViewMBean类的具体用法?Java TopicViewMBean怎么用?Java TopicViewMBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TopicViewMBean类属于org.apache.activemq.broker.jmx包,在下文中一共展示了TopicViewMBean类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: displayTopicStats

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
private void displayTopicStats() throws Exception {

        String query = JmxMBeansUtil.createQueryString(queryString, "Topic");
        List<?> topicsList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query);

        final String header = "%-50s  %10s  %10s  %10s  %10s  %10s  %10s";
        final String tableRow = "%-50s  %10d  %10d  %10d  %10d  %10d  %10d";

        context.print(String.format(Locale.US, header, "Name", "Queue Size", "Producer #", "Consumer #", "Enqueue #", "Dequeue #", "Memory %"));

        // Iterate through the topics result
        for (Object view : topicsList) {
            ObjectName topicName = ((ObjectInstance)view).getObjectName();
            TopicViewMBean topicView = MBeanServerInvocationHandler.
                newProxyInstance(createJmxConnection(), topicName, TopicViewMBean.class, true);

            context.print(String.format(Locale.US, tableRow,
                    topicView.getName(),
                    topicView.getQueueSize(),
                    topicView.getProducerCount(),
                    topicView.getConsumerCount(),
                    topicView.getEnqueueCount(),
                    topicView.getDequeueCount(),
                    topicView.getMemoryPercentUsage()));
        }
    }
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:27,代码来源:DstatCommand.java


示例2: getTopicStatistics

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
/**
 * Returns topic statistics for the JMS topics.
 *
 * @return {@link List} of {@link TopicMBean}. One for each topic.
 */
@PreAuthorize(SecurityConstants.MANAGE_ACTIVEMQ)
public List<TopicMBean> getTopicStatistics() {
    try {
        List<TopicMBean> topics = new ArrayList<>();
        for (ObjectName name : mBeanServer.getTopics()) {
            String destination = name.getKeyProperty(mBeanServer.getDestinationProperty());
            TopicViewMBean topicView = mBeanServer.getTopicViewMBean(name);
            TopicMBean topic = new TopicMBean(destination);
            topic.setEnqueueCount(topicView.getEnqueueCount());
            topic.setDequeueCount(topicView.getDequeueCount());
            topic.setExpiredCount(topicView.getExpiredCount());
            topic.setConsumerCount(topicView.getConsumerCount());
            topics.add(topic);
        }
        return topics;
    } catch (IOException ex) {
        throw new MotechException("Could not access MBeans ", ex);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:25,代码来源:MBeanService.java


示例3: testCreateTopicPublisher

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test
public void testCreateTopicPublisher() throws Exception {
    JmsConnectionFactory factory = new JmsConnectionFactory(getBrokerAmqpConnectionURI());
    TopicConnection connection = factory.createTopicConnection();
    assertNotNull(connection);

    TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Topic topic = session.createTopic(name.getMethodName());
    TopicPublisher publisher = session.createPublisher(topic);
    assertNotNull(publisher);

    TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(0, proxy.getEnqueueCount());
    connection.close();
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:17,代码来源:JmsTopicPublisherTest.java


示例4: testAnonymousSendToTopic

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testAnonymousSendToTopic() throws Exception {
    connection = createAmqpConnection();
    assertNotNull(connection);
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Topic topic = session.createTopic(name.getMethodName());
    assertNotNull(session);
    MessageProducer producer = session.createProducer(null);
    assertNotNull(producer);
    MessageConsumer consumer = session.createConsumer(topic);
    assertNotNull(consumer);

    Message message = session.createMessage();
    producer.send(topic, message);

    TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(1, proxy.getEnqueueCount());
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:21,代码来源:JmsAnonymousProducerTest.java


示例5: testSyncConsumeFromTopic

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testSyncConsumeFromTopic() throws Exception {
    connection = createAmqpConnection();
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Topic topic = session.createTopic(name.getMethodName());
    MessageConsumer consumer = session.createConsumer(topic);

    sendToAmqTopic(1);

    final TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(1, proxy.getEnqueueCount());

    assertNotNull("Failed to receive any message.", consumer.receive(3000));

    assertTrue("Published message not consumed.", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            return proxy.getQueueSize() == 0;
        }
    }));
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:26,代码来源:JmsMessageConsumerTest.java


示例6: testSyncConsumeFromTopic

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testSyncConsumeFromTopic() throws Exception {
    connection = createStompConnection();
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Topic topic = session.createTopic(name.getMethodName());
    MessageConsumer consumer = session.createConsumer(topic);

    sendToAmqTopic(1);

    final TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(1, proxy.getEnqueueCount());
    assertNotNull("Failed to receive any message.", consumer.receive(2000));

    assertTrue("Published message not consumed.", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            return proxy.getQueueSize() == 0;
        }
    }));
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:25,代码来源:JmsMessageConsumerTest.java


示例7: testCreateDuableSubscriber

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testCreateDuableSubscriber() throws Exception {
    connection = createStompConnection();
    connection.setClientID("DURABLE-STOMP");
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Topic topic = session.createTopic(name.getMethodName());
    session.createDurableSubscriber(topic, name.getMethodName() + "-subscriber");

    TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(0, proxy.getQueueSize());

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:17,代码来源:JmsDurableSubscriberTest.java


示例8: testSyncConsumeFromTopic

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testSyncConsumeFromTopic() throws Exception {
    connection = createAmqpConnection();
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Topic topic = session.createTopic(name.getMethodName());
    MessageConsumer consumer = session.createConsumer(topic);

    sendToAmqTopic(1);

    final TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    //assertEquals(1, proxy.getQueueSize());

    assertNotNull("Failed to receive any message.", consumer.receive(2000));

    assertTrue("Published message not consumed.", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            return proxy.getQueueSize() == 0;
        }
    }));
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:26,代码来源:JmsMessageConsumerTest.java


示例9: testCreateDuableSubscriber

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testCreateDuableSubscriber() throws Exception {
    connection = createAmqpConnection();
    connection.setClientID("DURABLE-AMQP");
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Topic topic = session.createTopic(name.getMethodName());
    session.createDurableSubscriber(topic, name.getMethodName() + "-subscriber");

    TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(0, proxy.getQueueSize());

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:17,代码来源:JmsDurableSubscriberTest.java


示例10: testCreateDurableSubscriber

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testCreateDurableSubscriber() 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());
    MessageConsumer consumer = session.createDurableSubscriber(topic, getSubscriptionName());

    TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(0, proxy.getQueueSize());

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    consumer.close();

    assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(1, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    session.unsubscribe(getSubscriptionName());
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:28,代码来源:JmsDurableSubscriberTest.java


示例11: testDurableGoesOfflineAndReturns

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testDurableGoesOfflineAndReturns() 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());
    TopicSubscriber subscriber = session.createDurableSubscriber(topic, getSubscriptionName());

    TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(0, proxy.getQueueSize());

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    subscriber.close();

    assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(1, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    subscriber = session.createDurableSubscriber(topic, getSubscriptionName());

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    subscriber.close();

    session.unsubscribe(getSubscriptionName());
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:35,代码来源:JmsDurableSubscriberTest.java


示例12: getProxyToTopic

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
protected TopicViewMBean getProxyToTopic(BrokerService broker, String name) throws MalformedObjectNameException, JMSException {
    ObjectName topicViewMBeanName = new ObjectName(
        broker.getBrokerObjectName() + ",destinationType=Topic,destinationName=" + name);
    TopicViewMBean proxy = (TopicViewMBean) brokerService.getManagementContext()
            .newProxyInstance(topicViewMBeanName, TopicViewMBean.class, true);
    return proxy;
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:8,代码来源:QpidJmsTestSupport.java


示例13: getProxyToTemporaryTopic

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
protected TopicViewMBean getProxyToTemporaryTopic(BrokerService broker, String name) throws MalformedObjectNameException, JMSException {
    name = JMXSupport.encodeObjectNamePart(name);
    ObjectName topicViewMBeanName = new ObjectName(
        broker.getBrokerObjectName() + ",destinationType=TempTopic,destinationName=" + name);
    TopicViewMBean proxy = (TopicViewMBean) brokerService.getManagementContext()
        .newProxyInstance(topicViewMBeanName, TopicViewMBean.class, true);
    return proxy;
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:9,代码来源:QpidJmsTestSupport.java


示例14: testDurableGoesOfflineAndReturns

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testDurableGoesOfflineAndReturns() throws Exception {
    connection = createStompConnection();
    connection.setClientID("DURABLE-STOMP");
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Topic topic = session.createTopic(name.getMethodName());
    TopicSubscriber subscriber = session.createDurableSubscriber(topic, name.getMethodName() + "-subscriber");

    TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(0, proxy.getQueueSize());

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    subscriber.close();

    assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(1, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    subscriber = session.createDurableSubscriber(topic, name.getMethodName() + "-subscriber");

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:28,代码来源:JmsDurableSubscriberTest.java


示例15: testDurableGoesOfflineAndReturns

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testDurableGoesOfflineAndReturns() throws Exception {
    connection = createAmqpConnection();
    connection.setClientID("DURABLE-AMQP");
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Topic topic = session.createTopic(name.getMethodName());
    TopicSubscriber subscriber = session.createDurableSubscriber(topic, name.getMethodName() + "-subscriber");

    TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(0, proxy.getQueueSize());

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    subscriber.close();

    assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(1, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    subscriber = session.createDurableSubscriber(topic, name.getMethodName() + "-subscriber");

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:28,代码来源:JmsDurableSubscriberTest.java


示例16: testOfflineSubscriberGetsItsMessages

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
@Test(timeout = 60000)
public void testOfflineSubscriberGetsItsMessages() throws Exception {
    connection = createAmqpConnection();
    connection.setClientID("DURABLE-AMQP");
    connection.start();

    assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    final int MSG_COUNT = 5;

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Topic topic = session.createTopic(name.getMethodName());
    TopicSubscriber subscriber = session.createDurableSubscriber(topic, getSubscriptionName());

    TopicViewMBean proxy = getProxyToTopic(name.getMethodName());
    assertEquals(0, proxy.getQueueSize());
    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    subscriber.close();

    assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(1, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    MessageProducer producer = session.createProducer(topic);
    for (int i = 0; i < MSG_COUNT; i++) {
        producer.send(session.createTextMessage("Message: " + i));
    }
    producer.close();

    LOG.info("Bringing offline subscription back online.");
    subscriber = session.createDurableSubscriber(topic, getSubscriptionName());

    assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
    assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);

    final CountDownLatch messages = new CountDownLatch(MSG_COUNT);
    subscriber.setMessageListener(new MessageListener() {

        @Override
        public void onMessage(Message message) {
            LOG.info("Consumer got a message: {}", message);
            messages.countDown();
        }
    });

    assertTrue("Only recieved messages: " + messages.getCount(), messages.await(30, TimeUnit.SECONDS));

    subscriber.close();

    session.unsubscribe(getSubscriptionName());
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:55,代码来源:JmsDurableSubscriberTest.java


示例17: getTopicViewMBean

import org.apache.activemq.broker.jmx.TopicViewMBean; //导入依赖的package包/类
/**
 * Retrieves the mbean view for the given ActiveMQ topic.
 * @param name the {@link ObjectName} representing the name of the topic for which the MBean view should be retrieved.
 * @return the {@link TopicViewMBean} allowing access to topic information.
 * @throws IOException when we were unable to connect using JMX.
 */
public TopicViewMBean getTopicViewMBean(ObjectName name) throws IOException {
    return MBeanServerInvocationHandler.newProxyInstance(openConnection(), name, TopicViewMBean.class, true);
}
 
开发者ID:motech,项目名称:motech,代码行数:10,代码来源:MotechMBeanServer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApplicationContextHelper类代码示例发布时间:2022-05-23
下一篇:
Java PathFileManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap