简体   繁体   中英

JMS Connection - start method (IBM MQ impl)

What is javax.jms.Connection#start() really is for. According to javadoc it says:

Starts (or restarts) a connection's delivery of incoming messages.

But what does that exactly means? I guess it depends on implementation so what does it means in IBM MQ (latest 8+)? Maybe after that client connection will pre-cache server messages? I've checked some examples of producer and they are calling the start method but never read messages. I tested code without calling start() and it worked fine (sending, not receiving).

I'm just trying understand MQ maybe more under the hood than needed but still i would like to know. Maybe also how it's done in other JMS implementations? like Tibco, Apache MQ? Maybe someone knows?

Exactly as the document mentions, Connection.start method starts the delivery of messages from messaging provider(in this case MQ) to application. A consumer will not be able to receive messages without calling Connection.start.

A connection.start is not required for sending messages. Have a look at the JmsConsumer.java sample shipped with MQ. It calls connection.start. Can you post your sample code that is receiving messages without calling connection.start?

Exactly as Shashi says. If you have a message consumer and a call receive on it before calling connection.start() you get receive giving any messages. Start the connection and you'll get messages.

Likewise if you have a message listener set, it won't start getting any messages until connection.start() is called.

In both cases nothing will be received, even if messages are on the queue, until connection.start() is called.

In terms of internals - is there some behaviour you're seeing that you can't explain? Can you clarify.

JMS2.0 Contexts are auto-start so if you're using the new API call to start isn't required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM