Java Code Examples for org.apache.activemq.command.ActiveMQDestination#isQueue()
The following examples show how to use
org.apache.activemq.command.ActiveMQDestination#isQueue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JMSPollingConsumerQueueTest.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Test Run Inbound Task to poll messages from Queue * * @throws Exception */ @Test public void testPollingOnQueue() throws Exception { String queueName = "testQueue1"; boolean isQueueExist = false; Properties jmsProperties = JMSTestsUtils.getJMSPropertiesForDestination(queueName, PROVIDER_URL, true); JMSBrokerController brokerController = new JMSBrokerController(PROVIDER_URL, jmsProperties); JMSPollingConsumer jmsPollingConsumer = new JMSPollingConsumer(jmsProperties, INTERVAL, INBOUND_EP_NAME); InboundTask task = new JMSTask(jmsPollingConsumer, INTERVAL); Assert.assertEquals(task.getInboundProperties().getProperty(JMSConstants.PROVIDER_URL), PROVIDER_URL); try { brokerController.startProcess(); task.execute(); ActiveMQDestination[] activeMQDestination = brokerController.getBrokerService().getRegionBroker(). getDestinations(); for (ActiveMQDestination destination : activeMQDestination) { if (destination.isQueue() && queueName.equals(destination.getPhysicalName())) { isQueueExist = true; } } Assert.assertTrue("Queue is not added as a subscription", isQueueExist); } finally { task.destroy(); brokerController.stopProcess(); } }
Example 2
Source File: DestinationsPluginTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testDestinationSave() throws Exception { BrokerView brokerView = broker.getAdminView(); brokerView.addQueue("test-queue"); broker.stop(); broker.waitUntilStopped(); broker = createBroker(); broker.start(); broker.waitUntilStarted(); ActiveMQDestination[] destinations = broker.getRegionBroker().getDestinations(); for (ActiveMQDestination destination : destinations) { if (destination.isQueue()) { assertEquals("test-queue", destination.getPhysicalName()); } } }
Example 3
Source File: BrokerService.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void makeSureDestinationExists(ActiveMQDestination activemqDestination) throws Exception { ArtemisBrokerWrapper hqBroker = (ArtemisBrokerWrapper) this.broker; //it can be null if (activemqDestination == null) { return; } if (activemqDestination.isQueue()) { String qname = activemqDestination.getPhysicalName(); System.out.println("physical name: " + qname); hqBroker.makeSureQueueExists(qname); } }
Example 4
Source File: TestSupport.java From activemq-artemis with Apache License 2.0 | 5 votes |
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(); }
Example 5
Source File: OpenWireConnection.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * Checks to see if this destination exists. If it does not throw an invalid destination exception. * * @param destination */ private void validateDestination(ActiveMQDestination destination) throws Exception { if (destination.isQueue()) { SimpleString physicalName = new SimpleString(destination.getPhysicalName()); BindingQueryResult result = server.bindingQuery(physicalName); if (!result.isExists() && !result.isAutoCreateQueues()) { throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(physicalName); } } }
Example 6
Source File: OpenWireConnection.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public Response processAddProducer(ProducerInfo info) throws Exception { SessionId sessionId = info.getProducerId().getParentId(); ConnectionState cs = getState(); if (cs == null) { throw new IllegalStateException("Cannot add a producer to a connection that had not been registered: " + sessionId.getParentId()); } SessionState ss = cs.getSessionState(sessionId); if (ss == null) { throw new IllegalStateException("Cannot add a producer to a session that had not been registered: " + sessionId); } // Avoid replaying dup commands if (!ss.getProducerIds().contains(info.getProducerId())) { ActiveMQDestination destination = info.getDestination(); if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination)) { if (destination.isQueue()) { OpenWireConnection.this.validateDestination(destination); } DestinationInfo destInfo = new DestinationInfo(getContext().getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, destination); OpenWireConnection.this.addDestination(destInfo); } ss.addProducer(info); } return null; }
Example 7
Source File: AMQSession.java From activemq-artemis with Apache License 2.0 | 5 votes |
public List<AMQConsumer> createConsumer(ConsumerInfo info, SlowConsumerDetectionListener slowConsumerDetectionListener) throws Exception { //check destination ActiveMQDestination dest = info.getDestination(); ActiveMQDestination[] dests = null; if (dest.isComposite()) { dests = dest.getCompositeDestinations(); } else { dests = new ActiveMQDestination[]{dest}; } List<AMQConsumer> consumersList = new java.util.LinkedList<>(); for (ActiveMQDestination openWireDest : dests) { boolean isInternalAddress = false; if (AdvisorySupport.isAdvisoryTopic(dest)) { if (!connection.isSuppportAdvisory()) { continue; } isInternalAddress = connection.isSuppressInternalManagementObjects(); } if (openWireDest.isQueue()) { openWireDest = protocolManager.virtualTopicConsumerToFQQN(openWireDest); SimpleString queueName = new SimpleString(convertWildcard(openWireDest)); if (!checkAutoCreateQueue(queueName, openWireDest.isTemporary())) { throw new InvalidDestinationException("Destination doesn't exist: " + queueName); } } AMQConsumer consumer = new AMQConsumer(this, openWireDest, info, scheduledPool, isInternalAddress); long nativeID = consumerIDGenerator.generateID(); consumer.init(slowConsumerDetectionListener, nativeID); consumersList.add(consumer); } return consumersList; }
Example 8
Source File: OpenWireUtil.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * We convert the core address to an ActiveMQ Destination. We use the actual address on the message rather than the * destination set on the consumer because it maybe different and the JMS spec says that it should be what ever was * set on publish/send so a divert or wildcard may mean thats its different to the destination subscribed to by the * consumer */ public static ActiveMQDestination toAMQAddress(Message message, ActiveMQDestination actualDestination) { String address = message.getAddress(); if (address == null || address.equals(actualDestination.getPhysicalName())) { return actualDestination; } if (actualDestination.isQueue()) { return new ActiveMQQueue(address); } else { return new ActiveMQTopic(address); } }
Example 9
Source File: MinimalWorkflowTests.java From scava with Eclipse Public License 2.0 | 4 votes |
@Test public void testInternalQueues() throws Exception { MinimalWorkflow workflow = new MinimalWorkflow(); workflow.createBroker(createBroker); InternalQueueMonitor monitor = new InternalQueueMonitor() { @Override public void run() { for (ActiveMQDestination c : workflow.getAllJobStreamsInternals()) { try { // System.out.println(s); String url = "service:jmx:rmi:///jndi/rmi://" + workflow.getMaster() + ":1099/jmxrmi"; try (JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(url))) { MBeanServerConnection connection = connector.getMBeanServerConnection(); ObjectName destination = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + workflow.getMaster() + ",destinationType=" + (c.isQueue() ? "Queue" : "Topic") + ",destinationName=" + c.getPhysicalName()); DestinationViewMBean mbView = MBeanServerInvocationHandler.newProxyInstance(connection, destination, DestinationViewMBean.class, true); // System.err.println(destinationName + ":" // + destinationType + " " // + mbView.getQueueSize() + " " // + mbView.getInFlightCount()); try { long qSize = mbView.getQueueSize(); queueSizes.put(c.toString(), qSize); if (qSize > 0) queueSizesActive = true; long qIFC = mbView.getInFlightCount(); queuesInFlight.put(c.toString(), qIFC); if (qIFC > 0) queuesInFlightActive = true; } catch (Exception ex) { // Ignore exception as we will be getting these during workflow termination as // we keep trying to get queue info on queues that will be shutting down } } // streamSizes.put(s.getName(), s.getSize()); // streamsInFlight.put(s.getName(), s.getInFlight()); } catch (Exception e) { // Ignore exception as we will be getting these during workflow termination as // we keep trying to get queue info on queues that will be shutting down } } // // System.out.println(queueSizes + "\r\n" + queuesInFlight); // System.out.println("" + // queueSizes.entrySet().stream().collect(Collectors.summingLong(e -> // e.getValue()))); // System.out.println(queueSizesActive); // System.out.println("" + // queuesInFlight.entrySet().stream().collect(Collectors.summingLong(e -> // e.getValue()))); // System.out.println(queuesInFlightActive); // } }; List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); workflow.setInstanceId("testInternalQueues"); workflow.getMinimalSource().setNumbers(numbers); workflow.getCopierTask().setDelay(100); workflow.getMinimalSink().setDelay(200); // workflow.setStreamMetadataPeriod(10); workflow.run(); long delay = 5; Timer timer = new Timer(); timer.schedule(monitor, 0, delay); waitFor(workflow); assertEquals(10, workflow.getMinimalSink().getNumbers().size()); assertTrue(monitor.queueSizesActive && monitor.queuesInFlightActive); assertEquals(0L, monitor.queueSizes.entrySet().stream().collect(Collectors.summingLong(e -> e.getValue())).longValue()); assertEquals(0L, monitor.queuesInFlight.entrySet().stream().collect(Collectors.summingLong(e -> e.getValue())) .longValue()); }
Example 10
Source File: OpenWireConnection.java From activemq-artemis with Apache License 2.0 | 4 votes |
public void removeDestination(ActiveMQDestination dest) throws Exception { if (dest.isQueue()) { if (!dest.isTemporary()) { // this should not really happen, // so I'm not creating a Logger for this logger.warn("OpenWire client sending a queue remove towards " + dest.getPhysicalName()); } try { server.destroyQueue(new SimpleString(dest.getPhysicalName()), getRemotingConnection()); } catch (ActiveMQNonExistentQueueException neq) { //this is ok, ActiveMQ 5 allows this and will actually do it quite often ActiveMQServerLogger.LOGGER.debug("queue never existed"); } } else { Bindings bindings = server.getPostOffice().lookupBindingsForAddress(new SimpleString(dest.getPhysicalName())); if (bindings != null) { for (Binding binding : bindings.getBindings()) { Queue b = (Queue) binding.getBindable(); if (b.getConsumerCount() > 0) { throw new Exception("Destination still has an active subscription: " + dest.getPhysicalName()); } if (b.isDurable()) { throw new Exception("Destination still has durable subscription: " + dest.getPhysicalName()); } b.deleteQueue(); } } } if (!AdvisorySupport.isAdvisoryTopic(dest)) { AMQConnectionContext context = getContext(); DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest); ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest); protocolManager.fireAdvisory(context, topic, advInfo); } }