You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
commit 0093a01e00e326b6bb738a4df43b5165f69c87a5
Author: Andrew den Hertog <andrew.denhertog@gmail.com>
Date: Sun Mar 1 12:28:19 2020 +1000
Provide documentation for system message handlers
Copy file name to clipboardExpand all lines: packages/bus-core/src/handler/README.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,40 @@ class Handler {
75
75
76
76
```
77
77
78
+
## System and non-domain messages
79
+
80
+
Sometimes you want to subscribe your application to messages that it doesn't own or publish. This is common when integrating with external systems that publish messages that don't conform to the structure of those defined in `@node-ts/bus-messages`. In order to subscribe to and handle these types of messages, you need to provide a resolver and a topic identifier as part of your handler declaration.
81
+
82
+
For example, let's say we're working with AWS and want to be notified every time there's a new S3 object created in a bucket. S3 publishes these events to an existing SNS topic, and we want to subscribe our application SQS queue to it and handle these messages. The handler declaration would look like this:
When this handler is registered, it will automatically subscribe the application queue to the underlying topic. Note that the topic identifier is specific to the bus transport being used. Here `@node-ts/bus-sqs` is used so an SNS ARN is provided, but if you were using a different transport (eg: RabbitMQ) then you would provide a different identifier (eg: an Exchange name).
109
+
110
+
All messages received from the queue will be sent to the resolver. Due to the prototype/duck typing nature of Javascript, you'll need to place assertions into the resolver so that your handler only receives messages you are intending to handle.
111
+
78
112
## Messages that fail processing
79
113
80
114
When a message handling function throws an error while processing a message, the message is returned to the queue to be retried. Often the message will succeed on a subsequent retry depending on the reason for the error (eg: a core piece of infrastructure was down, an external service was unavailable, a network partition event occurred, a row lock version conflict stopped an update going through).
0 commit comments