Message Persistence


JMS defines two message delivery modes, persistent and non-persistent. This mode is set by the message sender or publisher in the JMSDeliveryMode message header field. Non-Persistent messages are never written to persistent storage. Persistent messages are logged to persistent storage when they are sent.

Messages with the persistent delivery mode are always written to persistent storage, except when they are published to a topic that has no durable subscribers. When a topic has no durable subscribers, there are no subscribers that need messages resent in the event of a server failure. Therefore, messages do not need to be saved, and performance is improved because disk I/O is not required.

This behavior is consistent with the JMS specification because durable subscribers for a topic cause published messages to be saved. However, non-durable subscribers that re-connect after a server failure are considered newly created subscribers and are not entitled to receive any messages created prior to the time they are created (that is, messages published before the subscriber re-connects are not resent).

File Locking

Each EMS server writes persistent messages to a store file. To prevent two servers from using the same store file, each server restricts access to its store file for the duration of the server process.

Windows

On Windows platforms, servers use the standard Windows CreateFile function, supplying FILE_SHARE_READ as the dwShareMode (third parameter position) to restrict access to other servers.

UNIX

On UNIX platforms, servers use the standard fcntl operating system call to implement cooperative file locking:

 
    struct flock fl; 
    int err; 
 
    fl.l_type = F_WRLCK;  
    fl.l_whence = 0;  
    fl.l_start = 0;  
    fl.l_len = 0; 
 
    err = fcntl(file, F_SETLK, &fl); 
 

To ensure correct locking, we recommend checking the operating system documentation for this call, since UNIX variants differ in their implementations.


TIBCO Enterprise Message Service™ User’s Guide
Software Release 4.3, February 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com