SFRMDoSHandler

public class SFRMDoSHandler extends Component

The SFRMDoSHandler is a simple barrier to ensure there is ONLY one-thread working per segment. When an incoming message is received and prepare to process, the IMH invoke enter(SFRMMessage) asking the DoSHandler to insert the working record for this segment. Then if there is a duplicate message received, the DosHandler reject it due to the working record has already exist. Thus it guarantees ONE THREAD WORKING per segment semantics. CAUTION: When the thread in the working record is not alive, the DoSHandler considers the working record is redundant and ALLOW message with same composite key owning a barrier for that message. Creation Date: 28/6/2007

Author:Twinsen Tsang

Methods

enter

public boolean enter(SFRMMessage message)

Invoke for requesting a barrier for message. For this case, the requested barrier does not expire.

Parameters:
  • message – The incoming SFRM Message.
Returns:

if the message has been entered by other thread before, it return false. otherwise, the barrier for this message is created and the owner is the invocation thread.

enter

public boolean enter(SFRMMessage message, long lifetime)

Invoke for requesting a barrier for message.

Parameters:
  • message – The incoming SFRM Message.
  • lifetime – How long is the barrier expire in millisecond. The common use for this is managing timeout/retry for a message.
Returns:

if the message has been entered by other thread before, it return false. otherwise, the barrier for this message is created and the owner is the invocation thread.

exit

public boolean exit(SFRMMessage message)

Invoke for removing the barrier for a message. The internal barrier for this message is removed and therefore invocating enter(SFRMMessage) for this mesasge return true again.

Parameters:
  • message – The incoming SFRM Message.
Returns:

it returns true iff the working record exists and remove successfully.

getResolvedKey

public String getResolvedKey(SFRMMessage message)

Get the composite key from the message. What it does is generating one string indentifying the message. For example:

Input message id: test@message-id
Input segment type: PAYLOAD
Input segment number: 999

Then the resolved key is test@message-id_INBOX_PAYLOAD_999
Parameters:
  • message – The incoming SFRM Message.
Returns:

the composite key of thie SFRM Message.