Creating Jakarta Messaging Connections
When the appropriate Jakarta Messaging property values are set, call one of the following methods to create a Jakarta Messaging connection:
createConnection()—creates a Jakarta Messaging connection with the client authentication credentials provided through the System, Initial Context, JNDI, URL, and/or Connection Factory property sources.createXAConnection()—creates a Jakarta Messaging connection that supports XA Sessions with the client authentication credentials provided through the System, Initial Context, JNDI, URL, and/or Connection Factory property sources.createConnection(String username, String password)—When using basic client authentication (the default), this method creates a Jakarta Messaging connection using an explicit username and password. The provided username and password overwrite any value that was implicitly set through other Jakarta Messaging property sources.createXAConnection(String username, String password)—When using basic client authentication (the default), use this method to establish a Jakarta Messaging connection that supports XA Sessions using an explicit username and password. The provided username and password overwrite any value that was implicitly set through other Jakarta Messaging property sources.
- If a Connection Factory or XAConnection Factory object is looked up from the event broker (refer to Working with JNDI), the properties set for the JNDI connection are inherited by the subsequent Jakarta Messaging connection. A client can use these same Jakarta Messaging properties for the connection or choose to override them with new values when making the connection. For information on where each property can be specified, and the priority that is given to the property according to where it is specified, refer to Jakarta Messaging Properties Reference.
- By default, each Jakarta Messaging connection that is created uses its own processing context and thread. If you want each new connection to use the default context and its single processing thread, set the
InitialContextenvironment propertySOLACE_JMS_USE_DEFAULT_CONTEXTproperty totrue.
Starting Jakarta Messaging Connections
To begin receiving messages over a Jakarta Messaging connection, the client application must call the start() method after the connection is established.
Stopping or Closing Jakarta Messaging Connections
To stop or close a Jakarta Messaging connection, call one of the following methods:
Connection.stop()—Temporarily stops the delivery of incoming messages over the connection. When a connection is stopped, the delivery of messages to the connection’s consumers is inhibited: synchronous receives block, and messages are not delivered to message listeners. To restart the delivery of messages, callConnection.start().When using Guaranteed Transport, published Non-Persistent and Persistent messages are spooled for consumers when the connection is stopped; when the connection is restarted, the spooled messages are delivered. When using Direct Transport, the Non-Persistent messages are not spooled for consumers when the connection is stopped and they are discarded.
Connection.close()—Closes the connection.