Overview
The Scheduled Event service allows you to send events to SAP Hybris Profile after a pre-defined amount of time, rather than immediately. If you use the Scheduled Event service to schedule the delivery of events in advance, the events enter the system no sooner than the specified time.
For instructions on how to use the Scheduled Event functionality, see the Event scheduling tutorial.
API Reference
/{tenant}/scheduledevents
/{tenant}/scheduledevents
Schedule given event according to received parameters and returns it location which can be used to further re-scheduling. Requires scope hybris.profile_scheduledevent_manage.
/{tenant}/scheduledevents/{scheduleId}
Re-schedule event according to received parameters or schedule new if event with given identifier doesn't exists. Requires scope hybris.profile_scheduledevent_manage.
Events
The store event, which enters the Context service, triggers the Scheduled Event service. The Scheduled Event service extracts the values of the schema, scheduleAt, and scheduleId attributes from the store event payload to deliver a scheduled event no sooner than the specified time. The id, consentRefId, and scheduleParameter attributes are user-provided and optional.
The following table shows an example of the store event, associated with the node creation.
Triggered by schema | Payload example |
---|---|
core/ScheduledEvent | {"id" : "999","schema" : "nodes/commerce/Product","consentRefId" : "ae3ade81-052f-4f36-8825-f1617180ed5e","scheduleAt" : "2016-12-10T18:06:17.234Z","scheduleParameter" : "affinity=1,23","scheduleId" : "nodes/commerce/Product/999"} |
Attributes of the message:
- id: The identifier of the created node
- schema: The schema defining the node
- consentRefId: Consent reference of the node's owner
- scheduleAt: Determines when the Context service sends the scheduled event. Provide this value in the ISO 8601 format, for example "2016-12-10T18:06:17.234Z", or as a duration, for example "P2DT2H30M5S". For duration, the service supports only days, hours, minutes, and seconds. Where the days are considered to be exactly 24 hours.
- scheduleParameter: Determines the scheduled event parameters. This attribute is optional.
- scheduleId: The unique identifier of the event. If you set the scheduleId, all previously-sent events containing the same scheduleId get overwritten.
After the specified amount of time, the Scheduled Event service sends the planned schedule event. The payload of the event includes the id, consentRefId, and scheduleParameter attributes.
The following table shows an example of a schedule event.
Triggered by schema | Payload example |
---|---|
nodes/commerce/Product | {"id" : "999","consentRefId" : "ae3ade81-052f-4f36-8825-f1617180ed5e","scheduleParameter" : "affinity=1,23"} |
Introduction to Tutorials
These tutorials use the Scheduled Event service API Console to describe these topics:
- Schedule an event
- Overwrite an already scheduled event
Prerequisites
- Access to the Scheduled Event service API Console
- A valid Bearer access token
/token
endpoint section of the OAuth 2.0 service documentation.Event scheduling
Schedule an event
Execute the command in the example to schedule an event according to received parameters.
cURL command example
curl -X POST -H "Authorization: Bearer access_token" -H "hybris-consent-reference: consent-reference" -H "hybris-context-trace-id: traceId" -H "hybris-schedule-event-at: time-date-format" -H "hybris-schema: schema" 'https://api.beta.yaas.io/hybris/scheduled-event/v1/{tenant}/scheduledevents'
Parameters
- Headers
- Authorization - Provide a valid bearer access token with the scope hybris.profile_scheduledevent_manage
- hybris-consent-reference - Provide a valid consent reference to which the data should belong
- hybris-context-trace-id - This header is optional. To enable the service to trace your event, provide the value of this header, namely a context trace ID, and make sure it has a traceable form: a trailing -1 at the end results in a traceable event, whereas a tracing -0 or no tracing marker makes your event non-traceable.
- hybris-schedule-event-at - Provide the time when the scheduled event, associated with the created or updated element, should be sent to the system. Ensure the time format is ISO 8601-compliant, and presented either as a combination of date and time, such as 2016-12-10T19:06:17.234+01:00, or as a duration, such as P2DT2H30M5S. For duration, the system supports only days, hours, minutes, and seconds. The system sends a scheduled event only when you define the schedule time value.
- hybris-schema - Provide the valid schema of the event
- URI parameters
- {tenant} - Provide your tenant name
Example of a POST request with real data
curl -X POST -H "Authorization: Bearer 001-958ff69f-532c-43db-b847-fa1d7b9e7635" -H "hybris-consent-reference: baa8a056-8b71-417e-9ad6-1c5069c66096" -H "hybris-context-trace-id: 520722c1-f66a-4add-b301-5cfdd35652e7-1" -H "hybris-scheduled-event-at: P0DT0H0M60S" -H "hybris-schema: context/commerce/FrontendEntered" 'https://api.beta.yaas.io/hybris/scheduled-event/v1/mycomicsshop/scheduledevents'
Response
A response with the status code of 201
indicates that the service successfully scheduled an event.
Overwrite an already scheduled event
To reschedule an already scheduled event, run the following command.
cURL command example
curl -X PUT -H "Authorization: Bearer access_token" -H "hybris-consent-reference: consent-reference" -H "hybris-context-trace-id: traceId" -H "hybris-schedule-event-at: date-time-format" -H "hybris-schema: schema" 'https://api.beta.yaas.io/hybris/scheduled-event/v1/{tenant}/scheduledevents/{scheduleId}'
Parameters
- Headers
- Authorization - Provide a valid bearer access token with the scope hybris.profile_scheduledevent_manage
- hybris-consent-reference - Provide a valid consent reference to which the data should belong
- hybris-context-trace-id - This header is optional. To enable the service to trace your event, provide the value of this header, namely a context trace ID, and make sure it has a traceable form: a trailing -1 at the end results in a traceable event, whereas a tracing -0 or no tracing marker makes your event non-traceable.
- hybris-schedule-event-at - Provide the time when the scheduled event, associated with the created or updated element, should be sent to the system. Ensure the time format is ISO 8601-compliant, and presented either as a combination of date and time, such as 2016-12-10T19:06:17.234+01:00, or as a duration, such as P2DT2H30M5S. For duration, the system supports only days, hours, minutes, and seconds. The system sends a scheduled event only when you define the schedule time value.
- hybris-schema - Provide the valid schema of the event
- URI parameters
- {tenant} - Provide your tenant name
- {scheduleId} - Provide the ID of your scheduled event
Example of a PUT request with real data
curl -X PUT -H "Authorization: Bearer 001-958ff69f-532c-43db-b847-fa1d7b9e7635" -H "hybris-consent-reference: baa8a056-8b71-417e-9ad6-1c5069c66096" -H "hybris-context-trace-id: 520722c1-f66a-4add-b301-5cfdd35652e7-1" -H "hybris-scheduled-event-at: P0DT0H0M60S" -H "hybris-schema: context/commerce/FrontendEntered" 'https://api.beta.yaas.io/hybris/scheduled-event/v1/mycomicsshop/scheduledevents'
Response
A response with the status code of 204
indicates that the service successfully rescheduled an event.
If you find any information that is unclear or incorrect, please let us know so that we can improve the Dev Portal content.
Use our private help channel. Receive updates over email and contact our specialists directly.
If you need more information about this topic, visit hybris Experts to post your own question and interact with our community and experts.