MotechEvent

public class MotechEvent implements Serializable

Motech Scheduled Event data carrier class. It contains a subject, to which listeners can subscribe and a payload in the form of a map of parameters. Instance of this class with event specific data will be sent by Motech Scheduler when a scheduled event is fired.

This class is immutable

Fields

EVENT_TYPE_KEY_NAME

public static final String EVENT_TYPE_KEY_NAME

PARAM_DISCARDED_MOTECH_EVENT

public static final String PARAM_DISCARDED_MOTECH_EVENT

PARAM_INVALID_MOTECH_EVENT

public static final String PARAM_INVALID_MOTECH_EVENT

PARAM_REDELIVERY_COUNT

public static final String PARAM_REDELIVERY_COUNT

Constructors

MotechEvent

public MotechEvent()

MotechEvent

public MotechEvent(String subject)

Constructs a MotechEvent with the given subject.

Parameters:
  • subject – the subject of the event
Throws:
  • IllegalArgumentException – if the subject is null or contains '*', '..'

MotechEvent

public MotechEvent(String subject, Map<String, Object> parameters)

Constructs a MotechEvent with the given subject and parameters.

Parameters:
  • subject – the subject of the event
  • parameters – the map of additional parameters
Throws:
  • IllegalArgumentException – if the subject is null or contains '*', '..'

Methods

equals

public boolean equals(Object o)

getId

public UUID getId()

Returns the universally unique identifier

Returns:the id

getMessageRedeliveryCount

public int getMessageRedeliveryCount()

Returns the motechEventRedeliveryCount from the parameters. This is incremented by the event system if the delivery fails, so it is equal to the number of failed deliveries. Any exception from the handler is counted as failure in this context. It cannot be larger than org.motechproject.event.messaging.MotechEventConfig.messageMaxRedeliveryCount

Returns:the number of message redeliveries

getParameters

public Map<String, Object> getParameters()

Returns the parameters, if null returns empty HashMap.

Returns:the map of the parameters

getSubject

public String getSubject()

Returns the name of the subject.

Returns:the subject

hashCode

public int hashCode()

incrementMessageRedeliveryCount

public void incrementMessageRedeliveryCount()

Increments the motechEventRedeliveryCount from the parameters. It is invoked by the event system if the delivery fails. If it is null, sets the value to 0.

setId

public void setId(UUID id)

Sets the id.

Parameters:
  • id – the universally unique identifier

toString

public String toString()