public class EventData extends Object
EventNotifier
,
EventManager
,
EventStatus
,
EventSubscriber
Constructor and Description |
---|
EventData(String eventNameOrTopic,
Object data)
Creates an event data.
|
EventData(String eventNameOrTopic,
Object data,
ServicesManager servicesManager)
Creates an event data.
|
Modifier and Type | Method and Description |
---|---|
void |
addAdditionalMetadata(String key,
Object value)
Adds additional metadata of the event.
|
void |
addStatusObserver(BiConsumer<EventStatus,EventData> observer)
Adds the observer for the status change event.
|
boolean |
canNotify()
Checks whether it is time for the event to be notified or not.
|
boolean |
equals(Object obj) |
static List<EventData> |
fromJson(String jsonString)
Generates a list of events from given JSON string representation.
|
Map<String,Object> |
getAdditionalMetadata()
Gets the collection of all additional metadata of the event.
|
Object |
getAdditionalMetadata(String metadataName)
Gets the additional metadata with specified name.
|
String |
getAppId()
Gets the Fabric application id.
|
String |
getAppName()
Gets the Fabric application name.
|
Object |
getData()
Gets the data of the event.
|
int |
getDelayNotificationInMilliseconds()
Gets the time in milliseconds to delay the notification of the event.
|
String |
getId()
Gets the unique id of the event.
|
EventMonitoringData |
getMonitoringData()
Gets the monitoring data of the event.
|
String |
getProducer()
Gets the producer of the event.
|
ServicesManager |
getServicesManager()
Gets the
ServicesManager associated with the event. |
EventStatus |
getStatus()
Gets the current status of the event.
|
long |
getTimestamp()
Gets the timestamp of the event in milliseconds.
|
String |
getTopic()
Gets the name or topic of the event.
|
String |
getType()
Gets the type of the event.
|
UserProfile |
getUserProfile()
Gets the
UserProfile which contain information like user id, first
name, last name and email id. |
int |
hashCode() |
void |
notify(EventSubscriber eventSubscriber,
int retryCount)
Notifies the subscriber of this event.
|
void |
removeAllStatusObservers()
Removes all the observers for the status change event.
|
void |
setDelayNotificationInMilliseconds(int delayNotificationInMilliseconds)
Sets the time in milliseconds to delay the notification of the event.
|
void |
setProducer(String producer)
Sets the producer of the event.
|
void |
setStatus(EventStatus status)
Sets the status of the event.
|
void |
setType(String type)
Sets the type of the event.
|
String |
toJson()
Returns JSON string representation of the event.
|
String |
toString() |
boolean |
waitForProcessing(long processingWaitTimeInMilliseconds)
Waits for processing of the event to be completed.
|
public EventData(String eventNameOrTopic, Object data)
eventNameOrTopic
- The name or topic of the event.data
- The data of the event.EventData(String, Object, ServicesManager)
public EventData(String eventNameOrTopic, Object data, ServicesManager servicesManager)
eventNameOrTopic
- The name or topic of the event.data
- The data of the event.servicesManager
- The ServicesManager
. This is needed to add
Identity attributes like UserProfile
to the event.EventData(String, Object)
,
getAppId()
,
getAppName()
,
getUserProfile()
public String getId()
public long getTimestamp()
System.currentTimeMillis()
public String getTopic()
public Object getData()
public String getAppId()
EventData(String, Object, ServicesManager)
is used to create
event.public String getAppName()
EventData(String, Object, ServicesManager)
is used to create
event.public UserProfile getUserProfile()
UserProfile
which contain information like user id, first
name, last name and email id. This is available only when
EventData(String, Object, ServicesManager)
is used to create
event.UserProfile
.public String getType()
public void setType(String type)
type
- The type of the event.public Map<String,Object> getAdditionalMetadata()
public Object getAdditionalMetadata(String metadataName)
metadataName
- The name of the metadata.public void addAdditionalMetadata(String key, Object value)
key
- The key of additional metadata of the event.value
- The value of additional metadata of the event.public String getProducer()
public void setProducer(String producer)
producer
- The producer of the event.public ServicesManager getServicesManager()
ServicesManager
associated with the event. If
ServicesManager
passed to the event is null
then it will
return either default or null
value.ServicesManager
.public int getDelayNotificationInMilliseconds()
public void setDelayNotificationInMilliseconds(int delayNotificationInMilliseconds)
delayNotificationInMilliseconds
- The time in milliseconds to delay
the notification of the event.public EventStatus getStatus()
EventStatus
.public void setStatus(EventStatus status)
FOR INTERNAL USE ONLY
status
- The EventStatus
.public void addStatusObserver(BiConsumer<EventStatus,EventData> observer)
observer
- The observer to add for the status change.public void removeAllStatusObservers()
public EventMonitoringData getMonitoringData()
FOR INTERNAL USE ONLY
public boolean canNotify()
public boolean waitForProcessing(long processingWaitTimeInMilliseconds)
processingWaitTimeInMilliseconds
- The time in milliseconds to wait
for processing to complete.IllegalStateException
- if the event was never queued.public void notify(EventSubscriber eventSubscriber, int retryCount)
FOR INTERNAL USE ONLY
eventSubscriber
- The subscriberretryCount
- The retry countpublic String toJson()
public static List<EventData> fromJson(String jsonString)
jsonString
- The JSON string. For example:
"{\"events\":[{\"topic\":\"topic1\",\"data\":\"data1\",\"type\":\"type1\"," + "\"producer\":\"producer1\",\"additionalMetadata\":{\"key1\":\"value1\", + \"key2\":\"value2\", \"key3\":3.1}}, {\"topic\":\"topic2\",\"data\":\"data2\"," + "\"additionalMetadata\":{\"key3\":\"value3\",\"key4\":\"value4\"}}]}"
Copyright © 2019. All rights reserved.