A Durable Connection creates a cache on the local machine, to allow a producer to send a message even if the server is unavailable. Configuration of the base directory is explained in the preceding section. Within the base directory, a subdirectory is created for each connection. The subdirectory's takes the name of the Client ID of the durable connection.
For example, if the base directory for Durable Connection is: c:\\temp
db in myConnectionFactory, any connection created through myConnectionFactory creates its cache in c:\\temp
db. If there are two connections on the same machine, with clientIDs "client1" and "client2", the directory structure takes the format below:
c:\\temp
db
____ client1.ptp |
____ client2.ptp
Note: If Client ID is not set, FioranoMQ at runtime internally creates a Unique ID for that particular connection and a directory by the same name is created for client side caching.
However, it is recommended that the Client ID should be set in all instances of use of Durable connections because: An application cannot transfer pending messages upon restart, as a new ID is generated for that connection. Since the ID is a complex string, it is difficult to use CSP Message Browser to browse for client side persisted messages.
Messages sent by a client are identified by its clientID. If the client application is terminated, , upon restart the runtime library checks if there are any pending messages stored in the local cache of the connection. This check is performed on the basis of the client ID set on the connection. Pending messages are sent to the server. This operation is performed when the clientID is set by the application. If the application wishes to ignore previously cached messages, it needs to add the following flag in the Hash table passed as the environment to InitialContext used for looking up operations. "DONT_SEND_PREVIOUSLY_STORED_MESSAGES", "TRUE"
Use the following API available in the connection if the client application needs to exercise control over the time at which pending messages are to be transmitted:
public void sendPendingMessages ()
throws JMSException;
When the preceding method is used on a connection, the runtime invocation sends all pending messages for that connection to the server.
public void purgePendingMessages ()
throws JMSException;
The preceding method is used to purge all messages in the local cache published on the associated connection.
Note: Both the APIs require the casting of JMS Connection into fiorano.jms.runtime.ptp.FioranoQueueConnection or fiorano.jms.runtime.pubsub.FioranoTopicConnection. |