use of javax.jms.QueueRequestor in project wildfly by wildfly.
the class DestinationConfiguration method createQueue.
public void createQueue(ConnectionFactory cf, Queue managementQueue, String queueName) throws JMSException, StartException {
try (Connection connection = createQueueConnection(cf);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
connection.start();
QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);
Message m = session.createMessage();
if (getSelector() != null && !getSelector().isEmpty()) {
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "createQueue", queueName, queueName, getSelector(), isDurable(), RoutingType.ANYCAST.name());
} else {
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "createQueue", queueName, queueName, isDurable(), RoutingType.ANYCAST.name());
}
Message reply = requestor.request(m);
ROOT_LOGGER.infof("Creating queue %s returned %s", queueName, reply);
requestor.close();
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
String body = reply.getBody(String.class);
if (!destinationAlreadyExist(body)) {
throw ROOT_LOGGER.remoteDestinationCreationFailed(queueName, body);
}
}
ROOT_LOGGER.infof("Queue %s has been created", queueName);
}
}
use of javax.jms.QueueRequestor in project wildfly by wildfly.
the class DestinationConfiguration method destroyTopic.
public void destroyTopic(ConnectionFactory cf, Queue managementQueue, String topicName) throws JMSException {
try (Connection connection = createQueueConnection(cf);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
connection.start();
QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "deleteAddress", topicName, true);
Message reply = requestor.request(m);
requestor.close();
ROOT_LOGGER.debugf("Deleting topic " + topicName + " returned " + reply);
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
throw ROOT_LOGGER.remoteDestinationDeletionFailed(topicName, reply.getBody(String.class));
}
ROOT_LOGGER.debugf("Topic %s has been deleted", topicName);
}
}
use of javax.jms.QueueRequestor in project wildfly by wildfly.
the class DestinationConfiguration method createTopic.
public void createTopic(ConnectionFactory cf, Queue managementQueue, String topicName) throws JMSException, StartException {
try (Connection connection = createQueueConnection(cf);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
connection.start();
QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "createAddress", topicName, RoutingType.MULTICAST.name());
Message reply = requestor.request(m);
ROOT_LOGGER.infof("Creating topic %s returned %s", topicName, reply);
requestor.close();
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
String body = reply.getBody(String.class);
if (!destinationAlreadyExist(body)) {
throw ROOT_LOGGER.remoteDestinationCreationFailed(topicName, body);
}
}
ROOT_LOGGER.infof("Topic %s has been created", topicName);
}
}
use of javax.jms.QueueRequestor in project wildfly by wildfly.
the class MDB20TopicTestCase method getRemoteNumberOfAllSubscriptions.
private int getRemoteNumberOfAllSubscriptions(String topicName) throws Exception {
QueueRequestor requestor = new QueueRequestor((QueueSession) session, ActiveMQJMSClient.createQueue("activemq.management"));
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putAttribute(m, ResourceNames.ADDRESS + "jms.topic." + topicName, "QueueNames");
Message reply = requestor.request(m);
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
throw new RuntimeException(reply.getBody(String.class));
}
Object[] result = (Object[]) JMSManagementHelper.getResult(reply);
return result.length;
}
use of javax.jms.QueueRequestor in project wildfly by wildfly.
the class RemoteActiveMQProviderJMSOperations method createRemoteTopic.
private void createRemoteTopic(String topicName) {
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616", "guest", "guest");
try (Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
connection.start();
Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "createAddress", topicName, RoutingType.MULTICAST.name());
Message reply = requestor.request(m);
System.out.println("Creating topic " + topicName + " returned " + reply);
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
String body = reply.getBody(String.class);
if (!destinationAlreadyExist(body)) {
System.out.println("Creation of topic " + topicName + " has failed because of " + body);
throw new JMSOperationsException("Creation of topic " + topicName + " has failed because of " + body);
}
}
} catch (JMSException ex) {
ex.printStackTrace();
throw new JMSOperationsException(ex);
}
System.out.println("Topic " + topicName + " has been created");
}
Aggregations