JMS, jmswebservice

Source: Internet
Author: User
Tags stomp

JMS, jmswebservice

First, download ActiveMQ. the following link lists all versions:
Http://activemq.apache.org/download-archives.html
Each version provides links for different operating systems:

 

The company's computer is windows and started with activemq. bat in the directory:

 

The default port number is 61616, which can be seen in conf/activemq. xml:

<transportConnectors>    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->    <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>    <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>    <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/></transportConnectors>

 

Related Maven dependency:

<dependency>    <groupId>javax.jms</groupId>    <artifactId>javax.jms-api</artifactId>    <version>2.0</version></dependency><dependency>    <groupId>org.apache.activemq</groupId>    <artifactId>activemq-core</artifactId>    <version>5.7.0</version></dependency>

 

Use javax. jms. Session to communicate with the JMS Provider:

ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(        ActiveMQConnection.DEFAULT_USER,        ActiveMQConnection.DEFAULT_PASSWORD, "tcp://localhost:61616");                                                                                                                                                Connection connection = connectionFactory.createConnection();connection.start();                                                                                                                                                Session session = connection.createSession(Boolean.TRUE,        Session.AUTO_ACKNOWLEDGE);

 

Then some destinations, senders, and sent content are all made by the session:

Destination destination = session. createQueue ("this is sparta !! "); MessageProducer producer = session. createProducer (destination); TextMessage message0 = session. createTextMessage (" this is Sparta !!! "); TextMessage message1 = session. createTextMessage (" this is also Sparta !!! "); TextMessage message2 = session. createTextMessage (" These are all Sparta !!! "); Producer. send (message0); producer. send (message1); producer. send (message2); session. commit ();

 

With producer, consumer is also available. The method for receiving messages is as follows:

MessageConsumer consumer = session.createConsumer(destination);System.out.println(((TextMessage) consumer.receive(10000)).getText());

 

The result is that the consumer goes to the receive one by one, just as the recipient confirms it in person.
Maybe we can let Listener do the following:

consumer.setMessageListener(new MessageListener() {    public void onMessage(Message message) {        try {            System.out.println("listener catched:::"+((TextMessage)message).getText());        } catch (JMSException e) {            e.printStackTrace();        }    }});

 

When this consumer is set to Listener, it cannot be received in the receive () method,
Otherwise, javax. jms. IllegalStateException: Cannot synchronously receive a message when a MessageListener is set

If you want to use publish/subscribe, simply change createQueue to createTopic, but you must understand that the Topic is stateless.

The complete code is as follows, Sender:

{ConnectionFactory connectionFactory = new ActiveMQConnectionFactory (ActiveMQConnection. DEFAULT_USER, ActiveMQConnection. DEFAULT_PASSWORD, "tcp: // localhost: 61616"); Connection connection = connectionFactory. createConnection (); connection. start (); Session session = connection. createSession (Boolean. TRUE, Session. AUTO_ACKNOWLEDGE); Destination destination = session. createQueue ("this is sparta !! "); MessageProducer producer = session. createProducer (destination); TextMessage message0 = session. createTextMessage (" this is Sparta !!! "); TextMessage message1 = session. createTextMessage (" this is also Sparta !!! "); TextMessage message2 = session. createTextMessage (" These are all Sparta !!! "); Producer. send (message0); producer. send (message1); producer. send (message2); session. commit ();}

 

Recipient:

{        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(                ActiveMQConnection.DEFAULT_USER,                ActiveMQConnection.DEFAULT_PASSWORD, "tcp://localhost:61616");;        Connection connection = connectionFactory.createConnection();        connection.start();                                                                                                                                                                                                                                                                Session session = connection.createSession(Boolean.FALSE,                Session.AUTO_ACKNOWLEDGE);                                                                                                                                                                                                                                                                Destination destination = session.createQueue("this is sparta!!");        MessageConsumer consumer = session.createConsumer(destination);        System.out.println(((TextMessage) consumer.receive(10000)).getText());        System.out.println(((TextMessage) consumer.receive(10000)).getText());        System.out.println(((TextMessage) consumer.receive(10000)).getText());    }

 


What is "JMS" on the Internet?

That's what sisters mean. You're right.

Mm: Sister

Gg: Brother

Dd: younger brother

Jj: Sister

Plmm: Pretty girl

Xdjm: siblings

Pfpf: admire

Pp: photo, but if it is pp, it means kick your ass.

Bt: abnormal. Compared with other sections of the cloud, the water version is a place where bt is found (she, it)

Zt: Re-posting, sometimes abbreviated as z.

Sl: Color wolf.

Bl: glass, not fragile, but gay

Bc: Idiot

Bd: Dumb

Ry: Demon

Lm: rogue

Pg: ass

Gf: girl friend, girlfriend

Bf: boy friend, boyfriend

Md: Damn it, you can use it with caution!

Tmd: ***, with a thick mouth, especially with caution!

Jjww: the way people speak

Sjb: Neurology

Pmp: flattering

Mpj: Butlers

Kick: Flat
Kh: sunflower is the master of the sunflower collection. A certain yunyun master has been trained in the environment, so no one calls its name, but calls it directly.

Khbd: sunflower collection

Pxjf

Js: profiteer

Sp: support, supported

Micro: a tone Auxiliary Word, dedicated for kh

Call, pig: Sleep

Porridge: Yes

Jam: Award

Bxcm: ice and snow smart

Lol: laugh out loud, laugh

Kfc: kxxx & fxxx & cxx

Pk: player kill, hacker, attack, can also be interpreted as the first batch after k

Btw: by the way, by the way

Ps: two meanings: btw or photoshop (a computer image repair software)

Cu: see you, goodbye

Bb: Baby, lover, child, byebye

Although Zhao Gong: super powerful

Manqing: manqing's ten torture techniques and the playfulness of our ancestors

Click it: cut down

Sauce purple: This way

Meals: meals

Film: Same pp, photo

Banzhu and Banzhu: moderators and forum administrators compare the water version to a small store.

Water Bucket, water ghost, Narcissus, Water King, water monster, jellyfish: refers to the irrigation madman, Jellyfish Special Women

Sailors: all sentient beings in the edition

Diver

Dinosaur: ugly mm

Crazy: unable to cope with the stimulus and abnormal behavior

Thx, 3x: thanks, thank you

Sigh: sigh

Cool: cool

Gay: gay, bl

Fag: Gay, bl

Pm: private messages of the Forum

Zip it: Shut up

Leecher: a vampire. It refers to a person who only knows how to ask for a shared reward and is severely despised.

Dl: download, download

Pub: ftp scanned on the Internet. It can temporarily upload and download files, or upload files to pubftp for sharing.

Brb: be right back, coming back soon

Ttyl: talk to you later.

Bbl: be back later will be back later

Kick your ass: Beat your ass

Ppl: people

Plz, pls: please, please

Bull ***, ***: Nonsense

Sorry ass: Poor guy, despising

So: General

Cutie: Sweetheart

D \ * amn: Depends on, he xx

Steamed Stuffed bun: Someone is ugly or stupid.

Powder: Very, Very

Cainiao, prawns, and beginners: New beginners

Laruence, prawns: Master

Wood Oil: No

Protein: bd + bc + sjb

Love Tiger Oil: I love u, I love you

Inverted: fainting, reverse

Table: No. For example, the table is too good.

When: faint sound

9494: that is

Pig doll: A good oral English from ccf

Explosive head: the words in the game, taking some... the rest of the full text>

What is "JMS" on the Internet?

That's what sisters mean. You're right.

Mm: Sister

Gg: Brother

Dd: younger brother

Jj: Sister

Plmm: Pretty girl

Xdjm: siblings

Pfpf: admire

Pp: photo, but if it is pp, it means kick your ass.

Bt: abnormal. Compared with other sections of the cloud, the water version is a place where bt is found (she, it)

Zt: Re-posting, sometimes abbreviated as z.

Sl: Color wolf.

Bl: glass, not fragile, but gay

Bc: Idiot

Bd: Dumb

Ry: Demon

Lm: rogue

Pg: ass

Gf: girl friend, girlfriend

Bf: boy friend, boyfriend

Md: Damn it, you can use it with caution!

Tmd: ***, with a thick mouth, especially with caution!

Jjww: the way people speak

Sjb: Neurology

Pmp: flattering

Mpj: Butlers

Kick: Flat
Kh: sunflower is the master of the sunflower collection. A certain yunyun master has been trained in the environment, so no one calls its name, but calls it directly.

Khbd: sunflower collection

Pxjf

Js: profiteer

Sp: support, supported

Micro: a tone Auxiliary Word, dedicated for kh

Call, pig: Sleep

Porridge: Yes

Jam: Award

Bxcm: ice and snow smart

Lol: laugh out loud, laugh

Kfc: kxxx & fxxx & cxx

Pk: player kill, hacker, attack, can also be interpreted as the first batch after k

Btw: by the way, by the way

Ps: two meanings: btw or photoshop (a computer image repair software)

Cu: see you, goodbye

Bb: Baby, lover, child, byebye

Although Zhao Gong: super powerful

Manqing: manqing's ten torture techniques and the playfulness of our ancestors

Click it: cut down

Sauce purple: This way

Meals: meals

Film: Same pp, photo

Banzhu and Banzhu: moderators and forum administrators compare the water version to a small store.

Water Bucket, water ghost, Narcissus, Water King, water monster, jellyfish: refers to the irrigation madman, Jellyfish Special Women

Sailors: all sentient beings in the edition

Diver

Dinosaur: ugly mm

Crazy: unable to cope with the stimulus and abnormal behavior

Thx, 3x: thanks, thank you

Sigh: sigh

Cool: cool

Gay: gay, bl

Fag: Gay, bl

Pm: private messages of the Forum

Zip it: Shut up

Leecher: a vampire. It refers to a person who only knows how to ask for a shared reward and is severely despised.

Dl: download, download

Pub: ftp scanned on the Internet. It can temporarily upload and download files, or upload files to pubftp for sharing.

Brb: be right back, coming back soon

Ttyl: talk to you later.

Bbl: be back later will be back later

Kick your ass: Beat your ass

Ppl: people

Plz, pls: please, please

Bull ***, ***: Nonsense

Sorry ass: Poor guy, despising

So: General

Cutie: Sweetheart

D \ * amn: Depends on, he xx

Steamed Stuffed bun: Someone is ugly or stupid.

Powder: Very, Very

Cainiao, prawns, and beginners: New beginners

Laruence, prawns: Master

Wood Oil: No

Protein: bd + bc + sjb

Love Tiger Oil: I love u, I love you

Inverted: fainting, reverse

Table: No. For example, the table is too good.

When: faint sound

9494: that is

Pig doll: A good oral English from ccf

Explosive head: the words in the game, taking some... the rest of the full text>

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.