use of javax.jms.QueueSession in project opennms by OpenNMS.
the class DaemonContextIT method canUseEmbeddedActiveMQBroker.
/**
* Verifies that the embedded ActiveMQ broker bootstraps successfully
* and is accessible using the provided connection factory.
*/
@Test
public void canUseEmbeddedActiveMQBroker() throws Throwable {
QueueConnection connection = activeMQConnectionFactory.createQueueConnection();
QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
TextMessage message = session.createTextMessage();
message.setText("ping");
QueueSender sender = session.createSender(session.createQueue("pong"));
sender.send(message);
}
use of javax.jms.QueueSession in project karaf by apache.
the class ArtemisDestinationSourceFactory method getNames.
private List<String> getNames(Connection connection, DestinationSource.DestinationType type) {
try {
QueueSession session = ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue managementQueue = session.createQueue("activemq.management");
QueueRequestor requestor = new QueueRequestor(session, managementQueue);
connection.start();
TextMessage m = session.createTextMessage();
m.setStringProperty("_AMQ_ResourceName", "broker");
m.setStringProperty("_AMQ_OperationName", "getQueueNames");
String routing = type == DestinationSource.DestinationType.Queue ? "ANYCAST" : "MULTICAST";
m.setText("[\"" + routing + "\"]");
Message reply = requestor.request(m);
String json = ((TextMessage) reply).getText();
List<?> array = (List<?>) JsonReader.read(new StringReader(json));
return (List<String>) array.get(0);
} catch (Exception e) {
return Collections.emptyList();
}
}
use of javax.jms.QueueSession in project wildfly by wildfly.
the class HelloMDB method sendReply.
private void sendReply(String msg, Queue destination, String messageID) throws JMSException {
QueueConnection conn = qFactory.createQueueConnection("guest", "guest");
try {
QueueSession session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
conn.start();
QueueSender sender = session.createSender(destination);
TextMessage message = session.createTextMessage(msg);
message.setJMSCorrelationID(messageID);
sender.send(message, DeliveryMode.NON_PERSISTENT, 4, 500);
} finally {
conn.close();
}
}
use of javax.jms.QueueSession in project wildfly by wildfly.
the class QueueTestMDB method sendReply.
private void sendReply(Queue destination, String messageID, Exception e) throws JMSException {
QueueConnection conn = qFactory.createQueueConnection();
try {
QueueSession session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
QueueSender sender = session.createSender(destination);
ObjectMessage message = session.createObjectMessage(e);
message.setJMSCorrelationID(messageID);
sender.send(message, DeliveryMode.NON_PERSISTENT, 4, 500);
} finally {
conn.close();
}
}
use of javax.jms.QueueSession in project wildfly by wildfly.
the class MessageDrivenTimeoutTestCase method sendMessage.
static Queue sendMessage(String text, String queueJndi, InitialContext initCtx) throws Exception {
QueueConnection connection = getConnection(initCtx);
connection.start();
Queue replyDestination = null;
try {
final QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
final Message message = session.createTextMessage(text);
replyDestination = (Queue) initCtx.lookup(TransactionTimeoutQueueSetupTask.REPLY_QUEUE_JNDI_NAME);
message.setJMSReplyTo(replyDestination);
final Destination destination = (Destination) initCtx.lookup(queueJndi);
final MessageProducer producer = session.createProducer(destination);
producer.send(message);
producer.close();
} finally {
connection.close();
}
return replyDestination;
}
Aggregations