In the simplest terms, an event is a signal that a system’s state has changed. In AWS, it’s represented as a JSON message, containing some set of facts about what changed and potentially what the current state of the system is.
Events are:
Events are JSON messages containing a message wrapped in an envelope:
source
attribute is provided by the application creating the event. This workshop uses the source awsserverlessda.serverlesspresso
to uniquely identify all events related to this workload. You can set this to almost any value (AWS events use a prefix of “AWS”, which is reserved).detail-type
attribute is also set by the application creating the event. This provides information about the type of event. In this example, OrderProcessor.WorkflowStarted
indicates the source of OrderProcessor and an action of WorkflowStarted.detail
attribute is a JSON payload containing custom event information. For custom events you create, this can be any arbitrary JSON.The maximum message size is 256 KB. To learn more, read about EventBridge quotas.
The workflow created in module 1 orchestrates individual orders from start to finish. Some of the workflow steps require human interaction (such as a customer submitting their drink order, or the barista accepting and completing the order).
The workflow emits an event at these steps and then waits for a response before continuing. The event is emitted to a serverless event bus where it is routed to the relevant service(s).
The routing is performed by Amazon EventBridge. You publish events to buses, and subscribers use rules to filter for events they care about. In this module, you’ll create rules in EventBridge to capture and route these events to the relevant service.
EventBridge lets you route events from AWS services, custom applications, software as a service application and microservices. The events are sent to buses, including custom buses you can set up specifically for your workload. Consumers such as AWS services or microservices then use rules to filter for the messages they want to receive.
This is the messaging behind event driven architecture. It allows you to decouple the producers and consumers of events - the producers do not know who, if anyone, is listening to the events they publish. Similarly, subscribers do not know if anyone else is listening and they may not know the publisher of the event.
This can make it faster to develop new features in software, increase extensibility, and reduce friction between development teams.
Watch this introduction to EventBridge video on YouTube.
More information on this services used in this section: