Configuring replication type with a user exit
Based on a mailbox name, a message name, or any other parameter that is related to a message, you can configure the replication type to immediate (synchronous) or delayed (asynchronous) for a given payload, by defining a user exit.
To do a custom action on a message by calling an external program, you can configure the replication type of the message by defining a user exit. Examples of custom action are sending an email notification after determining the replication type or creating a backup of the payload. The custom action is performed by the user exit implementation that you provide. The custom action might be performed before or after the replication is completed. The user exit is called and run after a message is uploaded to a mailbox, and before a barrier is put to wait for immediate replication to complete. If the user exit returns synchronous, a barrier is created, and the message upload process is halted until the barrier is removed after the payload replication is completed. If the user exit returns asynchronous, the message is uploaded.
To configure the replication type with a user exit, specify the exit point class in a
property file using the key com.ibm.mailbox.replication.impl
. The
property must specify the qualified path for a class that implements the
com.ibm.mailbox.replication.IReplicationConfiguration
interface. You can configure a default for replication type in the same property file by
using the key com.ibm.mailbox.replication.type
. If the user exit is not
set, the system default, which is defined in the mailbox.properties
file is used to determine and complete the replication.
- If a user exit is defined, the user exit class is loaded and run to determine the replication type.
- If a user exit is not defined, the customer default from the property file is used as replication type. If customer default is also not configured, the system default of asynchronous (delayed) is used.
- If the user-defined property file is not available, the default replication type is asynchronous.
Following is an example user exit class:
import com.ibm.mailbox.common.enums.ReplicationType;
import com.ibm.mailbox.replication.IReplicationConfiguration;
public class SelectReplicationType implements IReplicationConfiguration {
public ReplicationType getReplicationType(String mailbox,
String messageName, String messageId, int messageSize) {
// if the message is in myMailbox, and the message size is less than 50000, use SYNCHRONOUS, otherwise use ASYNCHRONOUS
if (mailbox.equals("/myMailbox") && messageSize < 50000)
return ReplicationType.SYNCHRONOUS;
else
return ReplicationType.ASYNCHRONOUS;
}
}