use of javax.jms.QueueConnection in project qpid-broker-j by apache.
the class QueueSessionTest method testQueueSessionCannotUnsubscribe.
@Test
public void testQueueSessionCannotUnsubscribe() throws Exception {
QueueConnection queueConnection = getQueueConnection();
try {
QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
try {
queueSession.unsubscribe("abc");
fail("expected exception did not occur");
} catch (javax.jms.IllegalStateException s) {
// PASS
}
} finally {
queueConnection.close();
}
}
use of javax.jms.QueueConnection in project wildfly by wildfly.
the class MessageDrivenTimeoutTestCase method receiveMessage.
static String receiveMessage(Queue replyQueue, InitialContext initCtx) throws Exception {
QueueConnection connection = getConnection(initCtx);
connection.start();
try {
final QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
final QueueReceiver receiver = session.createReceiver(replyQueue);
final Message reply = receiver.receive(TimeoutUtil.adjust(5000));
// waiting for synchro could be finished before checking
Thread.sleep(TimeoutUtil.adjust(500));
if (reply == null)
return null;
return ((TextMessage) reply).getText();
} finally {
connection.close();
}
}
use of javax.jms.QueueConnection in project activemq-artemis by apache.
the class QueueReceiverTest method testCreateReceiverWithMessageSelector.
/**
* com.sun.ts.tests.jms.ee.all.queueconn.QueueConnTest line 171
*/
@Test
public void testCreateReceiverWithMessageSelector() throws Exception {
QueueConnection qc = null;
try {
qc = createQueueConnection();
QueueSession qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueReceiver qreceiver = qs.createReceiver(queue1, "targetMessage = TRUE");
qc.start();
TextMessage m = qs.createTextMessage();
m.setText("one");
m.setBooleanProperty("targetMessage", false);
QueueSender qsender = qs.createSender(queue1);
qsender.send(m);
m.setText("two");
m.setBooleanProperty("targetMessage", true);
qsender.send(m);
TextMessage rm = (TextMessage) qreceiver.receive(1000);
ProxyAssertSupport.assertEquals("two", rm.getText());
} finally {
if (qc != null) {
qc.close();
}
Thread.sleep(2000);
removeAllMessages(queue1.getQueueName(), true);
checkEmpty(queue1);
}
}
use of javax.jms.QueueConnection in project activemq-artemis by apache.
the class SessionTest method testCreateTopicOnAQueueSession.
@Test
public void testCreateTopicOnAQueueSession() throws Exception {
QueueConnection c = (QueueConnection) getConnectionFactory().createConnection();
QueueSession s = c.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
try {
s.createTopic("TestTopic");
ProxyAssertSupport.fail("should throw IllegalStateException");
} catch (javax.jms.IllegalStateException e) {
// OK
}
c.close();
}
use of javax.jms.QueueConnection in project activemq-artemis by apache.
the class OutgoingConnectionTest method testSharedActiveMQConnectionFactoryWithClose.
@Test
public void testSharedActiveMQConnectionFactoryWithClose() throws Exception {
Session s = null;
Session s2 = null;
ActiveMQRAManagedConnection mc = null;
ActiveMQRAManagedConnection mc2 = null;
try {
server.getConfiguration().setSecurityEnabled(false);
resourceAdapter = new ActiveMQResourceAdapter();
resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
ActiveMQRAConnectionManager qraConnectionManager = new ActiveMQRAConnectionManager();
ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
ActiveMQRAConnectionFactory qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
QueueConnection queueConnection = qraConnectionFactory.createQueueConnection();
s = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
mc = (ActiveMQRAManagedConnection) ((ActiveMQRASession) s).getManagedConnection();
QueueConnection queueConnection2 = qraConnectionFactory.createQueueConnection();
s2 = queueConnection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
mc2 = (ActiveMQRAManagedConnection) ((ActiveMQRASession) s2).getManagedConnection();
mc.destroy();
MessageProducer producer = s2.createProducer(ActiveMQJMSClient.createQueue(MDBQUEUE));
producer.send(s2.createTextMessage("x"));
} finally {
if (s != null) {
s.close();
}
if (mc != null) {
mc.destroy();
}
if (s2 != null) {
s2.close();
}
if (mc2 != null) {
mc2.destroy();
}
}
}
Aggregations