Common methods of JMS

Source: Internet
Author: User

Import Javax.jms.connection;import Javax.jms.connectionfactory;import javax.jms.destination;import Javax.jms.message;import Javax.jms.messageconsumer;import Javax.jms.messagelistener;import javax.jms.Session; Import Javax.jms.textmessage;import Org.apache.activemq.activemqconnection;import Org.apache.activemq.activemqconnectionfactory;import Com.ailk.biapp.ci.localization.cntv.service.iusersynchronizationservice;import Com.asiainfo.biframe.utils.config.configure;import Com.asiainfo.biframe.utils.spring.SystemServiceLocator; Public classJmstopicreceiver { Public voidTopiclistener () {//ConnectionFactory: Connection Factory, JMS uses it to create a connectionConnectionFactory ConnectionFactory; //CONNECTION:JMS Client-to-JMS Provider connectionsConnection Connection =NULL; //Session: A thread that sends or receives a messageSession session; //Destination: The destination of the message, to whom the message is sent.Destination Destination; //consumer, message recipientMessageconsumer Consumer; String Activeurl= Configure.getinstance (). GetProperty ("Active_url"); String Topic= Configure.getinstance (). GetProperty ("topic_name"); ConnectionFactory=Newactivemqconnectionfactory (Activemqconnection.default_user, Activemqconnection.default_        PASSWORD, Activeurl); Try {                        //construction Gets the connection object from the factoryConnection =connectionfactory.createconnection (); //StartConnection.start (); //Get Operation ConnectionSession =connection.createsession (Boolean.false, Session.auto_acknowledge); //Test-queue is consistent with sender, one to create one to receiveDestination =session.createtopic (topic); Consumer=Session.createconsumer (destination); Consumer.setmessagelistener (NewMessageListener () { Public voidonMessage (Message message) {Try{textmessage txtmsg=(textmessage) message; String msg=Txtmsg.gettext (); //Incremental Sync users when topic is receivedIusersynchronizationservice Service =(Iusersynchronizationservice) systemservicelocator.getinstance (). GetService ("Usersynchronizationserviceimpl");                    Service.startincrementalsync (msg); } Catch(Exception e) {e.printstacktrace ();       }                }            }); } Catch(Exception e) {e.printstacktrace (); }    }    }

Common methods of JMS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.