@Override public JMSContext createContext(String userName, String password) { return createContext(userName, password, Session.AUTO_ACKNOWLEDGE); }
@Override public XAJMSContext createXAContext() { return createXAContext(null, null); }
/** * Creates a Connection Factory instance * * @param cxManager The connection manager * @return javax.resource.cci.ConnectionFactory instance * @throws ResourceException Thrown if a connection factory can't be created */ @Override public Object createConnectionFactory(final ConnectionManager cxManager) throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createConnectionFactory(" + cxManager + ")"); } cm = cxManager; ActiveMQRAConnectionFactory cf = new ActiveMQRAConnectionFactoryImpl(this, cm); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created connection factory: " + cf + ", using connection manager: " + cm); } return cf; }
/** * Create a queue connection * * @param userName The user name * @param password The password * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public QueueConnection createQueueConnection(final String userName, final String password) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createQueueConnection(" + userName + ", ****)"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.QUEUE_CONNECTION); s.setUserName(userName); s.setPassword(password); validateUser(s); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created queue connection: " + s); } return s; }
/** * Create a topic connection * * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public TopicConnection createTopicConnection() throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createTopicConnection()"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.TOPIC_CONNECTION); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created topic connection: " + s); } return s; }
/** * Creates a Connection Factory instance * * @param cxManager The connection manager * @return javax.resource.cci.ConnectionFactory instance * @throws ResourceException Thrown if a connection factory can't be created */ @Override public Object createConnectionFactory(final ConnectionManager cxManager) throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createConnectionFactory(" + cxManager + ")"); } cm = cxManager; ActiveMQRAConnectionFactory cf = new ActiveMQRAConnectionFactoryImpl(this, cm); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created connection factory: " + cf + ", using connection manager: " + cm); } return cf; }
/** * Create a XA queue connection * * @param userName The user name * @param password The password * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public XAQueueConnection createXAQueueConnection(final String userName, final String password) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createXAQueueConnection(" + userName + ", ****)"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION); s.setUserName(userName); s.setPassword(password); validateUser(s); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created queue connection: " + s); } return s; }
/** * Create a connection * * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public Connection createConnection() throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createConnection()"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.CONNECTION); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created connection: " + s); } return s; }
@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(); }
/** * Create a XA topic connection * * @param userName The user name * @param password The password * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public XATopicConnection createXATopicConnection(final String userName, final String password) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createXATopicConnection(" + userName + ", ****)"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION); s.setUserName(userName); s.setPassword(password); validateUser(s); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created topic connection: " + s); } return s; }
/** * Create a XA queue connection * * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public XAQueueConnection createXAQueueConnection() throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createXAQueueConnection()"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created queue connection: " + s); } return s; }
@Override public JMSContext createContext() { return createContext(null, null); }
@Override public XAJMSContext createXAContext() { return createXAContext(null, null); }
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(); }
/** * Create a connection * * @param userName The user name * @param password The password * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public Connection createConnection(final String userName, final String password) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createConnection(" + userName + ", ****)"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.CONNECTION); s.setUserName(userName); s.setPassword(password); validateUser(s); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created connection: " + s); } return s; }
/** * Create a XA topic connection * * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public XATopicConnection createXATopicConnection() throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createXATopicConnection()"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created topic connection: " + s); } return s; }
@Override public JMSContext createContext(int sessionMode) { return createContext(null, null, sessionMode); }
@Override @Before public void setUp() throws Exception { useDummyTransactionManager(); super.setUp(); resourceAdapter = new ActiveMQResourceAdapter(); resourceAdapter.setEntries("[\"java://jmsXA\"]"); resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName()); MyBootstrapContext ctx = new MyBootstrapContext(); resourceAdapter.start(ctx); mcf = new ActiveMQRAManagedConnectionFactory(); mcf.setResourceAdapter(resourceAdapter); qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager); }
/** * Create a connection * * @param userName The user name * @param password The password * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public Connection createConnection(final String userName, final String password) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createConnection(" + userName + ", ****)"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.CONNECTION); s.setUserName(userName); s.setPassword(password); validateUser(s); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created connection: " + s); } return s; }
/** * Create a queue connection * * @return The connection * @throws JMSException Thrown if the operation fails */ @Override public QueueConnection createQueueConnection() throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createQueueConnection()"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.QUEUE_CONNECTION); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Created queue connection: " + s); } return s; }