use of javax.jms.JMSContext in project activemq-artemis by apache.
the class JMSTestBase method tearDown.
@Override
@After
public void tearDown() throws Exception {
try {
for (JMSContext jmsContext : contextSet) {
jmsContext.close();
}
} catch (RuntimeException ignored) {
// no-op
} finally {
contextSet.clear();
}
try {
if (conn != null)
conn.close();
} catch (Exception e) {
// no-op
}
namingContext.close();
jmsServer.stop();
server = null;
cf = null;
jmsServer = null;
namingContext = null;
MBeanServerFactory.releaseMBeanServer(mbeanServer);
mbeanServer = null;
ServiceUtils.setTransactionManager(null);
super.tearDown();
}
use of javax.jms.JMSContext in project activemq-artemis by apache.
the class OutgoingConnectionTest method testJMSContext.
@Test
public void testJMSContext() throws Exception {
resourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
ActiveMQRAConnectionFactory qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
JMSContext jmsctx = qraConnectionFactory.createContext(JMSContext.DUPS_OK_ACKNOWLEDGE);
assertEquals(JMSContext.DUPS_OK_ACKNOWLEDGE, jmsctx.getSessionMode());
}
use of javax.jms.JMSContext in project activemq-artemis by apache.
the class JMSContextTest method testCreateXAContextThrowsException.
@Test
public void testCreateXAContextThrowsException() throws Exception {
JMSContext jmsctx = qraConnectionFactory.createXAContext();
try {
jmsctx.createContext(JMSContext.AUTO_ACKNOWLEDGE);
fail("expected JMSRuntimeException");
} catch (JMSRuntimeException e) {
// pass
} catch (Exception e) {
fail("wrong exception thrown: " + e);
}
}
use of javax.jms.JMSContext in project activemq-artemis by apache.
the class OutgoingConnectionNoJTATest method testSimpleSendNoXAJMSContext.
@Test
public void testSimpleSendNoXAJMSContext() throws Exception {
Queue q = ActiveMQJMSClient.createQueue(MDBQUEUE);
try (ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession();
ClientConsumer consVerify = session.createConsumer(MDBQUEUE);
JMSContext jmsctx = qraConnectionFactory.createContext()) {
session.start();
// These next 4 lines could be written in a single line however it makes difficult for debugging
JMSProducer producer = jmsctx.createProducer();
producer.setProperty("strvalue", "hello");
TextMessage msgsend = jmsctx.createTextMessage("hello");
producer.send(q, msgsend);
ClientMessage msg = consVerify.receive(1000);
assertNotNull(msg);
assertEquals("hello", msg.getStringProperty("strvalue"));
}
}
use of javax.jms.JMSContext in project activemq-artemis by apache.
the class OutgoingConnectionNoJTATest method sessionNotTransactedTestNoActiveJTATx.
@Test
public void sessionNotTransactedTestNoActiveJTATx() throws Exception {
JMSContext context = qraConnectionFactory.createContext(JMSContext.AUTO_ACKNOWLEDGE);
assertEquals(context.getSessionMode(), JMSContext.AUTO_ACKNOWLEDGE);
}
Aggregations