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
Copy file name to clipboardExpand all lines: sns-sqs-message-content-router-cdk/README.md
+41-12Lines changed: 41 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# Amazon SNS to Amazon SQS by filtering content
1
+
# Amazon SNS to Amazon SQS by filtering content (Message-content router pattern)
2
2
3
-
This pattern creates an SNS topic and various SQS destination queues. Messages received by the SNS topic are routed to various SQS queues according to routing logic.
3
+
This pattern creates an SNS topic and various SQS destination queues. Messages received by the SNS topic are routed to various SQS queues according to routing logic. The pattern is an implementation of the Integration pattern: "Content-Based Message route" available here: [https://www.enterpriseintegrationpatterns.com/patterns/messaging/ContentBasedRouter.html](https://www.enterpriseintegrationpatterns.com/patterns/messaging/ContentBasedRouter.html)
4
4
5
-
Learn more about this pattern at Serverless Land Patterns: << Add the live URL here [https://serverlessland.com/patterns/sns-sqs-message-content-router-cdk](https://serverlessland.com/patterns/sns-sqs-message-content-router-cdk)
5
+
Learn more about this pattern at Serverless Land Patterns: [https://serverlessland.com/patterns/sns-sqs-message-content-router-cdk](https://serverlessland.com/patterns/sns-sqs-message-content-router-cdk)
6
6
7
7
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.
8
8
@@ -31,20 +31,47 @@ Important: this application uses various AWS services and there are costs associ
31
31
32
32
## How it works
33
33
34
-
The CDK Stack pick-up a configuration from `stackconfiguration.js` stored inside the `src` folder. This files contains a JSON structure that describe the routing logic. The stack will also create a DeadQueue letter for each Queue and a Default Queue for messages that do not match any
34
+
The CDK Stack pick-up a configuration from `stackconfiguration.json` stored inside the `src` folder. This files contains a JSON structure that describe the routing logic. The stack will also create a DeadQueue letter for each Queue.
35
+
36
+
The parameter `IsAttribute` specifies to CDK if the filter is of type attribute or content.
35
37
36
38
```json
37
39
{
38
40
"Sns": {
39
-
"Name": "The name of the SNS Topic"
41
+
"TopicName": "content-router"
40
42
},
41
43
"Sqs": [
42
44
{
43
-
"Name": "The name of the SQS queue",
44
-
"ContentFilter": "True - the filter will act on the message content; False - the filter will act on the message attribute",
45
-
"Filter: {
46
-
"Name": "The property name of the filter",
47
-
"Values": ["value1", "value2"]
45
+
"QueueName": "country-usa",
46
+
"IsAttribute": true,
47
+
"Filter": {
48
+
"FilterName": "country",
49
+
"FilterValues": [
50
+
"united states of america",
51
+
"usa"
52
+
]
53
+
}
54
+
},
55
+
{
56
+
"QueueName": "country-germany",
57
+
"IsAttribute": true,
58
+
"Filter": {
59
+
"FilterName": "country",
60
+
"FilterValues": [
61
+
"germany",
62
+
"de"
63
+
]
64
+
}
65
+
},
66
+
{
67
+
"QueueName": "language-english",
68
+
"IsAttribute": false,
69
+
"Filter": {
70
+
"FilterName": "language",
71
+
"FilterValues": [
72
+
"english",
73
+
"en"
74
+
]
48
75
}
49
76
}
50
77
]
@@ -65,7 +92,7 @@ Message Body:
65
92
"Message":"Test Message to be received by Queue3 only"
66
93
}
67
94
Message Attribute:
68
-
Type - String; Name - Filter1Name; Value - Filter1Value1
95
+
Type - String; Name - country; Value - usa
69
96
```
70
97
71
98
**Scenario-2 Content based**
@@ -77,7 +104,9 @@ Message body based filter. Copy Json to the message body and add attibutes given
77
104
Message Body:
78
105
{
79
106
"Message":"Test Message to be received by Queue2 only",
Copy file name to clipboardExpand all lines: sns-sqs-message-content-router-cdk/example-pattern.json
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,16 @@
9
9
"text": [
10
10
"This CDK project demonstrates how to create a Message Content-based routing pattern using Amazon SNS and Amazon SQS.",
11
11
"The number of Queues and the Filters are dynamically defined inside the stackconfiguration.json file. The solution can be adapted for any specific requirement.",
12
-
"This architecture is an implementation of the Integration pattern: Content-Based Message Router explained in the Integration Patterns book."
12
+
"This architecture is an implementation of the Integration pattern: Content-Based Message Router explained in the Integration Patterns book.",
13
+
"The content can be filtered by attributes or by message body which grants full flexibility."
0 commit comments