-
-
Notifications
You must be signed in to change notification settings - Fork 8
Subscriptions
The EPCIS standard allows the user to create subscriptions or standing queries on the repository. These subscriptions usually specify the parameters to filter the events they need to receive as well as an HTTP URL to send the results to.
EPCIS 2.0 introduced the use of WebSockets for the subscriptions.
FasT&T EPCIS repository supports both kind of subscriptions.
The subscriptions are stored in the database in the subscriptions
schema. The schedule and parameters are both stored in the database, so any restart of the repository will keep them and start sending the events where it stopped.
The subscriptions table hasa [LastExecutedTime]
field that stores the date of the last execution of each subscription. Each time a subscription is executed, the data results are filtered using a GE_recordTime
parameter and this field is then updated with the latest value used.
To avoid to skip any captured events, this mechanism retrieves the event from [LastExecutedTime - 30s] and discards all the events already returned by the subscription.
As 30 seconds is the default request timeout, this ensures that all the requests are returned by the subscriptions even if it takes a longer time to be captured.
The websockets subscriptions are not stored in the database but are executed using the exact same mechanism as the persisted subscriptions.
The EPCIS specification allows the subscription to contain a trigger
field instead of a schedule.
FasT&T allows multiple values for the trigger field:
-
hourly
: returns the results at the beginning of every hour -
daily
: returns the results at the beginning of every day -
weekly
: returns the results at the beginning of every week (monday) -
monthly
: returns the results at the beginning of every month -
stream
: returns the results as soon as they are recorded in the repository
This background worker process might not be suitable for an environment where multiple instances of the repository are working in parallel. In that case it's recommended to host an external process that handles the subscription triggers/process.