public class SolConnection extends Object implements SolConnectionIF, SolConnectionEventSource, ExceptionListener, SessionEventHandler
| Modifier and Type | Method and Description |
|---|---|
void |
addConnectionConsumer(SolConnectionConsumerIF cons) |
void |
close()
Closes the connection.
|
ConnectionConsumer |
createConnectionConsumer(Destination destination,
String messageSelector,
ServerSessionPool sessionPool,
int maxMessages)
Creates a connection consumer for this connection (optional operation).
|
void |
createDefaultSubscriber() |
ConnectionConsumer |
createDurableConnectionConsumer(Topic topic,
String subscriptionName,
String messageSelector,
ServerSessionPool sessionPool,
int maxMessages)
Create a durable connection consumer for this connection (optional operation).
|
Session |
createSession(boolean transacted,
int acknowledgeMode)
Creates a
Session object. |
void |
deleteTemporaryQueue(SolTemporaryQueueIF queue) |
void |
deleteTemporaryTopic(SolTemporaryTopicIF topic) |
String |
getClientID()
Gets the client identifier for this connection.
|
String |
getClientName() |
ExceptionListener |
getExceptionListener()
Gets the
ExceptionListener object for this connection. |
JCSMPProperties |
getJCSMPProperties() |
JMSProperties |
getJMSProperties() |
JMSState |
getJMSState() |
ConnectionMetaData |
getMetaData()
Gets the metadata for this connection.
|
ConnectionProperties |
getProperties() |
void |
handleEvent(SessionEventArgs event)
Called when a session event notification is available.
|
void |
onException(JMSException exception)
Notifies user of a JMS exception.
|
void |
remove(SolSessionIF session) |
void |
removeConnectionConsumer(SolConnectionConsumerIF cons) |
void |
setClientID(String clientID)
Sets the client identifier for this connection.
|
void |
setConnectionEventListener(SolConnectionEventListener eventListener)
Called to set the
SolConnectionEventListener on a connection. |
void |
setExceptionListener(ExceptionListener listener)
Sets an exception listener for this connection.
|
void |
start()
Starts (or restarts) a connection's delivery of incoming messages.
|
void |
stop()
Temporarily stops a connection's delivery of incoming messages.
|
static JCSMPProperties |
toJCSMPProperties(JMSPropertyBean bean,
boolean connectionTypeXA) |
public JCSMPProperties getJCSMPProperties()
getJCSMPProperties in interface SolConnectionIFpublic JMSProperties getJMSProperties()
public void close()
throws JMSException
ConnectionSince a provider typically allocates significant resources outside the JVM on behalf of a connection, clients should close these resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.
There is no need to close the sessions, producers, and consumers of a closed connection.
Closing a connection causes all temporary destinations to be deleted.
When this method is invoked, it should not return until message
processing has been shut down in an orderly fashion. This means that all
message
listeners that may have been running have returned, and that all pending
receives have returned. A close terminates all pending message receives
on the connection's sessions' consumers. The receives may return with a
message or with null, depending on whether there was a message available
at the time of the close. If one or more of the connection's sessions'
message listeners is processing a message at the time when connection
close is invoked, all the facilities of the connection and
its sessions must remain available to those listeners until they return
control to the JMS provider.
Closing a connection causes any of its sessions' transactions
in progress to be rolled back. In the case where a session's
work is coordinated by an external transaction manager, a session's
commit and rollback methods are
not used and the result of a closed session's work is determined
later by the transaction manager.
Closing a connection does NOT force an
acknowledgment of client-acknowledged sessions.
Invoking the acknowledge method of a received message
from a closed connection's session must throw an
IllegalStateException. Closing a closed connection must
NOT throw an exception.
close in interface ConnectionJMSException - if the JMS provider fails to close the
connection due to some internal error. For
example, a failure to release resources
or to close a socket connection can cause
this exception to be thrown.public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
ConnectioncreateConnectionConsumer in interface Connectiondestination - the destination to accessmessageSelector - only messages with properties matching the
message selector expression are delivered. A value of null or
an empty string indicates that there is no message selector
for the message consumer.sessionPool - the server session pool to associate with this
connection consumermaxMessages - the maximum number of messages that can be
assigned to a server session at one timeJMSException - if the Connection object fails
to create a connection consumer due to some
internal error or invalid arguments for
sessionPool and
messageSelector.InvalidDestinationException - if an invalid destination is specified.InvalidSelectorException - if the message selector is invalid.ConnectionConsumerpublic ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
ConnectioncreateDurableConnectionConsumer in interface Connectiontopic - topic to accesssubscriptionName - durable subscription namemessageSelector - only messages with properties matching the
message selector expression are delivered. A value of null or
an empty string indicates that there is no message selector
for the message consumer.sessionPool - the server session pool to associate with this
durable connection consumermaxMessages - the maximum number of messages that can be
assigned to a server session at one timeJMSException - if the Connection object fails
to create a connection consumer due to some
internal error or invalid arguments for
sessionPool and
messageSelector.InvalidDestinationException - if an invalid destination
is specified.InvalidSelectorException - if the message selector is invalid.ConnectionConsumerpublic Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
ConnectionSession object.createSession in interface Connectiontransacted - 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,
Session.DUPS_OK_ACKNOWLEDGE, and
SupportedProperty.SOL_CLIENT_ACKNOWLEDGE.
(Supported since 5.1 SolOS-TR)
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,
SupportedProperty.SOL_CLIENT_ACKNOWLEDGEpublic String getClientID() throws JMSException
Connection
In releases prior to 5.0 SolOS-TR, the client identifier is automatically generated by the provider.
Calls to setClientID will have no effect on ClientID.getClientID in interface ConnectionJMSException - if the JMS provider fails to return
the client ID for this connection due
to some internal error.public String getClientName() throws JMSException
JMSExceptionpublic ExceptionListener getExceptionListener() throws JMSException
ConnectionExceptionListener object for this connection.
Not every Connection has an ExceptionListener
associated with it.getExceptionListener in interface ConnectionExceptionListener for this connection, or null.
if no ExceptionListener is associated
with this connection.JMSException - if the JMS provider fails to
get the ExceptionListener for this
connection.Connection.setExceptionListener(javax.jms.ExceptionListener)public ConnectionMetaData getMetaData() throws JMSException
ConnectiongetMetaData in interface ConnectionJMSException - if the JMS provider fails to
get the connection metadata for this connection.ConnectionMetaDatapublic void setClientID(String clientID) throws JMSException
ConnectionSets the Client ID used to register with the appliance running in SolOS-TR. "Client ID" is known as "Client Name" on the appliance. If specified, it must be a valid Topic name, and a maximum of 160 bytes in length when encoded as UTF-8. If not specified, an auto-generated client ID is used.Note that if you set the client-name before creating the connection (via SolConnectionFactory.setClientID), "Replace Duplicate Client Connections" will work as expected because it is not a name change.
setClientID in interface ConnectionclientID - the unique client identifierJMSException - on errorpublic void setExceptionListener(ExceptionListener listener) throws JMSException
ConnectionIf a JMS provider detects a serious problem with a connection, it
informs the connection's ExceptionListener, if one has been
registered. It does this by calling the listener's
onException method, passing it a JMSException
object describing the problem.
An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn their connection has failed.
A connection serializes execution of its
ExceptionListener.
A JMS provider should attempt to resolve connection problems itself before it notifies the client of them.
setExceptionListener in interface Connectionlistener - the exception listenerJMSException - if the JMS provider fails to
set the exception listener for this connection.public void start()
throws JMSException
Connectionstart on a connection that has already been
started is ignored.
startandstophas no effect on direct messaging.
start in interface ConnectionJMSException - if the JMS provider fails to start
message delivery due to some internal error.Connection.stop()public void stop()
throws JMSException
Connectionstart
method. When the connection is stopped,
delivery to all the connection's message consumers is inhibited:
synchronous receives block, and messages are not delivered to message
listeners.
This call blocks until receives and/or message listeners in progress have completed.
Stopping a connection has no effect on its ability to send messages.
A call to stop on a connection that has already been
stopped is ignored.
A call to stop must not return until delivery of messages
has paused. This means that a client can rely on the fact that none of
its message listeners will be called and that all threads of control
waiting for receive calls to return will not return with a
message until the
connection is restarted. The receive timers for a stopped connection
continue to advance, so receives may time out while the connection is
stopped.
If message listeners are running when stop is invoked,
the stop call must
wait until all of them have returned before it may return. While these
message listeners are completing, they must have the full services of the
connection available to them.
startandstophas no effect on direct messaging.
stop in interface ConnectionJMSException - if the JMS provider fails to stop
message delivery due to some internal error.Connection.start()public void remove(SolSessionIF session)
remove in interface SolConnectionIFpublic void removeConnectionConsumer(SolConnectionConsumerIF cons)
public void addConnectionConsumer(SolConnectionConsumerIF cons)
public void deleteTemporaryQueue(SolTemporaryQueueIF queue) throws JMSException
deleteTemporaryQueue in interface SolConnectionIFJMSExceptionpublic void deleteTemporaryTopic(SolTemporaryTopicIF topic) throws JMSException
deleteTemporaryTopic in interface SolConnectionIFJMSExceptionpublic ConnectionProperties getProperties()
getProperties in interface SolConnectionIFpublic void handleEvent(SessionEventArgs event)
SessionEventHandlerhandleEvent in interface SessionEventHandlerevent - The event to process.public void createDefaultSubscriber()
throws JCSMPException
createDefaultSubscriber in interface SolConnectionIFJCSMPExceptionpublic void onException(JMSException exception)
ExceptionListeneronException in interface ExceptionListenerexception - the JMS exceptionpublic static JCSMPProperties toJCSMPProperties(JMSPropertyBean bean, boolean connectionTypeXA)
public JMSState getJMSState()
getJMSState in interface SolConnectionIFpublic void setConnectionEventListener(SolConnectionEventListener eventListener)
SolConnectionEventSourceSolConnectionEventListener on a connection. It can
be reset by using a null argument.setConnectionEventListener in interface SolConnectionEventSourceeventListener - The listener to set; null to clear the listener.Copyright 2004-2020 Solace Corporation. All rights reserved.