public static ManagedConnection create( final Connection connection ) { if ( (connection instanceof XAQueueConnection) && (connection instanceof XATopicConnection)) { return new ManagedXAQueueTopicConnection(connection); } else if (connection instanceof XAQueueConnection) { return new ManagedXAQueueConnection((XAQueueConnection) connection); } else if (connection instanceof XATopicConnection) { return new ManagedXATopicConnection((XATopicConnection) connection); } else if ( (connection instanceof QueueConnection) && (connection instanceof TopicConnection)) { return new ManagedQueueTopicConnection(connection); } else if (connection instanceof QueueConnection) { return new ManagedQueueConnection((QueueConnection) connection); } else if (connection instanceof TopicConnection) { return new ManagedTopicConnection((TopicConnection) connection); } else { return new ManagedConnection(connection); } }
/** * Create JMS {@link XASession} instance on top of the provided {@link Connection} instance. * * @param xAConnection JMS Connection. * @return Session instance. * @throws JMSConnectorException Error when creating the XASession. */ public XASession createXASession(XAConnection xAConnection) throws JMSConnectorException { try { if (logger.isDebugEnabled()) { logger.debug("Creating a new JMS XASession on: " + this.connectionFactoryString); } if (JMSConstants.JMS_SPEC_VERSION_1_1.equals(jmsSpec) || JMSConstants.JMS_SPEC_VERSION_2_0 .equals(jmsSpec)) { return xAConnection.createXASession(); } else if (JMSConstants.JMSDestinationType.QUEUE.equals(this.destinationType)) { return ((XAQueueConnection) (xAConnection)).createXAQueueSession(); } else { return ((XATopicConnection) (xAConnection)).createXATopicSession(); } } catch (JMSException e) { throw new JMSConnectorException( "JMS Exception while obtaining session for factory " + connectionFactoryString, e); } }
private void assertConnectionType(Connection conn, String type) { if ("generic".equals(type) || "queue".equals(type) || "topic".equals(type)) { //generic Assert.assertFalse(conn instanceof XAConnection); Assert.assertTrue(conn instanceof QueueConnection); Assert.assertFalse(conn instanceof XAQueueConnection); Assert.assertTrue(conn instanceof TopicConnection); Assert.assertFalse(conn instanceof XATopicConnection); } else if ("xa".equals(type) || "xa-queue".equals(type) || "xa-topic".equals(type)) { Assert.assertTrue(conn instanceof XAConnection); Assert.assertTrue(conn instanceof QueueConnection); Assert.assertTrue(conn instanceof XAQueueConnection); Assert.assertTrue(conn instanceof TopicConnection); Assert.assertTrue(conn instanceof XATopicConnection); } else { Assert.fail("Unknown connection type: " + type); } }
/** * 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 (ActiveMQRAConnectionFactoryImpl.trace) { 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 (ActiveMQRAConnectionFactoryImpl.trace) { ActiveMQRALogger.LOGGER.trace("Created topic 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 (ActiveMQRAConnectionFactoryImpl.trace) { ActiveMQRALogger.LOGGER.trace("createXATopicConnection()"); } ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION); if (ActiveMQRAConnectionFactoryImpl.trace) { ActiveMQRALogger.LOGGER.trace("Created topic connection: " + s); } return s; }
public ManagedXATopicConnection( XATopicConnection connection ) { super(connection); this.xaTopicConnection = connection; }
@Override public XATopicSession createXATopicSession() throws JMSException { return addSession( ((XATopicConnection) connection).createXATopicSession()); }
public XATopicConnection createXATopicConnection() throws JMSException { return (XATopicConnection) createActiveMQConnection(); }
public XATopicConnection createXATopicConnection(String userName, String password) throws JMSException { return (XATopicConnection) createActiveMQConnection(userName, password); }
private void assertXAConnection(Connection connection) { assertTrue("Should be an XAConnection", connection instanceof XAConnection); assertTrue("Should be an XATopicConnection", connection instanceof XATopicConnection); assertTrue("Should be an XAQueueConnection", connection instanceof XAQueueConnection); }
@Test public void testConnectionTypes() throws Exception { deployConnectionFactory(0, JMSFactoryType.CF, "ConnectionFactory", "/ConnectionFactory"); deployConnectionFactory(0, JMSFactoryType.QUEUE_XA_CF, "CF_QUEUE_XA_TRUE", "/CF_QUEUE_XA_TRUE"); deployConnectionFactory(0, JMSFactoryType.XA_CF, "CF_XA_TRUE", "/CF_XA_TRUE"); deployConnectionFactory(0, JMSFactoryType.QUEUE_CF, "CF_QUEUE", "/CF_QUEUE"); deployConnectionFactory(0, JMSFactoryType.TOPIC_CF, "CF_TOPIC", "/CF_TOPIC"); deployConnectionFactory(0, JMSFactoryType.TOPIC_XA_CF, "CF_TOPIC_XA_TRUE", "/CF_TOPIC_XA_TRUE"); Connection genericConnection = null; XAConnection xaConnection = null; QueueConnection queueConnection = null; TopicConnection topicConnection = null; XAQueueConnection xaQueueConnection = null; XATopicConnection xaTopicConnection = null; ConnectionFactory genericFactory = (ConnectionFactory) ic.lookup("/ConnectionFactory"); genericConnection = genericFactory.createConnection(); assertConnectionType(genericConnection, "generic"); XAConnectionFactory xaFactory = (XAConnectionFactory) ic.lookup("/CF_XA_TRUE"); xaConnection = xaFactory.createXAConnection(); assertConnectionType(xaConnection, "xa"); QueueConnectionFactory queueCF = (QueueConnectionFactory) ic.lookup("/CF_QUEUE"); queueConnection = queueCF.createQueueConnection(); assertConnectionType(queueConnection, "queue"); TopicConnectionFactory topicCF = (TopicConnectionFactory) ic.lookup("/CF_TOPIC"); topicConnection = topicCF.createTopicConnection(); assertConnectionType(topicConnection, "topic"); XAQueueConnectionFactory xaQueueCF = (XAQueueConnectionFactory) ic.lookup("/CF_QUEUE_XA_TRUE"); xaQueueConnection = xaQueueCF.createXAQueueConnection(); assertConnectionType(xaQueueConnection, "xa-queue"); XATopicConnectionFactory xaTopicCF = (XATopicConnectionFactory) ic.lookup("/CF_TOPIC_XA_TRUE"); xaTopicConnection = xaTopicCF.createXATopicConnection(); assertConnectionType(xaTopicConnection, "xa-topic"); genericConnection.close(); xaConnection.close(); queueConnection.close(); topicConnection.close(); xaQueueConnection.close(); xaTopicConnection.close(); undeployConnectionFactory("ConnectionFactory"); undeployConnectionFactory("CF_QUEUE_XA_TRUE"); undeployConnectionFactory("CF_XA_TRUE"); undeployConnectionFactory("CF_QUEUE"); undeployConnectionFactory("CF_TOPIC"); undeployConnectionFactory("CF_TOPIC_XA_TRUE"); }
public XATopicConnection createXATopicConnection() throws JMSException { return createXATopicConnection(user, password); }
public XATopicConnection createXATopicConnection(final String username, final String password) throws JMSException { return (XATopicConnection) createConnectionInternal(username, password, true, ActiveMQConnection.TYPE_TOPIC_CONNECTION); }
/** * Creates a XATopicConnection with the default user identity. * <p> The XATopicConnection is created in stopped mode. No messages * will be delivered until the <code>Connection.start</code> method * is explicitly called. * * @return A newly created XATopicConnection * @throws JMSException If creating the XATopicConnection fails due to some internal error. * @throws JMSSecurityException If client authentication fails due to an invalid user name or password. */ public XATopicConnection createXATopicConnection() throws JMSException { return (XATopicConnection) createXAConnection(); }
/** * Creates a XATopicConnection with the specified user identity. * <p> The XATopicConnection is created in stopped mode. No messages * will be delivered until the <code>Connection.start</code> method * is explicitly called. * * @param username the caller's user name * @param password the caller's password * @return A newly created XATopicConnection. * @throws JMSException If creating the XATopicConnection fails due to some internal error. * @throws JMSSecurityException If client authentication fails due to an invalid user name or password. */ public XATopicConnection createXATopicConnection(String username, String password) throws JMSException { return (XATopicConnection) createXAConnection(username, password); }