Class: Connection

Connection

Class that wraps an underlying external:LightstreamerClient connection into a JMS Extender compatible connection.

new Connection()

This method is not meant to be used directly. Creates a Connection object that wraps an underlying LightstreamerClient object into a JMS Extender compatible connection.

Method Summary

close
Closes the connection.
createSession
Creates a Session object.
getClientID
Gets the client identifier for this connection.
getExceptionListener
Gets the ExceptionListener object for this connection.
setClientID
Sets the client identifier for this connection.
setExceptionListener
Sets an exception listener for this connection.
start
Starts (or restarts) the connection's delivery of incoming messages.
stop
Temporarily stops the connection's delivery of incoming messages.

Method Detail

close()

Closes the connection. All message producers and consumers will be stopped and their subsequent use will cause an IllegalStateException. A call to Connection#close on a connection that has already been closed is ignored.
Implementation note: underlying subscriptions are unsubscribed and deleted. If the connection was created through a ConnectionFactory the underlying LightstreamerClient connection is also disconnected. This means any message being sent (JMS messages, acknowledges, unsubscriptions, etc.) may get lost if the library did not have enough time to deliver them.

createSession(sessionMode, acknowledgeMode) → {Session}

Creates a Session object.
This method may be called in 3 different ways:
  • No arguments: the session is created as non-transacted and with "AUTO_ACK" acknowledge mode.
  • One arguments: the argument is the session mode and must be a string specifying either "TRANSACTED" or an ancknowledge mode.
  • Two arguments: the first argument is the transacted flag and must be a boolean; the second argument is the acknowledge mode and must be a string.
Parameters:
Name Type Description
sessionMode String | Boolean In case of String, specifies the session mode. Can be one of the following: "TRANSACTED", "PRE_ACK", "AUTO_ACK", "CLIENT_ACK", "DUPS_OK" or "INDIVIDUAL_ACK".
In case of Boolean, specifies if the session is transacted.
acknowledgeMode String If the first argument is Boolean, specifies the type of acknowledge to be used for messages. Can be one of the following: "PRE_ACK", "AUTO_ACK", "CLIENT_ACK", "DUPS_OK" or "INDIVIDUAL_ACK".
See JMS Extender documentation for more information on acknowledge modes.
Returns:
Type
Session

getClientID() → {String}

Gets the client identifier for this connection. See JMS specifications for more information.
Returns:
Type
String

getExceptionListener() → {ExceptionListener}

Gets the ExceptionListener object for this connection.
Returns:
Type
ExceptionListener

setClientID(clientId)

Sets the client identifier for this connection. See JMS specifications for more information.
Implementation note: scalability considerations apply when the client ID is set, see JMS Extender documentation.
Parameters:
Name Type Description
clientId String the unique client identifier

setExceptionListener(exceptionListener)

Sets an exception listener for this connection. Many common JMS exceptions will be delivered asynchronously through this listener.
Parameters:
Name Type Description
exceptionListener ExceptionListener the exception listener meant to receive exceptions for this connection.

start()

Starts (or restarts) the connection's delivery of incoming messages. A call to Connection#start on a connection that has already been started is ignored.

stop()

Temporarily stops the connection's delivery of incoming messages. Delivery can be restarted using the connection's Connection#start method. A call to Connection#stop on a connection that has already been stopped is ignored.
Stopping a connection has no effect on its ability to send messages.
Implementation note: underlying subscriptions are unsubscribed but their item names are kept for a later restart.