|
SonicMQ API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Connection
Implementation of a JMS Connection A JMS Connection is a client's active connection to its JMS provider. It will typically allocate provider resources outside the Java virtual machine.
Connections support concurrent use.
A Connection serves several purposes:
Due to the authentication and communication setup done when a Connection is created, a Connection is a relatively heavy-weight JMS object. Most clients will do all their messaging with a single Connection. Other more advanced applications may use several Connections. JMS does not architect a reason for using multiple connections; however, there may be operational reasons for doing so.
A JMS client typically creates a Connection; one or more Sessions; and a number of message producers and consumers. When a Connection is created it is in stopped mode. That means that no messages are being delivered.
It is typical to leave the Connection in stopped mode until setup is complete. At that point the Connection's start() method is called and messages begin arriving at the Connection's consumers. This setup convention minimizes any client confusion that may result from asynchronous message delivery while the client is still in the process of setting itself up.
A Connection can immediately be started and the setup can be done afterwards. Clients that do this must be prepared to handle asynchronous message delivery while they are still in the process of setting up.
A message producer can send messages while a Connection is stopped.
Connection
Method Summary | |
---|---|
Session |
createSession(boolean transacted,
int acknowledgeMode)
DOMAIN_UNIFICATION_todo: This declaration is only here to help stuff compile against the old JMS.jar file. |
java.lang.String[] |
getBrokerReconnectURLs()
Returns URLs available on the currently connected broker, that may be used for the purpose re-connection of fault-tolerant connections when temporary or permanent network failure is encountered. |
java.lang.String |
getBrokerURL()
Get URL of broker actually connected to. |
Channel |
getChannel(java.lang.String channelID)
Retrieve a reference to a channel with the given channelID. |
java.lang.String |
getConnectID()
Get the connect ID for this connection. |
int |
getConnectionState()
Get connection state, one of ACTIVE, RECONNECTING, FAILED or CLOSED. |
ConnectionStateChangeListener |
getConnectionStateChangeListener()
Get connection state change listener. |
java.lang.String |
getRoutingNodeName()
Returns the name of the DRA routing node currently associated with the connection. |
java.lang.String[] |
getStandbyBrokerReconnectURLs()
Returns URLs available on a standby broker, if any, which is paired for fault-tolerance with the currently connected broker, and that may be used for the purpose re-connection to a standby broker in the event of currently connected broker failure. |
java.util.Enumeration |
getUnfinishedChannelIDs()
Return an enumeration of channel identifiers. |
java.util.Enumeration |
getUnfinishedChannels()
Return an enumeration of channels. |
java.lang.String |
getUsername()
Get the user of this connection. |
boolean |
hasUnfinishedChannel(java.lang.String channelID)
Check if this connection has a channel with the given channelID. |
boolean |
hasUnfinishedChannels()
Check if this connection has any unfinished channels. |
boolean |
isFaultTolerant()
Returns true if the connection is fault tolerant For a connection to be fault-tolerant, fault-tolerant must be set in the ConnectionFactory, and the broker must support(be licensed for) fault-tolerance. |
boolean |
isSecure()
|
void |
setConnectionStateChangeListener(ConnectionStateChangeListener listener)
Set connection state change listener. |
void |
setPingInterval(long interval)
Enable/disable sending active pings on this connection. |
void |
setRejectionListener(RejectionListener rl)
Sets a listener to receive errors on messages rejected by the Broker when persistence is enabled and messages are sent asynchronously from the persistent store. |
Methods inherited from interface javax.jms.Connection |
---|
close, createConnectionConsumer, createDurableConnectionConsumer, getClientID, getExceptionListener, getMetaData, setClientID, setExceptionListener, start, stop |
Method Detail |
---|
java.lang.String getBrokerURL()
java.lang.String[] getStandbyBrokerReconnectURLs()
Re-connection is automatically performed by the client runtime. Standby broker reconnect URLs are provided for informational use.
The standby broker reconnect URLs are derived from the broker configuration. If a default routing URL is configured on the standby, this will be used for standby re-connection. Otherwise, standby broker acceptors URLs, configured with the same acceptor name as the currently connected broker URL are used for re-connection.
If called after the connection is closed, the last known standby reconnect URLs are returned.
If the currently connected broker is standalone, or, if from the configuration, no redundant URLs are present on the standby, or, if the connection is non fault-tolerant, null is returned.
getBrokerURL()
,
getBrokerReconnectURLs()
,
isFaultTolerant()
java.lang.String[] getBrokerReconnectURLs()
Re-connection is automatically performed by the client runtime. Broker reconnect URLs are provided for informational use.
The broker reconnect URLs are derived from the broker configuration. If a default routing URL is configured on the broker, the currently connected URL is used for reconnection. Otherwise, acceptors URLs, configured with the same acceptor name as the currently connectedURL are used for reconnection.
If called after the connection is closed, the last known reconnect URLs are returned.
If the connection is non fault-tolerant, returns null.
getBrokerURL()
,
getStandbyBrokerReconnectURLs()
,
isFaultTolerant()
java.lang.String getRoutingNodeName()
int getConnectionState()
A non fault-tolerant connection will never see a RECONNECTING value. This method may be called after the connection is closed.
Constants.ACTIVE
,
Constants.RECONNECTING
,
Constants.FAILED
,
Constants.CLOSED
,
ConnectionStateChangeListener
,
setConnectionStateChangeListener(ConnectionStateChangeListener)
,
getConnectionStateChangeListener()
void setConnectionStateChangeListener(ConnectionStateChangeListener listener)
ConnectionStateChangeListener
,
getConnectionStateChangeListener()
boolean isFaultTolerant()
For a connection to be fault-tolerant, fault-tolerant must be set in the ConnectionFactory, and the broker must support(be licensed for) fault-tolerance.
ConnectionFactory.setFaultTolerant(java.lang.Boolean)
boolean isSecure()
ConnectionStateChangeListener getConnectionStateChangeListener()
ConnectionStateChangeListener
,
setConnectionStateChangeListener(ConnectionStateChangeListener)
java.lang.String getConnectID()
java.lang.String getUsername()
void setPingInterval(long interval)
interval
- indicates the interval in seconds for sending a ping.
Setting interval to 0 or any negative value
effectively disables the ping.void setRejectionListener(RejectionListener rl) throws JMSException
rl
- an object that implements the RejectionListener interface
JMSException
boolean hasUnfinishedChannel(java.lang.String channelID) throws JMSException
channelID
- The channelID of the channel in question.
True
If this channel has an active channelID with
this given channelID.
JMSException
- If there is an internal JMS Error.boolean hasUnfinishedChannels() throws JMSException
True
If this connection has any unfinished channels.
JMSException
- If there is an internal JMS Error.Channel getChannel(java.lang.String channelID) throws JMSException, java.io.IOException
channelID
- The channelID of the channel in question.
JMSException
- If there is an internal JMS Error.
java.io.IOException
- If there is an IOException while the channel
is being recovered.java.util.Enumeration getUnfinishedChannels() throws JMSException, java.io.IOException
This method returns an enumeration of Channel objects.
JMSException
- If there is an internal JMS Error
java.io.IOException
- If there is an issue accessing channel recovery informationjava.util.Enumeration getUnfinishedChannelIDs() throws JMSException, java.io.IOException
JMSException
- If there is an internal JMS Error.
java.io.IOException
- If there is an issue accessing channel recovery information.Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
createSession
in interface Connection
transacted
- indicates whether the session is transactedacknowledgeMode
- indicates whether the consumer or the
client will acknowledge any messages it receives; ignored if the session
is transacted. Legal values are Session.AUTO_ACKNOWLEDGE
,
Session.CLIENT_ACKNOWLEDGE
, and
Session.DUPS_OK_ACKNOWLEDGE
.
JMSException
- if the Connection
object fails
to create a session due to some internal error or
lack of support for the specific transaction
and acknowledgement mode.Session.AUTO_ACKNOWLEDGE
,
Session.CLIENT_ACKNOWLEDGE
,
Session.DUPS_OK_ACKNOWLEDGE
|
SonicMQ API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |