use of org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactory 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 org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactory in project activemq-artemis by apache.
the class OutgoingConnectionTest method testInexistentUserOnCreateConnection.
@Test
public void testInexistentUserOnCreateConnection() throws Exception {
resourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
ActiveMQRAConnectionFactory qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
Connection conn = null;
try {
conn = qraConnectionFactory.createConnection("IDont", "Exist");
fail("Exception was expected");
} catch (JMSSecurityException expected) {
}
conn = qraConnectionFactory.createConnection("testuser", "testpassword");
conn.close();
try {
XAConnection xaconn = qraConnectionFactory.createXAConnection("IDont", "Exist");
fail("Exception was expected");
} catch (JMSSecurityException expected) {
}
XAConnection xaconn = qraConnectionFactory.createXAConnection("testuser", "testpassword");
xaconn.close();
try {
TopicConnection topicconn = qraConnectionFactory.createTopicConnection("IDont", "Exist");
fail("Exception was expected");
} catch (JMSSecurityException expected) {
}
TopicConnection topicconn = qraConnectionFactory.createTopicConnection("testuser", "testpassword");
topicconn.close();
try {
QueueConnection queueconn = qraConnectionFactory.createQueueConnection("IDont", "Exist");
fail("Exception was expected");
} catch (JMSSecurityException expected) {
}
QueueConnection queueconn = qraConnectionFactory.createQueueConnection("testuser", "testpassword");
queueconn.close();
mcf.stop();
}
use of org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactory in project activemq-artemis by apache.
the class IgnoreJTATest method testSendAndReceive.
private void testSendAndReceive(Boolean ignoreJTA) throws Exception {
setDummyTX();
setupDLQ(10);
resourceAdapter = newResourceAdapter();
if (ignoreJTA != null) {
resourceAdapter.setIgnoreJTA(ignoreJTA);
}
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
ActiveMQRAConnectionFactory qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
QueueConnection queueConnection = qraConnectionFactory.createQueueConnection();
Session s = queueConnection.createSession(true, Session.AUTO_ACKNOWLEDGE);
Queue q = ActiveMQJMSClient.createQueue(MDBQUEUE);
MessageProducer mp = s.createProducer(q);
MessageConsumer consumer = s.createConsumer(q);
Message message = s.createTextMessage("test");
mp.send(message);
s.commit();
queueConnection.start();
TextMessage textMessage = (TextMessage) consumer.receive(1000);
assertNotNull(textMessage);
assertEquals(textMessage.getText(), "test");
s.rollback();
textMessage = (TextMessage) consumer.receive(1000);
assertNotNull(textMessage);
assertEquals(textMessage.getText(), "test");
s.commit();
}
use of org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactory in project activemq-artemis by apache.
the class OutgoingConnectionJTATest method testSimpleMessageSendAndReceiveTransacted.
@Test
public void testSimpleMessageSendAndReceiveTransacted() throws Exception {
setDummyTX();
setupDLQ(10);
resourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
ActiveMQRAConnectionFactory qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
QueueConnection queueConnection = qraConnectionFactory.createQueueConnection();
Session s = queueConnection.createSession(true, Session.AUTO_ACKNOWLEDGE);
Queue q = ActiveMQJMSClient.createQueue(MDBQUEUE);
MessageProducer mp = s.createProducer(q);
MessageConsumer consumer = s.createConsumer(q);
Message message = s.createTextMessage("test");
mp.send(message);
s.commit();
queueConnection.start();
TextMessage textMessage = (TextMessage) consumer.receive(1000);
assertNotNull(textMessage);
assertEquals(textMessage.getText(), "test");
s.rollback();
textMessage = (TextMessage) consumer.receive(1000);
assertNotNull(textMessage);
assertEquals(textMessage.getText(), "test");
s.commit();
}
use of org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactory in project activemq-artemis by apache.
the class OutgoingConnectionNoJTATest method testSimpleMessageSendAndReceiveSessionTransacted2.
@Test
public void testSimpleMessageSendAndReceiveSessionTransacted2() throws Exception {
setupDLQ(10);
resourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setAllowLocalTransactions(true);
mcf.setResourceAdapter(resourceAdapter);
ActiveMQRAConnectionFactory qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
QueueConnection queueConnection = qraConnectionFactory.createQueueConnection();
Session s = queueConnection.createSession(Session.SESSION_TRANSACTED);
Queue q = ActiveMQJMSClient.createQueue(MDBQUEUE);
MessageProducer mp = s.createProducer(q);
MessageConsumer consumer = s.createConsumer(q);
Message message = s.createTextMessage("test");
mp.send(message);
s.commit();
queueConnection.start();
TextMessage textMessage = (TextMessage) consumer.receive(1000);
assertNotNull(textMessage);
assertEquals(textMessage.getText(), "test");
s.rollback();
textMessage = (TextMessage) consumer.receive(1000);
assertNotNull(textMessage);
assertEquals(textMessage.getText(), "test");
s.commit();
textMessage = (TextMessage) consumer.receiveNoWait();
assertNull(textMessage);
}
Aggregations