Package javax.jms

Examples of javax.jms.TopicConnectionFactory


            Properties props = new Properties();
            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();
            Topic topic = (Topic) ctx.lookup("topicName");
            TopicSession session = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            TopicPublisher publisher = session.createPublisher(topic);
            if (message != null) {
                Message msg = session.createTextMessage(message);
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

            Properties props = new Properties();
            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();
            Topic topic = (Topic) ctx.lookup("topicName");
            TopicSession session = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            TopicPublisher publisher = session.createPublisher(topic);
            if (message != null) {
                Message msg = session.createTextMessage(message);
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

  private static final Logger log = Logger.getLogger(JNDITopicConnectionFactory.class);

    private TopicConnectionFactory getFactory() throws JMSException
    {
        Context ctx = null ;
        TopicConnectionFactory factory ;
       
        try
        {
            ctx = createContext() ;
            factory = (TopicConnectionFactory) ctx.lookup(getBinding());
View Full Code Here

            switch (cc.getType()) {
                case CONNECTION_TYPE: {
                    return factory.createConnection(cc.getUserName(), cc.getPassword());
                }
                case TOPIC_CONNECTION_TYPE: {
                    TopicConnectionFactory topicFactory = (TopicConnectionFactory) factory;
                    return topicFactory.createTopicConnection(cc.getUserName(), cc.getPassword());
                }
                case QUEUE_CONNECTION_TYPE: {
                    QueueConnectionFactory queueFactory = (QueueConnectionFactory) factory;
                    return queueFactory.createQueueConnection(cc.getUserName(), cc.getPassword());
                }
            }
        }
        switch (cc.getType()) {
            case CONNECTION_TYPE: {
                return factory.createConnection();
            }
            case TOPIC_CONNECTION_TYPE: {
                TopicConnectionFactory topicFactory = (TopicConnectionFactory) factory;
                return topicFactory.createTopicConnection();
            }
            case QUEUE_CONNECTION_TYPE: {
                QueueConnectionFactory queueFactory = (QueueConnectionFactory) factory;
                return queueFactory.createQueueConnection();
            }
View Full Code Here

        throws Exception
    {
        /* Create Naming-Context */
        Context ctx = new InitialContext(namingProps);
        /* Lookup 'administerable' Objects */
        TopicConnectionFactory tcf = (TopicConnectionFactory)ctx.lookup("TopicConnectionFactory");
        Topic                  t   = (Topic)ctx.lookup("testTopic");

        TopicConnection tc  = null;
        TopicSession s_send = null;
        TopicSession s_rec1 = null;
        TopicSession s_rec2 = null;
        try {
            /* Create a connection to the topic */
            tc = tcf.createTopicConnection("system", "system");
            /* Create a session on top of the connection which will be used only for
            sending messages, transacted and with auto-acknowledge-mode*/
            s_send = tc.createTopicSession(true, Session.AUTO_ACKNOWLEDGE);
            /* Create sessions on top of the connection which will be used only for
            receiving messages, transacted and with auto-acknowledge-mode */
 
View Full Code Here

        throws Exception
    {
        /* Create Naming-Context */
        Context ctx = new InitialContext(namingProps);
        /* Lookup 'administerable' Objects */
        TopicConnectionFactory tcf = (TopicConnectionFactory)ctx.lookup("TopicConnectionFactory");
        Topic                  t   = (Topic)ctx.lookup("testTopic");

        TopicConnection tc  = null;
        TopicSession s_send = null;
        TopicSession s_rec1 = null;
        TopicSession s_rec2 = null;
        try {
            final long start  = System.currentTimeMillis();
            final String type = Long.toString(start);
            /* Create a connection to the topic */
            tc = tcf.createTopicConnection("system", "system");
            /* Create a session on top of the connection which will be used only for
            sending messages, transacted and with auto-acknowledge-mode*/
            s_send = tc.createTopicSession(true, Session.AUTO_ACKNOWLEDGE);
            /* Create sessions on top of the connection which will be used only for
            receiving messages, transacted and with auto-acknowledge-mode */
 
View Full Code Here

        throws Exception
    {
        /* Create Naming-Context */
        Context ctx = new InitialContext(namingProps);
        /* Lookup 'administerable' Objects */
        TopicConnectionFactory tcf = (TopicConnectionFactory)ctx.lookup("TopicConnectionFactory");
        TopicConnection tc = null;
        TopicSession    ts = null;
        try {
            tc = tcf.createTopicConnection("system", "system");
            ts = tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

            String tn = "topic-" + System.currentTimeMillis();
            Topic topic = ts.createTopic(tn);

View Full Code Here

    {
        final String name = "mysubscriber";
        /* Create Naming-Context */
        Context ctx = new InitialContext(namingProps);
        /* Lookup 'administerable' Objects */
        TopicConnectionFactory tcf = (TopicConnectionFactory)ctx.lookup("TopicConnectionFactory");
        Topic topic = (Topic)ctx.lookup("testTopic");
        TopicConnection tc  = null;
        TopicSession    ts  = null;
        try {
            tc = tcf.createTopicConnection("system", "system");
            ts = tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

            int num = 1000;
            TopicPublisher tp = ts.createPublisher(topic);
            ObjectMessage om = ts.createObjectMessage(new Integer(num++));
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.