private ActiveMQTopic lookupTopic(final String topicName, final boolean isTemporary) throws ActiveMQException { String topicNameToUse = topicName; if (enable1xPrefixes) { topicNameToUse = (isTemporary ? PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString() : PacketImpl.OLD_TOPIC_PREFIX.toString()) + topicName; } ActiveMQTopic topic; if (isTemporary) { topic = ActiveMQDestination.createTemporaryTopic(topicNameToUse); } else { topic = ActiveMQDestination.createTopic(topicNameToUse); } AddressQuery query = session.addressQuery(topic.getSimpleAddress()); if (!query.isExists() && !query.isAutoCreateAddresses()) { return null; } else { return topic; } }
public void deleteTemporaryTopic(final ActiveMQDestination tempTopic) throws JMSException { if (!tempTopic.isTemporary()) { throw new InvalidDestinationException("Not a temporary topic " + tempTopic); } try { AddressQuery response = session.addressQuery(tempTopic.getSimpleAddress()); if (!response.isExists()) { throw new InvalidDestinationException("Cannot delete temporary topic " + tempTopic.getName() + " does not exist"); } if (response.getQueueNames().size() > 1) { throw new IllegalStateException("Cannot delete temporary topic " + tempTopic.getName() + " since it has subscribers"); } SimpleString address = tempTopic.getSimpleAddress(); session.deleteQueue(address); connection.removeTemporaryQueue(address); } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
AddressQuery response = session.addressQuery(dest.getSimpleAddress());
AddressQuery response = session.addressQuery(new SimpleString(activeMQDestination.getAddress())); if (!response.isExists()) { if (response.isAutoCreateQueues()) {
AddressQuery response = session.addressQuery(dest.getSimpleAddress()); AddressQuery response = session.addressQuery(dest.getSimpleAddress());
ClientSession.AddressQuery response = session.addressQuery(jbd.getSimpleAddress());
ClientSession.AddressQuery query = clientSession.addressQuery(address);
@Override public void run() throws ActiveMQException { session.addressQuery(RandomUtil.randomSimpleString()); } });
@Override protected void createClient() { try { if (!session.addressQuery(address).isExists() && autoCreateQueue) { log.warn("{}: queue does not exist - creating queue: address = {}, name = {}", this.getClass().getSimpleName(), address.toString(), address.toString()); session.createQueue(address, address); } producer = session.createProducer(address); } catch (ActiveMQException amqEx) { throw new ActiveMQClientResourceException(String.format("Error creating producer for address %s", address.toString()), amqEx); } }
@Override protected void createClient() { try { if (!session.addressQuery(address).isExists() && autoCreateQueue) { log.warn("{}: queue does not exist - creating queue: address = {}, name = {}", this.getClass().getSimpleName(), address.toString(), address.toString()); session.createQueue(address, address); } producer = session.createProducer(address); } catch (ActiveMQException amqEx) { throw new ActiveMQClientResourceException(String.format("Error creating producer for address %s", address.toString()), amqEx); } }
@Override protected void createClient() { try { if (address != null && !session.addressQuery(address).isExists() && autoCreateQueue) { log.warn("queue does not exist - creating queue: address = {}, name = {}", address.toString(), address.toString()); session.createQueue(address, address); } producer = session.createProducer((SimpleString) null); } catch (ActiveMQException amqEx) { if (address == null) { throw new ActiveMQClientResourceException(String.format("Error creating producer for address %s", address.toString()), amqEx); } else { throw new ActiveMQClientResourceException("Error creating producer", amqEx); } } }
@Override protected void createClient() { try { if (address != null && !session.addressQuery(address).isExists() && autoCreateQueue) { log.warn("queue does not exist - creating queue: address = {}, name = {}", address.toString(), address.toString()); session.createQueue(address, address); } producer = session.createProducer((SimpleString) null); } catch (ActiveMQException amqEx) { if (address == null) { throw new ActiveMQClientResourceException(String.format("Error creating producer for address %s", address.toString()), amqEx); } else { throw new ActiveMQClientResourceException("Error creating producer", amqEx); } } }
public void deploy(TopicDeployment topicDeployment) throws Exception { if (!started) { throw new Exception("You must start() this class instance before deploying"); } String queueName = topicDeployment.getName(); boolean defaultDurable; try (ClientSession session = sessionFactory.createSession(false, false, false)) { defaultDurable = topicDeployment.isDurableSend(); ClientSession.AddressQuery query = session.addressQuery(new SimpleString(queueName)); if (!query.isExists()) session.createAddress(SimpleString.toSimpleString(queueName), RoutingType.MULTICAST, true); } destination.createTopicResource(queueName, defaultDurable, topicDeployment.getConsumerSessionTimeoutSeconds(), topicDeployment.isDuplicatesAllowed()); }
public void deploy(TopicDeployment topicDeployment) throws Exception { if (!started) { throw new Exception("You must start() this class instance before deploying"); } String queueName = topicDeployment.getName(); boolean defaultDurable; try (ClientSession session = sessionFactory.createSession(false, false, false)) { defaultDurable = topicDeployment.isDurableSend(); ClientSession.AddressQuery query = session.addressQuery(new SimpleString(queueName)); if (!query.isExists()) session.createAddress(SimpleString.toSimpleString(queueName), RoutingType.MULTICAST, true); } destination.createTopicResource(queueName, defaultDurable, topicDeployment.getConsumerSessionTimeoutSeconds(), topicDeployment.isDuplicatesAllowed()); }
private ActiveMQTopic lookupTopic(final String topicName, final boolean isTemporary) throws ActiveMQException { String topicNameToUse = topicName; if (enable1xPrefixes) { topicNameToUse = (isTemporary ? PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString() : PacketImpl.OLD_TOPIC_PREFIX.toString()) + topicName; } ActiveMQTopic topic; if (isTemporary) { topic = ActiveMQDestination.createTemporaryTopic(topicNameToUse); } else { topic = ActiveMQDestination.createTopic(topicNameToUse); } AddressQuery query = session.addressQuery(topic.getSimpleAddress()); if (!query.isExists() && !query.isAutoCreateAddresses()) { return null; } else { return topic; } }
private ActiveMQTopic lookupTopic(final String topicName, final boolean isTemporary) throws ActiveMQException { String topicNameToUse = topicName; if (enable1xPrefixes) { topicNameToUse = (isTemporary ? PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString() : PacketImpl.OLD_TOPIC_PREFIX.toString()) + topicName; } ActiveMQTopic topic; if (isTemporary) { topic = ActiveMQDestination.createTemporaryTopic(topicNameToUse); } else { topic = ActiveMQDestination.createTopic(topicNameToUse); } AddressQuery query = session.addressQuery(topic.getSimpleAddress()); if (!query.isExists() && !query.isAutoCreateAddresses()) { return null; } else { return topic; } }
private ActiveMQTopic lookupTopic(final String topicName, final boolean isTemporary) throws ActiveMQException { String topicNameToUse = topicName; if (enable1xPrefixes) { topicNameToUse = (isTemporary ? PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString() : PacketImpl.OLD_TOPIC_PREFIX.toString()) + topicName; } ActiveMQTopic topic; if (isTemporary) { topic = ActiveMQDestination.createTemporaryTopic(topicNameToUse); } else { topic = ActiveMQDestination.createTopic(topicNameToUse); } AddressQuery query = session.addressQuery(topic.getSimpleAddress()); if (!query.isExists() && !query.isAutoCreateAddresses()) { return null; } else { return topic; } }
private ActiveMQTopic lookupTopic(final String topicName, final boolean isTemporary) throws ActiveMQException { String topicNameToUse = topicName; if (enable1xPrefixes) { topicNameToUse = (isTemporary ? PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString() : PacketImpl.OLD_TOPIC_PREFIX.toString()) + topicName; } ActiveMQTopic topic; if (isTemporary) { topic = ActiveMQDestination.createTemporaryTopic(topicNameToUse); } else { topic = ActiveMQDestination.createTopic(topicNameToUse); } AddressQuery query = session.addressQuery(topic.getSimpleAddress()); if (!query.isExists() && !query.isAutoCreateAddresses()) { return null; } else { return topic; } }
@Test public void testManagementAddressAlwaysExists() throws Exception { ClientSession.AddressQuery query = session.addressQuery(new SimpleString("activemq.management")); assertTrue(query.isExists()); }
public void deploy(QueueDeployment queueDeployment) throws Exception { if (!started) { throw new Exception("You must start() this class instance before deploying"); } String queueName = queueDeployment.getName(); try (ClientSession session = sessionFactory.createSession(false, false, false)) { ClientSession.AddressQuery query = session.addressQuery(SimpleString.toSimpleString(queueName)); if (!query.isExists()) { session.createAddress(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, true); session.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), queueDeployment.isDurableSend()); } else { ClientSession.QueueQuery qquery = session.queueQuery(SimpleString.toSimpleString(queueName)); if (!qquery.isExists()) { session.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), queueDeployment.isDurableSend()); } } } destination.createQueueResource(queueName, queueDeployment.isDurableSend(), queueDeployment.getConsumerSessionTimeoutSeconds(), queueDeployment.isDuplicatesAllowed()); }