use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class ClusterTestBase method createAddressInfo.
protected void createAddressInfo(final int node, final String address, final RoutingType routingType, final int defaulMaxConsumers, boolean defaultPurgeOnNoConsumers) throws Exception {
AddressInfo addressInfo = new AddressInfo(new SimpleString(address));
addressInfo.addRoutingType(routingType);
servers[node].addOrUpdateAddressInfo(addressInfo);
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class UpdateQueueTest method testUpdateAddress.
@Test
public void testUpdateAddress() throws Exception {
ActiveMQServer server = createServer(true, true);
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
server.start();
SimpleString ADDRESS = SimpleString.toSimpleString("queue.0");
AddressInfo infoAdded = new AddressInfo(ADDRESS, RoutingType.ANYCAST);
server.addAddressInfo(infoAdded);
server.updateAddressInfo(ADDRESS, infoAdded.getRoutingTypes());
server.stop();
server.start();
AddressInfo infoAfterRestart = server.getPostOffice().getAddressInfo(ADDRESS);
Assert.assertEquals(infoAdded.getId(), infoAfterRestart.getId());
EnumSet<RoutingType> completeSet = EnumSet.allOf(RoutingType.class);
server.updateAddressInfo(ADDRESS, completeSet);
server.stop();
server.start();
infoAfterRestart = server.getPostOffice().getAddressInfo(ADDRESS);
// it was changed.. so new ID
Assert.assertNotEquals(infoAdded.getId(), infoAfterRestart.getId());
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class PendingDeliveriesTest method createQueue.
@Before
public void createQueue() throws Exception {
server.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("queue1"), RoutingType.ANYCAST));
server.createQueue(SimpleString.toSimpleString("queue1"), RoutingType.ANYCAST, SimpleString.toSimpleString("queue1"), null, true, false);
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class JMSServerManagerImpl method internalCreateQueue.
private synchronized boolean internalCreateQueue(final String queueName, final String jmsQueueName, final String selectorString, final boolean durable, final boolean autoCreated) throws Exception {
if (queues.get(queueName) != null) {
return false;
} else {
// Convert from JMS selector to core filter
String coreFilterString = null;
if (selectorString != null) {
coreFilterString = SelectorTranslator.convertToActiveMQFilterString(selectorString);
}
server.addOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString(queueName)).addRoutingType(RoutingType.ANYCAST));
AddressSettings as = server.getAddressSettingsRepository().getMatch(queueName);
server.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(coreFilterString), null, durable, false, true, false, false, as.getDefaultMaxConsumers(), as.isDefaultPurgeOnNoConsumers(), as.isAutoCreateAddresses());
// create the JMS queue with the logical name jmsQueueName and keeps queueName for its *core* queue name
queues.put(queueName, ActiveMQDestination.createQueue(queueName, jmsQueueName));
this.recoverregistryBindings(queueName, PersistedType.Queue);
return true;
}
}
use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.
the class FQQNOpenWireTest method testVirtualTopicFQQNAutoCreateQueue.
@Test
public void testVirtualTopicFQQNAutoCreateQueue() throws Exception {
Connection exConn = null;
SimpleString topic = new SimpleString("VirtualTopic.Orders");
SimpleString subscriptionQ = new SimpleString("Consumer.A");
// defaults are false via test setUp
this.server.addAddressInfo(new AddressInfo(topic, RoutingType.MULTICAST));
this.server.getAddressSettingsRepository().getMatch("VirtualTopic.#").setAutoCreateQueues(true);
try {
ActiveMQConnectionFactory exFact = new ActiveMQConnectionFactory();
exFact.setWatchTopicAdvisories(false);
exConn = exFact.createConnection();
exConn.start();
Session session = exConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createTopic(topic.toString());
MessageProducer producer = session.createProducer(destination);
Destination destinationFQN = session.createQueue(CompositeAddress.toFullQN(topic, subscriptionQ).toString());
MessageConsumer messageConsumerA = session.createConsumer(destinationFQN);
MessageConsumer messageConsumerB = session.createConsumer(destinationFQN);
TextMessage message = session.createTextMessage("This is a text message");
producer.send(message);
// only one consumer should get the message
TextMessage messageReceivedA = (TextMessage) messageConsumerA.receive(2000);
TextMessage messageReceivedB = (TextMessage) messageConsumerB.receive(2000);
assertTrue((messageReceivedA == null || messageReceivedB == null));
String text = messageReceivedA != null ? messageReceivedA.getText() : messageReceivedB.getText();
assertEquals("This is a text message", text);
messageConsumerA.close();
messageConsumerB.close();
} finally {
if (exConn != null) {
exConn.close();
}
}
}
Aggregations