org.apache.activemq.command.ActiveMQQueue Java Examples

The following examples show how to use org.apache.activemq.command.ActiveMQQueue. 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: JMSUtilsTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Test lookupDestination
 *
 * @throws Exception
 */
@Test
public void testLookupDestination() throws Exception {
    String queueName = "testQueueExist";
    Properties jmsProperties = JMSTestsUtils.getJMSPropertiesForDestination(queueName, PROVIDER_URL, true);
    JMSBrokerController brokerController = new JMSBrokerController(PROVIDER_URL, jmsProperties);
    try {
        brokerController.startProcess();
        InitialContext ctx = new InitialContext(jmsProperties);
        brokerController.connect(queueName, true);
        Destination existDest = JMSUtils.lookupDestination(ctx, queueName, JMSConstants.DESTINATION_TYPE_QUEUE);
        Assert.assertEquals("The destination should be exist", queueName,
                            ((ActiveMQQueue) existDest).getPhysicalName());
        Destination nullDest = JMSUtils.lookupDestination(ctx, null, JMSConstants.DESTINATION_TYPE_QUEUE);
        Assert.assertNull("Destination should be null when the destination name is null", nullDest);
        String notExistQueueName = "Not_Exist";
        Destination nonExistDest = JMSUtils
                .lookupDestination(ctx, notExistQueueName, JMSConstants.DESTINATION_TYPE_QUEUE);
        Assert.assertEquals("The destination should be exist", notExistQueueName,
                            ((ActiveMQQueue) nonExistDest).getPhysicalName());
    } finally {
        brokerController.disconnect();
        brokerController.stopProcess();
    }
}
 
Example #2
Source File: UserServiceServiceImpl.java    From paas with Apache License 2.0 6 votes vote down vote up
/**
 * 发送容器消息
 * @author hf
 * @since 2018/7/13 18:34
 */
private void sendMQ(String userId, String serviceId, ResultVO resultVO) {
    Destination destination = new ActiveMQQueue("MQ_QUEUE_SERVICE");
    Task task = new Task();

    Map<String, Object> data = new HashMap<>(16);
    data.put("type", WebSocketTypeEnum.SERVICE.getCode());
    data.put("serviceId",serviceId);
    resultVO.setData(data);

    Map<String,String> map = new HashMap<>(16);
    map.put("uid",userId);
    map.put("data", JsonUtils.objectToJson(resultVO));
    task.setData(map);

    mqProducer.send(destination, JsonUtils.objectToJson(task));
}
 
Example #3
Source File: BrokerRedeliveryTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void testNoScheduledRedeliveryOfExpired() throws Exception {
   startBroker(true);
   ActiveMQConnection consumerConnection = (ActiveMQConnection) createConnection();
   consumerConnection.start();
   Session consumerSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
   MessageConsumer consumer = consumerSession.createConsumer(destination);
   sendMessage(1500);
   Message message = consumer.receive(1000);
   assertNotNull("got message", message);

   // ensure there is another consumer to redispatch to
   MessageConsumer redeliverConsumer = consumerSession.createConsumer(destination);

   // allow consumed to expire so it gets redelivered
   TimeUnit.SECONDS.sleep(2);
   consumer.close();

   // should go to dlq as it has expired
   // validate DLQ
   MessageConsumer dlqConsumer = consumerSession.createConsumer(new ActiveMQQueue(SharedDeadLetterStrategy.DEFAULT_DEAD_LETTER_QUEUE_NAME));
   Message dlqMessage = dlqConsumer.receive(2000);
   assertNotNull("Got message from dql", dlqMessage);
   assertEquals("message matches", message.getStringProperty("data"), dlqMessage.getStringProperty("data"));
}
 
Example #4
Source File: VolumesController.java    From paas with Apache License 2.0 6 votes vote down vote up
/**
 * 发送数据卷消息
 * @author jitwxs
 * @since 2018/7/9 18:34
 */
private void sendMQ(String userId, String volumeId, ResultVO resultVO) {
    Destination destination = new ActiveMQQueue("MQ_QUEUE_VOLUME");
    Task task = new Task();

    Map<String, Object> data = new HashMap<>(16);
    data.put("type", WebSocketTypeEnum.VOLUME.getCode());
    data.put("volumeId", volumeId);
    resultVO.setData(data);

    Map<String,String> map = new HashMap<>(16);
    map.put("uid",userId);
    map.put("data", JsonUtils.objectToJson(resultVO));
    task.setData(map);

    mqProducer.send(destination, JsonUtils.objectToJson(task));
}
 
Example #5
Source File: ConnectorXBeanConfigTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void testConnectorConfiguredCorrectly() throws Exception {

      TransportConnector connector = brokerService.getTransportConnectors().get(0);

      assertEquals(new URI("tcp://localhost:61636"), connector.getUri());
      assertTrue(connector.getTaskRunnerFactory() == brokerService.getTaskRunnerFactory());

      NetworkConnector netConnector = brokerService.getNetworkConnectors().get(0);
      List<ActiveMQDestination> excludedDestinations = netConnector.getExcludedDestinations();
      assertEquals(new ActiveMQQueue("exclude.test.foo"), excludedDestinations.get(0));
      assertEquals(new ActiveMQTopic("exclude.test.bar"), excludedDestinations.get(1));

      List<ActiveMQDestination> dynamicallyIncludedDestinations = netConnector.getDynamicallyIncludedDestinations();
      assertEquals(new ActiveMQQueue("include.test.foo"), dynamicallyIncludedDestinations.get(0));
      assertEquals(new ActiveMQTopic("include.test.bar"), dynamicallyIncludedDestinations.get(1));
   }
 
Example #6
Source File: SimpleOpenWireTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testAutoDestinationCreationOnProducerSend() throws JMSException {
   AddressSettings addressSetting = new AddressSettings();
   addressSetting.setAutoCreateQueues(true);
   addressSetting.setAutoCreateAddresses(true);

   String address = "foo";
   server.getAddressSettingsRepository().addMatch(address, addressSetting);

   connection.start();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

   TextMessage message = session.createTextMessage("bar");
   Queue queue = new ActiveMQQueue(address);

   MessageProducer producer = session.createProducer(null);
   producer.send(queue, message);

   MessageConsumer consumer = session.createConsumer(queue);
   TextMessage message1 = (TextMessage) consumer.receive(1000);
   assertTrue(message1.getText().equals(message.getText()));
}
 
Example #7
Source File: IgniteJmsStreamerTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testInsertMultipleCacheEntriesFromOneMessage() throws Exception {
    Destination dest = new ActiveMQQueue(QUEUE_NAME);

    // produce A SINGLE MESSAGE, containing all data, into the queue
    produceStringMessages(dest, true);

    try (IgniteDataStreamer<String, String> dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) {
        JmsStreamer<TextMessage, String, String> jmsStreamer = newJmsStreamer(TextMessage.class, dataStreamer);
        jmsStreamer.setDestination(dest);

        // subscribe to cache PUT events and return a countdown latch starting at CACHE_ENTRY_COUNT
        CountDownLatch latch = subscribeToPutEvents(CACHE_ENTRY_COUNT);

        jmsStreamer.start();

        // all cache PUT events received in 10 seconds
        latch.await(10, TimeUnit.SECONDS);

        assertAllCacheEntriesLoaded();

        jmsStreamer.stop();
    }

}
 
Example #8
Source File: JaasNetworkTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void testNetwork() throws Exception {

      System.setProperty("javax.net.ssl.trustStore", "src/test/resources/org/apache/activemq/security/client.ts");
      System.setProperty("javax.net.ssl.trustStorePassword", "password");
      System.setProperty("javax.net.ssl.trustStoreType", "jks");
      System.setProperty("javax.net.ssl.keyStore", "src/test/resources/org/apache/activemq/security/client.ks");
      System.setProperty("javax.net.ssl.keyStorePassword", "password");
      System.setProperty("javax.net.ssl.keyStoreType", "jks");

      ActiveMQConnectionFactory producerFactory = new ActiveMQConnectionFactory("ssl://localhost:61617");
      Connection producerConn = producerFactory.createConnection();
      Session producerSess = producerConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer producer = producerSess.createProducer(new ActiveMQQueue("test"));
      producerConn.start();
      TextMessage sentMessage = producerSess.createTextMessage("test");
      producer.send(sentMessage);

      ActiveMQConnectionFactory consumerFactory = new ActiveMQConnectionFactory("ssl://localhost:61618");
      Connection consumerConn = consumerFactory.createConnection();
      Session consumerSess = consumerConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      consumerConn.start();
      MessageConsumer consumer = consumerSess.createConsumer(new ActiveMQQueue("test"));
      TextMessage receivedMessage = (TextMessage) consumer.receive(100);
      assertEquals(sentMessage, receivedMessage);

   }
 
Example #9
Source File: ClientJmsConfig.java    From c2mon with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public DefaultMessageListenerContainer clientRequestJmsContainer(ClientRequestDelegator delegator, ClientRequestErrorHandler errorHandler) {
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();

  String clientRequestQueue = properties.getJms().getRequestQueue();
  container.setDestination(new ActiveMQQueue(clientRequestQueue));

  container.setConnectionFactory(clientSingleConnectionFactory());
  container.setMessageListener(delegator);
  container.setConcurrentConsumers(properties.getJms().getInitialConsumers());
  container.setMaxConcurrentConsumers(properties.getJms().getMaxConsumers());
  container.setMaxMessagesPerTask(1);
  container.setReceiveTimeout(1000);
  container.setIdleTaskExecutionLimit(600);
  container.setSessionTransacted(false);
  container.setTaskExecutor(clientExecutor());
  container.setErrorHandler(errorHandler);
  container.setAutoStartup(false);
  container.setPhase(ServerConstants.PHASE_INTERMEDIATE);
  return container;
}
 
Example #10
Source File: AbstractCachedLDAPAuthorizationMapLegacyTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testRenameDestination() throws Exception {
   map.query();

   // Test for a destination rename
   Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
   assertEquals("set size: " + failedACLs, 2, failedACLs.size());

   connection.rename(new Dn("cn=TEST.FOO," + getQueueBaseDn()), new Rdn("cn=TEST.BAR"));

   Thread.sleep(2000);

   failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
   assertEquals("set size: " + failedACLs, 0, failedACLs.size());

   failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.BAR"));
   assertEquals("set size: " + failedACLs, 2, failedACLs.size());
}
 
Example #11
Source File: QueueResendDuringShutdownTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
   this.receiveCount = 0;

   this.broker = new BrokerService();
   this.broker.setPersistent(false);
   this.broker.start();
   this.broker.waitUntilStarted();

   this.factory = new ActiveMQConnectionFactory(broker.getVmConnectorURI());
   this.queue = new ActiveMQQueue("TESTQUEUE");

   connections = new Connection[NUM_CONNECTION_TO_TEST];
   int iter = 0;
   while (iter < NUM_CONNECTION_TO_TEST) {
      this.connections[iter] = factory.createConnection();
      iter++;
   }

   this.producerConnection = factory.createConnection();
   this.producerConnection.start();
}
 
Example #12
Source File: IgniteJmsStreamerTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testQueueMessagesConsumedInBatchesCompletionSizeBased() throws Exception {
    Destination dest = new ActiveMQQueue(QUEUE_NAME);

    // produce multiple messages into the queue
    produceStringMessages(dest, false);

    try (IgniteDataStreamer<String, String> dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) {
        JmsStreamer<TextMessage, String, String> jmsStreamer = newJmsStreamer(TextMessage.class, dataStreamer);
        jmsStreamer.setDestination(dest);
        jmsStreamer.setBatched(true);
        jmsStreamer.setBatchClosureSize(99);

        // disable time-based session commits
        jmsStreamer.setBatchClosureMillis(0);

        // subscribe to cache PUT events and return a countdown latch starting at CACHE_ENTRY_COUNT
        CountDownLatch latch = subscribeToPutEvents(CACHE_ENTRY_COUNT);

        jmsStreamer.start();

        // all cache PUT events received in 10 seconds
        latch.await(10, TimeUnit.SECONDS);

        assertAllCacheEntriesLoaded();

        // we expect all entries to be loaded, but still one (uncommitted) message should remain in the queue
        // as observed by the broker
        DestinationStatistics qStats = broker.getBroker().getDestinationMap().get(dest).getDestinationStatistics();
        assertEquals(1, qStats.getMessages().getCount());
        assertEquals(1, qStats.getInflight().getCount());

        jmsStreamer.stop();
    }

}
 
Example #13
Source File: NetworkBridgeProducerFlowControlTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void testSendFailIfNoSpaceDoesNotBlockQueueNetwork() throws Exception {
   // Consumer prefetch is disabled for broker1's consumers.
   final ActiveMQQueue SLOW_SHARED_QUEUE = new ActiveMQQueue(NetworkBridgeProducerFlowControlTest.class.getSimpleName() + ".slow.shared?consumer.prefetchSize=1");

   final ActiveMQQueue FAST_SHARED_QUEUE = new ActiveMQQueue(NetworkBridgeProducerFlowControlTest.class.getSimpleName() + ".fast.shared?consumer.prefetchSize=1");

   doTestSendFailIfNoSpaceDoesNotBlockNetwork(SLOW_SHARED_QUEUE, FAST_SHARED_QUEUE);
}
 
Example #14
Source File: AuthorizationMapTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void testAuthorizationMap() {
   AuthorizationMap map = createAuthorizationMap();

   Set<?> readACLs = map.getReadACLs(new ActiveMQQueue("USERS.FOO.BAR"));
   assertEquals("set size: " + readACLs, 2, readACLs.size());
   assertTrue("Contains users group", readACLs.contains(ADMINS));
   assertTrue("Contains users group", readACLs.contains(USERS));

}
 
Example #15
Source File: QueueBrowsingTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testMemoryLimit() throws Exception {
   broker.getSystemUsage().getMemoryUsage().setLimit(16 * 1024);

   int messageToSend = 370;

   ActiveMQQueue queue = new ActiveMQQueue("TEST");
   Connection connection = factory.createConnection();
   connection.start();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(queue);

   String data = "";
   for (int i = 0; i < 1024 * 2; i++) {
      data += "x";
   }

   for (int i = 0; i < messageToSend; i++) {
      producer.send(session.createTextMessage(data));
   }

   QueueBrowser browser = session.createBrowser(queue);
   Enumeration<?> enumeration = browser.getEnumeration();
   int received = 0;
   while (enumeration.hasMoreElements()) {
      Message m = (Message) enumeration.nextElement();
      received++;
      LOG.info("Browsed message " + received + ": " + m.getJMSMessageID());
   }

   browser.close();
   assertTrue("got at least maxPageSize", received >= maxPageSize);
}
 
Example #16
Source File: AbstractCachedLDAPAuthorizationMapLegacyTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testQuery() throws Exception {
   map.query();
   Set<?> readACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
   assertEquals("set size: " + readACLs, 2, readACLs.size());
   assertTrue("Contains admin group", readACLs.contains(ADMINS));
   assertTrue("Contains users group", readACLs.contains(USERS));

   Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("FAILED"));
   assertEquals("set size: " + failedACLs, 0, failedACLs.size());
}
 
Example #17
Source File: IgniteJmsStreamerTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testQueueFromExplicitDestination() throws Exception {
    Destination dest = new ActiveMQQueue(QUEUE_NAME);

    // produce messages into the queue
    produceObjectMessages(dest, false);

    try (IgniteDataStreamer<String, String> dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) {
        JmsStreamer<ObjectMessage, String, String> jmsStreamer = newJmsStreamer(ObjectMessage.class, dataStreamer);
        jmsStreamer.setDestination(dest);

        // subscribe to cache PUT events and return a countdown latch starting at CACHE_ENTRY_COUNT
        CountDownLatch latch = subscribeToPutEvents(CACHE_ENTRY_COUNT);

        // start the streamer
        jmsStreamer.start();

        // all cache PUT events received in 10 seconds
        latch.await(10, TimeUnit.SECONDS);

        assertAllCacheEntriesLoaded();

        jmsStreamer.stop();
    }

}
 
Example #18
Source File: DestinationListenerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void testConsumerForcesNotificationOfNewDestination() throws Exception {
   // now lets cause a destination to be created
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   ActiveMQQueue newQueue = new ActiveMQQueue("Test.Cheese");
   session.createConsumer(newQueue);

   Thread.sleep(3000);

   assertThat(newQueue, isIn(newDestinations));

   LOG.info("New destinations are: " + newDestinations);
}
 
Example #19
Source File: SimpleOpenWireTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailoverTransportReconnect() throws Exception {
   Connection exConn = null;

   try {
      String urlString = "failover:(tcp://" + OWHOST + ":" + OWPORT + ")";
      ActiveMQConnectionFactory exFact = new ActiveMQConnectionFactory(urlString);

      Queue queue = new ActiveMQQueue(durableQueueName);

      exConn = exFact.createConnection();
      exConn.start();

      Session session = exConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer messageProducer = session.createProducer(queue);
      messageProducer.send(session.createTextMessage("Test"));

      MessageConsumer consumer = session.createConsumer(queue);
      assertNotNull(consumer.receive(5000));

      server.stop();
      Thread.sleep(3000);

      server.start();
      server.waitForActivation(10, TimeUnit.SECONDS);

      messageProducer.send(session.createTextMessage("Test2"));
      assertNotNull(consumer.receive(5000));
   } finally {
      if (exConn != null) {
         exConn.close();
      }
   }
}
 
Example #20
Source File: IgniteJmsStreamerTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testQueueFromName() throws Exception {
    Destination dest = new ActiveMQQueue(QUEUE_NAME);

    // produce messages into the queue
    produceObjectMessages(dest, false);

    try (IgniteDataStreamer<String, String> dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) {
        JmsStreamer<ObjectMessage, String, String> jmsStreamer = newJmsStreamer(ObjectMessage.class, dataStreamer);
        jmsStreamer.setDestinationType(Queue.class);
        jmsStreamer.setDestinationName(QUEUE_NAME);

        // subscribe to cache PUT events and return a countdown latch starting at CACHE_ENTRY_COUNT
        CountDownLatch latch = subscribeToPutEvents(CACHE_ENTRY_COUNT);

        jmsStreamer.start();

        // all cache PUT events received in 10 seconds
        latch.await(10, TimeUnit.SECONDS);

        assertAllCacheEntriesLoaded();

        jmsStreamer.stop();
    }

}
 
Example #21
Source File: NetworkReconnectTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {

   LOG.info("===============================================================================");
   LOG.info("Running Test Case: " + getName());
   LOG.info("===============================================================================");

   producerConnectionFactory = createProducerConnectionFactory();
   consumerConnectionFactory = createConsumerConnectionFactory();
   destination = new ActiveMQQueue("RECONNECT.TEST.QUEUE");

}
 
Example #22
Source File: AbstractCachedLDAPAuthorizationMapLegacyTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testSynchronousUpdate() throws Exception {
   map.setRefreshInterval(1);
   map.query();
   Set<?> readACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
   assertEquals("set size: " + readACLs, 2, readACLs.size());
   assertTrue("Contains admin group", readACLs.contains(ADMINS));
   assertTrue("Contains users group", readACLs.contains(USERS));

   Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("FAILED"));
   assertEquals("set size: " + failedACLs, 0, failedACLs.size());

   LdifReader reader = new LdifReader(getRemoveLdif());

   for (LdifEntry entry : reader) {
      connection.delete(entry.getDn());
   }

   reader.close();

   assertTrue("did not get expected size. ", Wait.waitFor(new Wait.Condition() {

      @Override
      public boolean isSatisified() throws Exception {
         return map.getReadACLs(new ActiveMQQueue("TEST.FOO")).size() == 0;
      }
   }));

   assertNull(map.getTempDestinationReadACLs());
   assertNull(map.getTempDestinationWriteACLs());
   assertNull(map.getTempDestinationAdminACLs());
}
 
Example #23
Source File: ActiveMQAdmin.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public void createQueue(String name) {
   try {
      context.bind(name, new ActiveMQQueue(name));
   } catch (NamingException e) {
      throw new RuntimeException(e);
   }
}
 
Example #24
Source File: ActiveJmsSender.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void sendToQueue(final String text, final String jmsQueueName) {
  if (text == null) {
    throw new NullPointerException("Attempting to send a null text message.");
  }
  Destination queue = new ActiveMQQueue(jmsQueueName);
  jmsTemplate.send(queue, new MessageCreator() {
    
    @Override
    public Message createMessage(Session session) throws JMSException {
      return session.createTextMessage(text);        
    }
    
  });
}
 
Example #25
Source File: TwoBrokerVirtualTopicForwardingTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void testDontBridgeQueuesWithOnlyQueueConsumers() throws Exception {
   dontBridgeVirtualTopicConsumerQueues("BrokerA", "BrokerB");

   startAllBrokers();
   waitForBridgeFormation();

   MessageConsumer clientA = createConsumer("BrokerA", createDestination("Consumer.A.VirtualTopic.tempTopic", false));
   MessageConsumer clientB = createConsumer("BrokerB", createDestination("Consumer.B.VirtualTopic.tempTopic", false));

   // give a sec to let advisories propagate
   Thread.sleep(500);

   ActiveMQQueue queueA = new ActiveMQQueue("Consumer.A.VirtualTopic.tempTopic");
   Destination destination = getDestination(brokers.get("BrokerA").broker, queueA);
   assertEquals(1, destination.getConsumers().size());

   ActiveMQQueue queueB = new ActiveMQQueue("Consumer.B.VirtualTopic.tempTopic");
   destination = getDestination(brokers.get("BrokerA").broker, queueB);
   assertNull(destination);

   ActiveMQTopic virtualTopic = new ActiveMQTopic("VirtualTopic.tempTopic");
   assertNull(getDestination(brokers.get("BrokerA").broker, virtualTopic));
   assertNull(getDestination(brokers.get("BrokerB").broker, virtualTopic));

   // send some messages
   sendMessages("BrokerA", virtualTopic, 1);

   MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
   MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);

   msgsA.waitForMessagesToArrive(1);
   msgsB.waitForMessagesToArrive(0);

   // ensure we don't get any more messages
   Thread.sleep(2000);

   assertEquals(1, msgsA.getMessageCount());
   assertEquals(0, msgsB.getMessageCount());
}
 
Example #26
Source File: DurableSubscriptionOfflineTestBase.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected Destination createDestination(String subject) {
   if (isTopic) {
      return new ActiveMQTopic(subject);
   } else {
      return new ActiveMQQueue(subject);
   }
}
 
Example #27
Source File: AbstractCachedLDAPAuthorizationMapLegacyTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testWildcards() throws Exception {
   map.query();
   Set<?> fooACLs = map.getReadACLs(new ActiveMQQueue("FOO.1"));
   assertEquals("set size: " + fooACLs, 2, fooACLs.size());
   assertTrue("Contains admin group", fooACLs.contains(ADMINS));
   assertTrue("Contains users group", fooACLs.contains(USERS));

   Set<?> barACLs = map.getReadACLs(new ActiveMQQueue("BAR.2"));
   assertEquals("set size: " + barACLs, 2, barACLs.size());
   assertTrue("Contains admin group", barACLs.contains(ADMINS));
   assertTrue("Contains users group", barACLs.contains(USERS));
}
 
Example #28
Source File: ActiveMessageReceiver.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Initialization method that must be called after bean creation. Sets the destination and registers as listener
 * in the Spring listener container.
 */
public void init() {
  ProcessConfiguration processConfiguration = ProcessConfigurationHolder.getInstance();
  log.debug("Setting ActiveMessageReceiver listener destination to {}", processConfiguration.getJmsDaqCommandQueue());
  listenerContainer.setMessageListener(this);
  listenerContainer.setDestination(new ActiveMQQueue(processConfiguration.getJmsDaqCommandQueue()));
  listenerContainer.initialize();
  listenerContainer.start();
}
 
Example #29
Source File: JobSchedulerTestSupport.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
   connectionUri = "vm://localhost";
   destination = new ActiveMQQueue(name.getMethodName());

   broker = createBroker();
   broker.start();
   broker.waitUntilStarted();

   jobScheduler = broker.getJobSchedulerStore().getJobScheduler("JMS");
}
 
Example #30
Source File: SimpleAuthenticationPluginSeparatorTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * @see {@link org.apache.activemq.CombinationTestSupport}
 */
@Override
public void initCombosForTestGuestReceiveFails() {
   addCombinationValues("userName", new Object[]{"guest"});
   addCombinationValues("password", new Object[]{"password"});
   addCombinationValues("destination", new Object[]{new ActiveMQQueue("TEST"), new ActiveMQTopic("TEST"), new ActiveMQQueue("USERS/FOO"), new ActiveMQTopic("USERS/FOO")});
}