Boxing Day

In much of these United States, except for Massachusetts, the 26 December is not referenced as Boxing Day. The day following Christmas Day, 26 December, while not formally recognised as Boxing Day…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




AWS EventBridge

Amazon EventBridge is a serverless event bus that makes it easier to build event-driven applications at scale using events generated from your applications, integrated SaaS applications, and AWS services. We can set up routing rules to determine where to send our data to build application architectures that react in real-time to our data sources with event publishers and consumers completely decoupled.

Event Bridge as a message router

In simple terms, Amazon EventBridge is a serverless event bus that helps connect services with data. In an event-driven architecture, AWS EventBridge acts as the coordinator to choreograph the interactions between different microservices using events.

An event bus receives events from a source and routes them to rules associated with that event bus. We can also filter out what type of events are published onto event bus by creating rules.

Our account’s default event bus receives events from AWS services. A custom event bus can receive events from your custom applications and services

Events are represented in the JSON format where we specify fields such as the Source (Source Name), DetailType (Detail of the event), Detail (Payload) and some other metadata like the region, account ID, etc.

We can pass events from one event bus to another across multiple regions or accounts by setting up a template in the event bus Resource-Based Policy.

Rules associated with the event bus evaluate events as they arrive. Each rule checks whether an event matches the rule’s criteria. We associate a rule with a specific event bus, so the rule only applies to events received by that event bus. We can set either Event Patterns or Schedule rules.

Schedule rules are either Fixed Rate or CRON. These events in the event bus are then handled by any processing service, say Lambda.

Predefined pattern — Provides an automatically generated template which we can further edit based on the service type and the event type of the service.

In the above image, we can see that we have a predefined event of type Bucket Level Operations of S3 and we are only publishing the DeleteBucket and DeleteBucketPolicy.

Custom patterns — This allows us to create rules on our own based on the data payload on what we want to filter and check before publishing to the event bus.

In the above image, we can see that we have the schema of the rule and the rule will check if the event data has source=‘my-application’ or detail-type=‘orders’ or if the eventName attribute of the event data includes the data from the eventName in the event rule and only the event data satisfying the rule check will be published to the bus.

EventBridge examines the incoming event and compares it against this rule. The rule specifies a source value of custom.myATMapp and, as this exists in the event, the pattern matches. It then routes the event to the rule’s targets.

The example above shows a static, exact match pattern — the attribute is either present, or it’s not. There are now additional operators available for dynamic matching based on specific comparison conditions. This provides functionality that’s similar to what you use in a SQL where clause for filtering records in a database. The image below is a summary of all the comparison operators available in EventBridge.

A target can be an AWS service, resource or endpoint. A rule can have up to 5 targets. And based on the target we have to configure them.

Retry Policy For Targets

Eventbridge attempts to retry failed invocations.

Max Age — The maximum number of periods to keep unprocessed events for, the default is 24 hours.

Retry Attempts — The maximum number of attempts to send an event to a target after an error occurred, the default is 185 times.

DLQ — We can also send the unprocessed events to a DLQ. We can also specify a DLQ that is in another AWS account. We need to just paste the ARN of the DLQ. The event that is sent to the DLQ consists of additional metadata like errorCode, errorMessage and targetARN which we can check why the delivery failed.

A schema defines the structure of events that are sent to EventBridge. EventBridge provides schemas for all events that are generated by AWS services. You can also create or upload custom schemas or infer schemas directly from events on an event bus. We need to turn on the Schema Discovery for an event bus.

We can select schemas related to AWS services that are already present or can group schemas by creating our own custom schema registry. Once you have a schema for an event, you can download code bindings for popular programming languages and speed up development. You can work with code bindings for schemas and manage schemas from the EventBridge console, by using the API, or directly in your IDE.

We can use the schema to discover the structure of the data that is being published into the event bus. There is no enforcement though on what we want to publish to the event bus, it is just for client-side validation. We could use this schema to validate the data with respect to the schema before publishing it into the event bus.

We can pass events from one event bus to another across multiple regions or accounts by setting up a template in the event bus Resource-Based Policy. The steps are

In SNS we publish a message to a topic and then the multiple subscribers to that topic get that message. It is a push-based model.

In SQS we publish the message to a queue and the consumer polls that message from the queue. Only one subscriber for a queue. It is a polling-based mode

In EventBridge we publish the message to the event bus and from there the subscribers get the message. It is also a push-based model.

SNS scales automatically, using Lambda per function concurrency setting to control downstream consumption.
SQS also scales automatically, using Lambda trigger batch size and per function concurrency setting to control downstream consumption.
EventBridge scales automatically up with a default quota of 400 PutEvents and 750 target invocation requests per second. Use Lambda per function concurrency setting to control downstream consumption.

Conditional message processing in SNS is that it can invoke different subscribers based on values on message metadata using SNS message filtering. Input Transformation like EventBridge is not available and the conditional message filtering is also not very flexible as we cannot transform parts of the message and define the metadata clearly.

Conditional message processing in SQS is that it can’t decide the consumer based on the message. Use SNS filtering with SQS to achieve this.
Conditional message processing in EventBridge is that it has event filtering which can route messages to targets based on the message. It can also transform events by Input Transform action before sending to the target. It also has a schema registry. It can auto-discover the event schema, so we don’t have to do it manually.

In SNS messages are gone once delivered to subscribers. No replay functionality

In SQS messages are gone once delivered to the consumer. No replay functionality

In EventBridge messages can be archived based on rules and can be replayed later. The benefit is we can archive the event message rather than running the producer again to produce the same event. So it’s convenient

In SNS message filtering can be done only on the message attributes
In SQS message filtering can be done only on the message attributes

In EventBridge message, filtering can be done on the entire message body

SNS FIFO maintains message order
SQS FIFO maintains message order
EventBridge message order not maintained

In SNS messages at rest can be encrypted using KMS

In SQS messages at rest can be encrypted using KMS

In EventBridge messages at rest cannot be encrypted using KMS

Add a comment

Related posts:

NOTHING REALLY MATTERS

And probably no one is even going to remember that you existed on this planet except your children or maybe your grandchildren. Nothing new here, billions of people have been born on this planet and…

Views Toward Animal Homelessness and Adoption in the United States from Recent Survey

A recent survey from Petsmart Charities, shows that those surveyed do not have an accurate estimate of how many pets are actually in need of a home. The survey results reveal that 84 percent of…

Selected Management and Leadership Books by Women Authors

Although there is more progress to be made, women have during the last three decades assumed a greater number of management and leadership positions and offer engaging, insightful, and entertaining…