Java Code Examples for org.apache.activemq.command.ActiveMQDestination#getPhysicalName()
The following examples show how to use
org.apache.activemq.command.ActiveMQDestination#getPhysicalName() .
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: OneopsAuthBroker.java From oneops with Apache License 2.0 | 6 votes |
/** * Add message producer. * * @param context * @param info * @throws Exception * @see org.apache.activemq.broker.BrokerFilter#addProducer(org.apache.activemq.broker.ConnectionContext, org.apache.activemq.command.ProducerInfo) */ public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception { Connection conn = context.getConnection(); ActiveMQDestination dest = info.getDestination(); if (dest != null) { String destName = dest.getPhysicalName(); String clientId = context.getClientId(); logger.info(">>> Got Producer Add request { Destination: " + destName + ", Remote Address: " + conn.getRemoteAddress() + ", ClientID: " + clientId + " }"); String allowedDest = userMap.get(context.getClientId()); if (allowedDest != null && (allowedDest.equals("*") || "controller.response".equals(destName))) { logger.info("<<< Producer allowed"); } else { logger.error("<<< Destination not allowed. Producer denied!"); throw new CmsAuthException("<<< Producer denied!"); } } else { logger.error("<<< Got Producer Add request from Remote Address:" + conn.getRemoteAddress() + ". But destination is NULL."); } super.addProducer(context, info); }
Example 2
Source File: ArtemisBrokerWrapper.java From activemq-artemis with Apache License 2.0 | 6 votes |
public long getAMQueueMessageCount(ActiveMQDestination amq5Dest) { if (amq5Dest.isTopic()) { throw new IllegalArgumentException("Method only accept queue type parameter."); } long count = 0; String qname = null; if (amq5Dest.isTemporary()) { qname = amq5Dest.getPhysicalName(); } else { qname = amq5Dest.getPhysicalName(); } Binding binding = server.getPostOffice().getBinding(new SimpleString(qname)); if (binding != null) { QueueImpl q = (QueueImpl) binding.getBindable(); count = q.getMessageCount(); } return count; }
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: AdvisoryTopicDeletionTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void doTest() throws Exception { Destination dest = createDestination(); Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Session consumerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = consumerSession.createConsumer(dest); MessageProducer prod = producerSession.createProducer(dest); Message message = producerSession.createMessage(); prod.send(message); consumer.receive(60 * 1000); connection.close(); connection = null; if (topic) { broker.getAdminView().removeTopic(((ActiveMQDestination) dest).getPhysicalName()); } else { broker.getAdminView().removeQueue(((ActiveMQDestination) dest).getPhysicalName()); } ActiveMQDestination dests[] = broker.getRegionBroker().getDestinations(); int matchingDestinations = 0; for (ActiveMQDestination destination : dests) { String name = destination.getPhysicalName(); LOG.debug("Found destination " + name); if (name.startsWith("ActiveMQ.Advisory") && name.contains(getDestinationString())) { matchingDestinations++; } } assertEquals("No matching destinations should be found", 0, matchingDestinations); }
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: AMQSession.java From activemq-artemis with Apache License 2.0 | 5 votes |
public String convertWildcard(ActiveMQDestination openWireDest) { if (openWireDest.isTemporary() || AdvisorySupport.isAdvisoryTopic(openWireDest)) { return openWireDest.getPhysicalName(); } else { return OPENWIRE_WILDCARD.convert(openWireDest.getPhysicalName(), server.getConfiguration().getWildcardConfiguration()); } }
Example 7
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 8
Source File: AbortSlowConsumer0Test.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testSlowConsumerIsAbortedViaJmx() throws Exception { underTest.setMaxSlowDuration(60 * 1000); // so jmx does the abort startConsumers(withPrefetch(2, destination)); Entry<MessageConsumer, MessageIdList> consumertoAbort = consumers.entrySet().iterator().next(); consumertoAbort.getValue().setProcessingDelay(8 * 1000); for (Connection c : connections) { c.setExceptionListener(this); } startProducers(destination, 100); consumertoAbort.getValue().assertMessagesReceived(1); ActiveMQDestination amqDest = (ActiveMQDestination) destination; ObjectName destinationViewMBean = new ObjectName("org.apache.activemq:destinationType=" + (amqDest.isTopic() ? "Topic" : "Queue") + ",destinationName=" + amqDest.getPhysicalName() + ",type=Broker,brokerName=localhost"); DestinationViewMBean queue = (DestinationViewMBean) broker.getManagementContext().newProxyInstance(destinationViewMBean, DestinationViewMBean.class, true); ObjectName slowConsumerPolicyMBeanName = queue.getSlowConsumerStrategy(); assertNotNull(slowConsumerPolicyMBeanName); AbortSlowConsumerStrategyViewMBean abortPolicy = (AbortSlowConsumerStrategyViewMBean) broker.getManagementContext().newProxyInstance(slowConsumerPolicyMBeanName, AbortSlowConsumerStrategyViewMBean.class, true); TimeUnit.SECONDS.sleep(3); TabularData slowOnes = abortPolicy.getSlowConsumers(); assertEquals("one slow consumers", 1, slowOnes.size()); LOG.info("slow ones:" + slowOnes); CompositeData slowOne = (CompositeData) slowOnes.values().iterator().next(); LOG.info("Slow one: " + slowOne); assertTrue("we have an object name", slowOne.get("subscription") instanceof ObjectName); abortPolicy.abortConsumer((ObjectName) slowOne.get("subscription")); consumertoAbort.getValue().assertAtMostMessagesReceived(1); slowOnes = abortPolicy.getSlowConsumers(); assertEquals("no slow consumers left", 0, slowOnes.size()); // verify mbean gone with destination broker.getAdminView().removeTopic(amqDest.getPhysicalName()); try { abortPolicy.getSlowConsumers(); fail("expect not found post destination removal"); } catch (UndeclaredThrowableException expected) { assertTrue("correct exception: " + expected.getCause(), expected.getCause() instanceof InstanceNotFoundException); } }
Example 9
Source File: AbortSlowConsumer0Test.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testAbortConsumerOnDeadConnection() throws Exception { TransportConnector transportConnector = broker.addConnector("tcp://0.0.0.0:0"); transportConnector.setBrokerService(broker); transportConnector.setTaskRunnerFactory(broker.getTaskRunnerFactory()); transportConnector.start(); SocketProxy socketProxy = new SocketProxy(transportConnector.getPublishableConnectURI()); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(socketProxy.getUrl()); ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy(); prefetchPolicy.setAll(4); connectionFactory.setPrefetchPolicy(prefetchPolicy); Connection c = connectionFactory.createConnection(); connections.add(c); c.start(); Session session = c.createSession(false, Session.CLIENT_ACKNOWLEDGE); final ActiveMQMessageConsumer messageconsumer = (ActiveMQMessageConsumer) session.createConsumer(destination); startProducers(destination, 10); messageconsumer.receive(4000).acknowledge(); assertNotNull(messageconsumer.receive(4000)); assertNotNull(messageconsumer.receive(4000)); assertNotNull(messageconsumer.receive(4000)); // close control command won't get through socketProxy.pause(); ActiveMQDestination amqDest = (ActiveMQDestination) destination; ObjectName destinationViewMBean = new ObjectName("org.apache.activemq:destinationType=" + (amqDest.isTopic() ? "Topic" : "Queue") + ",destinationName=" + amqDest.getPhysicalName() + ",type=Broker,brokerName=localhost"); final DestinationViewMBean destView = (DestinationViewMBean) broker.getManagementContext().newProxyInstance(destinationViewMBean, DestinationViewMBean.class, true); assertTrue("Consumer gone from broker view", Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { LOG.info("DestView {} consumerCount {}", destView, destView.getConsumerCount()); return 0 == destView.getConsumerCount(); } })); socketProxy.goOn(); assertTrue("consumer was closed", Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { boolean closed = false; try { messageconsumer.receive(400); } catch (javax.jms.IllegalStateException expected) { closed = expected.toString().contains("closed"); } return closed; } })); }
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); } }
Example 11
Source File: ActiveMQMessageProducerSendInterceptor.java From pinpoint with Apache License 2.0 | 4 votes |
private boolean filterDestination(ActiveMQDestination destination) { String destinationName = destination.getPhysicalName(); return this.excludeDestinationFilter.filter(destinationName); }
Example 12
Source File: ActiveMQMessageConsumerDispatchInterceptor.java From pinpoint with Apache License 2.0 | 4 votes |
private boolean filterDestination(ActiveMQDestination destination) { String destinationName = destination.getPhysicalName(); return this.excludeDestinationFilter.filter(destinationName); }