use of org.apache.activemq.artemis.jms.client.ActiveMQDestination in project activemq-artemis by apache.
the class EmbeddedJMSResource method getTopicQueues.
/**
* Get the Queues corresponding to a JMS Topic.
* <p>
* The full name of the JMS Topic including the prefix should be provided - i.e. topic://myTopic. If the destination type prefix
* is not included in the destination name, a prefix of "topic://" is assumed.
*
* @param topicName the full name of the JMS Destination
* @return the number of messages in the JMS Destination
*/
public List<Queue> getTopicQueues(String topicName) {
List<Queue> queues = new LinkedList<>();
ActiveMQDestination destination = ActiveMQDestination.createDestination(topicName, ActiveMQDestination.TYPE.TOPIC);
if (!destination.isQueue()) {
BindingQueryResult bindingQueryResult = null;
try {
bindingQueryResult = jmsServer.getActiveMQServer().bindingQuery(destination.getSimpleAddress());
} catch (Exception ex) {
log.error(String.format("getTopicQueues( %s ) - bindingQuery for %s failed", topicName, destination.getAddress()), ex);
return queues;
}
if (bindingQueryResult.isExists()) {
ActiveMQServer activeMQServer = jmsServer.getActiveMQServer();
for (SimpleString queueName : bindingQueryResult.getQueueNames()) {
queues.add(activeMQServer.locateQueue(queueName));
}
}
}
return queues;
}
use of org.apache.activemq.artemis.jms.client.ActiveMQDestination in project activemq-artemis by apache.
the class EmbeddedJMSResource method pushMessage.
public void pushMessage(String destinationName, Message message) {
if (destinationName == null) {
throw new IllegalArgumentException("sendMessage failure - destination name is required");
} else if (message == null) {
throw new IllegalArgumentException("sendMessage failure - a Message is required");
}
ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.TYPE.QUEUE);
getInternalClient().pushMessage(destination, message);
}
use of org.apache.activemq.artemis.jms.client.ActiveMQDestination in project activemq-artemis by apache.
the class ActiveMQDestinationTest method testFromAddressWithQueueAddressPrefix.
@Test
public void testFromAddressWithQueueAddressPrefix() throws Exception {
String destinationName = RandomUtil.randomString();
String address = QUEUE_QUALIFIED_PREFIX + destinationName;
ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address);
Assert.assertTrue(destination instanceof Queue);
Assert.assertEquals(destinationName, ((Queue) destination).getQueueName());
}
use of org.apache.activemq.artemis.jms.client.ActiveMQDestination in project activemq-artemis by apache.
the class ActiveMQDestinationTest method testFromAddressWithInvalidPrefix.
@Test
public void testFromAddressWithInvalidPrefix() throws Exception {
String invalidPrefix = "junk";
String destinationName = RandomUtil.randomString();
String address = invalidPrefix + destinationName;
ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address);
Assert.assertTrue(destination instanceof Destination);
}
use of org.apache.activemq.artemis.jms.client.ActiveMQDestination in project activemq-artemis by apache.
the class ActiveMQDestinationTest method testFromAddressWithTopicAddressPrefix.
@Test
public void testFromAddressWithTopicAddressPrefix() throws Exception {
String destinationName = RandomUtil.randomString();
String address = TOPIC_QUALIFIED_PREFIX + destinationName;
ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address);
Assert.assertTrue(destination instanceof Topic);
Assert.assertEquals(destinationName, ((Topic) destination).getTopicName());
}
Aggregations