Package org.objectweb.joram.mom.dest
Class AcquisitionModule
- java.lang.Object
-
- org.objectweb.joram.mom.dest.AcquisitionModule
-
- All Implemented Interfaces:
ReliableTransmitter
public class AcquisitionModule extends Object implements ReliableTransmitter
TheAcquisitionModuleinterfaces between the acquisition destinations and the specifiedAcquisitionHandler.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classAcquisitionModule.AcquisitionTask
-
Field Summary
Fields Modifier and Type Field Description protected ObjectacquisitionHandlerThe acquisition logic.private AcquisitionModule.AcquisitionTaskacquisitionTaskThe task used to launch a new acquisition.private static booleanDEBUGprivate DestinationdestinationThe acquisition queue or topic using this module.private longexpirationThe duration of produced messages.private booleanisDaemonTells if acquisition is done on-demand using the acquisition task or with a daemon.private booleanisExpirationSettrueif the expiration property has been set.private booleanisPersistencySettrueif the persistence property has been set.private booleanisPersistentTells if the messages produced are persistent.private booleanisPrioritySettrueif the priority property has been set.private static Loggerloggerprivate longperiodThe period before subsequent acquisition if positive.private intpriorityThe priority of produced messages, default is 4.private booleanrunningtrueif the acquisition daemon is running.private AtomicLongtransmitCounterThe number of transmitted messages.
-
Constructor Summary
Constructors Constructor Description AcquisitionModule(Destination destination, String className, Properties properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientMessagesacquisitionNot(AcquisitionNot not, long msgCount)static voidcheckAcquisitionClass(String className)Verify that one and only one correct interface is implemented.voidclose()Closes the handler.longgetCount()Returns the number of transmitted messages Be careful this counter is reseted at each time the server starts.longgetExpiration()Returns the expiration value for produced messages.longgetPeriod()intgetPriority()Returns the priority of produced messages.booleanisMessagePersistent()Returns true if the messages produced are persistent.booleanisRunning()voidprocessMessages(ClientMessages cm)In request mode (period <= 0), a message received on the acquisition destination will launch an acquisition process.voidsetExpiration(long expiration)Sets the expiration value for produced messages.voidsetMessagePersistent(boolean isPersistent)Sets the DeliveryMode value for the produced messages.private voidsetMessagesInfo(List<Message> messages, long msgCount)voidsetPriority(int priority)Sets the priority of produced messages.voidsetProperties(Properties properties)Resets the acquisition properties.PropertiesstartHandler(Properties prop)Start the daemon.protected PropertiesstopHandler(Properties prop)Stop the daemon.private static Propertiestransform(Properties properties)voidtransmit(List<Message> messages, boolean persistent)Transmits a list of messages to the MOM in a reliable way: if persistent is set to true the messages have been persisted when the method returns and therefore can be safely acknowledged.voidtransmit(Message message, String messageId)Transmits a message to the MOM in a reliable way: if the message is persistent it has been persisted when the method returns and therefore can be safely acknowledged.
-
-
-
Field Detail
-
logger
private static final Logger logger
-
DEBUG
private static final boolean DEBUG
-
acquisitionHandler
protected Object acquisitionHandler
The acquisition logic.
-
priority
private int priority
The priority of produced messages, default is 4.
-
isPrioritySet
private boolean isPrioritySet
trueif the priority property has been set.
-
isPersistent
private boolean isPersistent
Tells if the messages produced are persistent.
-
isPersistencySet
private boolean isPersistencySet
trueif the persistence property has been set.
-
expiration
private long expiration
The duration of produced messages.
-
isExpirationSet
private boolean isExpirationSet
trueif the expiration property has been set.
-
destination
private final Destination destination
The acquisition queue or topic using this module.
-
period
private long period
The period before subsequent acquisition if positive.
-
acquisitionTask
private AcquisitionModule.AcquisitionTask acquisitionTask
The task used to launch a new acquisition.
-
isDaemon
private boolean isDaemon
Tells if acquisition is done on-demand using the acquisition task or with a daemon.
-
running
private boolean running
trueif the acquisition daemon is running.
-
transmitCounter
private AtomicLong transmitCounter
The number of transmitted messages.
-
-
Constructor Detail
-
AcquisitionModule
public AcquisitionModule(Destination destination, String className, Properties properties)
-
-
Method Detail
-
checkAcquisitionClass
public static void checkAcquisitionClass(String className) throws Exception
Verify that one and only one correct interface is implemented.- Throws:
Exception
-
transform
private static Properties transform(Properties properties)
-
isRunning
public boolean isRunning()
-
isMessagePersistent
public boolean isMessagePersistent()
Returns true if the messages produced are persistent.- Returns:
- true if the messages produced are persistent.
-
setMessagePersistent
public void setMessagePersistent(boolean isPersistent)
Sets the DeliveryMode value for the produced messages. If the parameter is true the messages produced are persistent.- Parameters:
isPersistent- if true the messages produced are persistent.
-
getPriority
public int getPriority()
Returns the priority of produced messages.- Returns:
- the priority of produced messages.
-
setPriority
public void setPriority(int priority)
Sets the priority of produced messages.- Parameters:
priority- the priority to set.
-
getExpiration
public long getExpiration()
Returns the expiration value for produced messages.- Returns:
- the expiration value for produced messages.
-
setExpiration
public void setExpiration(long expiration)
Sets the expiration value for produced messages.- Parameters:
expiration- the expiration to set.
-
getCount
public long getCount()
Returns the number of transmitted messages Be careful this counter is reseted at each time the server starts.- Returns:
- the number of transmitted messages
-
setProperties
public void setProperties(Properties properties)
Resets the acquisition properties.
-
processMessages
public void processMessages(ClientMessages cm)
In request mode (period <= 0), a message received on the acquisition destination will launch an acquisition process. If the message holds non-null properties, these properties are first transmitted to the handler.
In other modes (periodic mode or daemon), such a message should not be received, so it is forwarded to the DMQ.
-
startHandler
public Properties startHandler(Properties prop) throws Exception
Start the daemon.- Parameters:
prop- properties for start if needed- Returns:
- properties for the reply.
- Throws:
Exception
-
stopHandler
protected Properties stopHandler(Properties prop) throws Exception
Stop the daemon.- Parameters:
prop- properties for stop if needed- Returns:
- properties for the reply.
- Throws:
Exception
-
acquisitionNot
public ClientMessages acquisitionNot(AcquisitionNot not, long msgCount)
-
close
public void close()
Closes the handler.
-
transmit
public void transmit(Message message, String messageId)
Transmits a message to the MOM in a reliable way: if the message is persistent it has been persisted when the method returns and therefore can be safely acknowledged. The message ID is used to avoid duplicates if a server crash happens right after transmitting the message and before it has been acknowledged. It can benullif such duplicates are tolerated.- Specified by:
transmitin interfaceReliableTransmitter- Parameters:
message- the message to transmitmessageId- the unique ID of the transmitted message- See Also:
ReliableTransmitter
-
transmit
public void transmit(List<Message> messages, boolean persistent)
Transmits a list of messages to the MOM in a reliable way: if persistent is set to true the messages have been persisted when the method returns and therefore can be safely acknowledged. Be careful, the use of this transmit method does not allow to verify the duplication of messages.- Specified by:
transmitin interfaceReliableTransmitter- Parameters:
messages- the list of messages to transmitpersistent- true if the message must be persisted.- See Also:
ReliableTransmitter
-
getPeriod
public long getPeriod()
-
-