Package javax.jms

Examples of javax.jms.TopicConnectionFactory


                testJmsConnection(connectionFactory.createConnection());

                obj = ctx.lookup("java:comp/env/TopicCF");
                Assert.assertNotNull("The JMS TopicConnectionFactory is null", obj);
                Assert.assertTrue("Not an instance of TopicConnectionFactory", obj instanceof TopicConnectionFactory);
                TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
                testJmsConnection(topicConnectionFactory.createConnection());

                obj = ctx.lookup("java:comp/env/QueueCF");
                Assert.assertNotNull("The JMS QueueConnectionFactory is null", obj);
                Assert.assertTrue("Not an instance of QueueConnectionFactory", obj instanceof QueueConnectionFactory);
                QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
View Full Code Here


    private void addAQDestinationContext(Context context) throws NamingException {

        // lookup and cache the queues
        QueueConnectionFactory queueFactory;
        QueueConnection queueConnection = null;
        TopicConnectionFactory topicFactory;
        TopicConnection topicConnection = null;
        AQjmsSession session = null;
        try {
            // create a datasource to use - datasources can keep the
            // username/password for later use
            DataSource ds = null;
            XADataSource xaDs = null;
            try {
                if (aqConnectionUrl != null)
                {
                    ds = AQUtil.getSQLDataSource(aqConnectionUrl, dbuser, dbpass);
                    xaDs = AQUtil.getXASQLDataSource(aqConnectionUrl, dbuser, dbpass);
                }
                else
                {
                    ds = AQUtil.getSQLDataSource( aqServerName, aqServerDBInst, aqServerPortNumber, aqDBDriver, dbuser, dbpass);
                    xaDs = AQUtil.getXASQLDataSource(aqServerName, aqServerDBInst, aqServerPortNumber, aqDBDriver, dbuser, dbpass);
                }
            } catch (SQLException e) {
                throw new RuntimeException(e.getMessage());
            }

            XAConnectionFactory factory = AQjmsFactory.getXAConnectionFactory(xaDs);
            context.rebind(XA_CONNECTION_FACTORY, factory);
            context.rebind("KURTSTAM", new String("hello"));

            // create the connection factory
            ConnectionFactory connectionFactory = AQjmsFactory.getConnectionFactory(ds);
            context.rebind(CONNECTION_FACTORY, connectionFactory);

            // create the queue connection factory
            queueFactory = AQjmsFactory.getQueueConnectionFactory(ds);
            context.rebind(QUEUE_CONNECTION_FACTORY, queueFactory);
            queueConnection = queueFactory.createQueueConnection();
            session = (AQjmsSession) queueConnection.createQueueSession(false,
                    Session.AUTO_ACKNOWLEDGE);

            // create the queue XA connection factory
            XAQueueConnectionFactory xaQueueConnectionFactory = AQjmsFactory.getXAQueueConnectionFactory(xaDs);
            context.rebind(XA_QUEUE_CONNECTION_FACTORY, xaQueueConnectionFactory);

//          create the topic XA connection factory
            XATopicConnectionFactory xaTopicConnectionFactory = AQjmsFactory.getXATopicConnectionFactory(xaDs);
            context.rebind(XA_TOPIC_CONNECTION_FACTORY, xaTopicConnectionFactory);

            // create the topic connection factory
            topicFactory = AQjmsFactory.getTopicConnectionFactory(ds);
            context.rebind(TOPIC_CONNECTION_FACTORY, topicFactory);
            topicConnection = topicFactory.createTopicConnection();
            session = (AQjmsSession) topicConnection.createTopicSession(false,
                    Session.AUTO_ACKNOWLEDGE);
            List<DestinationInfo> list = AQUtil.getDestinationInfoList(ds, aqSchemaName);
            // for each queue
            Iterator<DestinationInfo> iter = list.iterator();
View Full Code Here

      environment.setProperty(Context.URL_PKG_PREFIXES, Environment.JBOSS_URL_PKG_PREFIX);
      final Context oCtx = NamingContextPool.getNamingContext(environment);
      try {
  TopicConnection oTconn = null;
  TopicSession   oTsess = null;
  TopicConnectionFactory qcf = (TopicConnectionFactory) oCtx
    .lookup("ConnectionFactory");

  oTconn = qcf.createTopicConnection();
  oTsess = oTconn.createTopicSession(false
      ,QueueSession.AUTO_ACKNOWLEDGE);
    Topic oT = (Topic) oCtx.lookup(p_sJndi);
    TopicSubscriber oRcv = oTsess.createSubscriber(oT);
    oTconn.start();
View Full Code Here

      boolean bIsTopic = Boolean.parseBoolean(obtainAtt(p_oP,
          COMMAND_IS_TOPIC, "false"));
      if (bIsTopic)
      {
        TopicConnectionFactory tcf = (TopicConnectionFactory) oFactCls;
        TopicConnection oTC = tcf.createTopicConnection();
        TopicSession oSess = oTC.createTopicSession(false,
            TopicSession.AUTO_ACKNOWLEDGE);
        Topic oTopic = null;
        try
        {
View Full Code Here

                testJmsConnection(connectionFactory.createConnection());

                obj = ejbContext.lookup("TopicCF");
                Assert.assertNotNull("The JMS TopicConnectionFactory is null", obj);
                Assert.assertTrue("Not an instance of TopicConnectionFactory", obj instanceof TopicConnectionFactory);
                TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
                testJmsConnection(topicConnectionFactory.createConnection());

                obj = ejbContext.lookup("QueueCF");
                Assert.assertNotNull("The JMS QueueConnectionFactory is null", obj);
                Assert.assertTrue("Not an instance of QueueConnectionFactory", obj instanceof QueueConnectionFactory);
                QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
View Full Code Here

        String userName = server.getAttribute("username");
        String password = server.getAttribute("password");
        String clientId = server.getAttribute("client-id");

        InitialContext jndi = null;
        TopicConnectionFactory factory = null;
        TopicConnection con = null;

        try {
            jndi = JNDIContextFactory.getInitialContext(serverName);
            factory = (TopicConnectionFactory) jndi.lookup(jndiName);
        } catch (GeneralException ge) {
            throw new GenericServiceException("Problems getting JNDI InitialContext.", ge.getNested());
        } catch (NamingException ne) {
            JNDIContextFactory.clearInitialContext(serverName);
            try {
                jndi = JNDIContextFactory.getInitialContext(serverName);
                factory = (TopicConnectionFactory) jndi.lookup(jndiName);
            } catch (GeneralException ge2) {
                throw new GenericServiceException("Problems getting JNDI InitialContext.", ge2.getNested());
            } catch (NamingException ne2) {
                throw new GenericServiceException("JNDI lookup problems.", ne);
            }
        }

        try {
            con = factory.createTopicConnection(userName, password);

            if (clientId != null && clientId.length() > 1)
                con.setClientID(clientId);
            con.start();
View Full Code Here

   
    private class MessagePublisher implements Runnable{
        private final boolean shouldPublish = true;
       
        public void run(){
            TopicConnectionFactory topicConnectionFactory = null;
            TopicConnection topicConnection = null;
            TopicSession topicSession = null;
            Topic topic = null;
            TopicPublisher topicPublisher = null;
            Message message = null;
           
            topicConnectionFactory = new ActiveMQConnectionFactory(CONNECTION_URL);
            try {
                topic = new ActiveMQTopic(TOPIC_NAME);
                topicConnection = topicConnectionFactory.createTopicConnection();
                topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
                topicPublisher = topicSession.createPublisher(topic);
                message = topicSession.createMessage();
            } catch (Exception ex) {
                exceptions.add(ex);
View Full Code Here

       
public JmsClient_1() throws Exception {
       
    Context jndiContext = getInitialContext();
   
    TopicConnectionFactory factory = (TopicConnectionFactory)
     //   jndiContext.lookup("java:comp/env/jms/TopicFactory");
    jndiContext.lookup("titan-TopicFactory");

   // Topic topic = (Topic) jndiContext.lookup("java:comp/env/jms/TicketTopic");
     Topic topic = (Topic) jndiContext.lookup("titan-TicketTopic");
    TopicConnection connect = factory.createTopicConnection();

    TopicSession session =
        connect.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

    TopicSubscriber subscriber = session.createSubscriber(topic);
View Full Code Here

   
    private class MessagePublisher implements Runnable{
        private final boolean shouldPublish = true;
       
        public void run(){
            TopicConnectionFactory topicConnectionFactory = null;
            TopicConnection topicConnection = null;
            TopicSession topicSession = null;
            Topic topic = null;
            TopicPublisher topicPublisher = null;
            Message message = null;
           
            topicConnectionFactory = new ActiveMQConnectionFactory(CONNECTION_URL);
            try {
                topic = new ActiveMQTopic(TOPIC_NAME);
                topicConnection = topicConnectionFactory.createTopicConnection();
                topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
                topicPublisher = topicSession.createPublisher(topic);
                message = topicSession.createMessage();
            } catch (Exception ex) {
                exceptions.add(ex);
View Full Code Here

            props.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
            props.put("java.naming.provider.url", "tcp://localhost:61616");
            props.put("topic.topicName", topicName);

            javax.naming.Context ctx = new InitialContext(props);
            TopicConnectionFactory factory = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
            TopicConnection conn = factory.createTopicConnection();
            final Topic topic = (Topic) ctx.lookup("topicName");
            TopicSession session = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            TopicSubscriber receiver = session.createSubscriber(topic, selectors, false);

            receiver.setMessageListener(new MessageListener() {
View Full Code Here

TOP

Related Classes of javax.jms.TopicConnectionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.