@Test public void testQueueTempUsageWhenBrokerTempUsageUpdated() throws Exception { ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + queue.getQueueName()); QueueViewMBean queueViewMBean = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance( queueViewMBeanName, QueueViewMBean.class, true); // Check that by default the queue's temp limit is the same as the broker's. BrokerView brokerView = brokerService.getAdminView(); long brokerTempLimit = brokerView.getTempLimit(); assertEquals(brokerTempLimit, queueViewMBean.getTempUsageLimit()); // Increase the broker's temp limit and check the queue's limit is updated to the same value. long newBrokerTempLimit = brokerTempLimit + 555; brokerView.setTempLimit(newBrokerTempLimit); assertEquals(brokerView.getTempLimit(), newBrokerTempLimit); assertEquals(queueViewMBean.getTempUsageLimit(), newBrokerTempLimit); } }
@Test public void testQueueTempUsageWhenSetExplicitly() throws Exception { ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + queue.getQueueName()); QueueViewMBean queueViewMBean = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance( queueViewMBeanName, QueueViewMBean.class, true); // Check that by default the queue's temp limit is the same as the broker's. BrokerView brokerView = brokerService.getAdminView(); long brokerTempLimit = brokerView.getTempLimit(); assertEquals(brokerTempLimit, queueViewMBean.getTempUsageLimit()); // Change the queue's temp limit independently of the broker's setting and check the broker's limit does not // change. long queueTempLimit = brokerTempLimit + 111; queueViewMBean.setTempUsageLimit(queueTempLimit); assertEquals(queueViewMBean.getTempUsageLimit(), queueTempLimit); assertEquals(brokerView.getTempLimit(), brokerTempLimit); // Now increase the broker's temp limit. Since the queue's limit was explicitly changed it should remain // unchanged. long newBrokerTempLimit = brokerTempLimit + 555; brokerView.setTempLimit(newBrokerTempLimit); assertEquals(brokerView.getTempLimit(), newBrokerTempLimit); assertEquals(queueViewMBean.getTempUsageLimit(), queueTempLimit); }
DestinationSource ds = connection.getDestinationSource(); Set<ActiveMQQueue> queues = ds.getQueues(); for(ActiveMQQueue queue : queues){ try { System.out.println(queue.getQueueName()); } catch (JMSException e) { e.printStackTrace(); } }
try { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616/"); ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection(); DestinationSource ds = connection.getDestinationSource(); connection.start(); Set<ActiveMQQueue> queues = ds.getQueues(); for (ActiveMQQueue activeMQQueue : queues) { try { System.out.println(activeMQQueue.getQueueName()); } catch (JMSException e) { e.printStackTrace(); } } connection.close(); } catch (Exception e) { e.printStackTrace(); }
// Create a ConnectionFactory ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); // Create a Connection ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection(); //Important point that was missed in the above answer connection.start(); DestinationSource ds = connection.getDestinationSource(); Set<ActiveMQQueue> queues = ds.getQueues(); for(ActiveMQQueue queue : queues){ try { System.out.println(queue.getQueueName()); } catch (JMSException e) { e.printStackTrace(); } }
jsonMap.put("name", dest.getQueueName()); String json = mapper.writeValueAsString(jsonMap); System.out.println(json);
jsonMap.put("name", dest.getQueueName()); String json = mapper.writeValueAsString(jsonMap); System.out.println(json);
jsonMap.put("name", dest.getQueueName()); String json = mapper.writeValueAsString(jsonMap); System.out.println(json);