-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement rabbitmq and complete the architecture locally
boyyy did i procrastinate with this one and the reason why is because i had to think quite a bit about how to implement rabbitmq in a clean way as it's quite dirty compared to azure service bus skills from many resources were used here: - Building ASP.NET Core 3 Hosted Services and .NET Core 3 Worker Services by Steve Gordan - RabbitMQ by Example by Stephen Haunts - Securing Microservices in ASP.NET Core by Kevin Dockx - RabbitMQ Custom Docker Image with Custom Configuration and Definitions by Mike Møller Nielsen [YouTube] - How export or import RabbitMQ configuration [Article] a custom rabbitmq image is built with all the exchanges, queues and bindings configured, i manually configured and exported this using its api the normal guest account is used for rabbitmq i created my own naming convention for exchanges and queues [afaik] as follows: exchange.applicationname.event applicationname.event.subscriber.queue an example: exchange.seelanstyres.deleteaccount seelanstyres.deleteaccount.addressservice.queue this satisfies my ocd as it's easy to understand what it means explaining it further: a publisher publishes messages to an exchange [of type fanout in this case] and queues bind to that exchange and receive a copy of those messages. each subscriber will listen in on its dedicated queue and process the messages a visual of a fanout exchange [sort of 😂]: -> queue -> subscriber publisher -> exchange -> queue -> subscriber -> queue -> subscriber in the system there's three events: - deleteaccount - updateaccount - updatetyre the order microservice has data related to all three so a worker is created for each the address microservice only needs to listen for when a customer deletes their account to remove all their addresses i tried my best to abstract a lot of the complexity of rabbitmq into the shared library and ensure there isn't much duplication, however, there's massive duplication for the worker services, in fact, the whole thing is copy and pasted and adjusted for the situation. this is something that i will have to address later as it's not that simple to extract a common method or extension method security as well as distributed tracing is maintained across rabbitmq kevin dockx' implementation for token validation is used across rabbitmq since it's the cleanest way to implement it now that the system is complete locally, soon it'll be azure time 😁 but before that, there's a lot of optimizations to make in terms of performance and implementing redis locally too
- Loading branch information
1 parent
c4dc341
commit 9619457
Showing
55 changed files
with
1,844 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Seelan's Tyres: Address Worker Service")] | ||
[assembly: AssemblyCompany("Shaylen Reddy")] | ||
[assembly: AssemblyProduct("Seelan's Tyres: Address Worker Service")] | ||
[assembly: AssemblyCopyright("Shaylen Reddy: MIT License")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("c71ce57a-276b-45e3-978d-22d7c71e64b4")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
[assembly: AssemblyVersion("@FILE_VERSION@")] | ||
[assembly: AssemblyFileVersion("@FILE_VERSION@")] | ||
[assembly: AssemblyInformationalVersion("@INFORMATIONAL_VERSION@")] | ||
|
||
// Custom Metadata | ||
[assembly: AssemblyMetadata("Commit Url", "@COMMIT_URL@")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Seelan's Tyres: Order Worker Service")] | ||
[assembly: AssemblyCompany("Shaylen Reddy")] | ||
[assembly: AssemblyProduct("Seelan's Tyres: Order Worker Service")] | ||
[assembly: AssemblyCopyright("Shaylen Reddy: MIT License")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("bc002c92-571f-4d7c-9001-6ab39d84bde2")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
[assembly: AssemblyVersion("@FILE_VERSION@")] | ||
[assembly: AssemblyFileVersion("@FILE_VERSION@")] | ||
[assembly: AssemblyInformationalVersion("@INFORMATIONAL_VERSION@")] | ||
|
||
// Custom Metadata | ||
[assembly: AssemblyMetadata("Commit Url", "@COMMIT_URL@")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM rabbitmq:3-management | ||
|
||
COPY custom-configuration/ /etc/rabbitmq/ |
137 changes: 137 additions & 0 deletions
137
orchestration/custom-images/rabbitmq/custom-configuration/definitions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
{ | ||
"users": [ | ||
{ | ||
"name": "guest", | ||
"password_hash": "gs8lM74gLU9MnfbvJtwNKedQ0VaUVH6dssi7hhTAwuvDQNPH", | ||
"hashing_algorithm": "rabbit_password_hashing_sha256", | ||
"tags": [ | ||
"administrator" | ||
], | ||
"limits": {} | ||
} | ||
], | ||
"vhosts": [ | ||
{ | ||
"name": "/" | ||
} | ||
], | ||
"permissions": [ | ||
{ | ||
"user": "guest", | ||
"vhost": "/", | ||
"configure": ".*", | ||
"write": ".*", | ||
"read": ".*" | ||
} | ||
], | ||
"topic_permissions": [], | ||
"parameters": [], | ||
"global_parameters": [ | ||
{ | ||
"name": "internal_cluster_id", | ||
"value": "rabbitmq-cluster-id-F3rLs5lFxjL0F9hKSffbNg" | ||
} | ||
], | ||
"policies": [], | ||
"queues": [ | ||
{ | ||
"name": "seelanstyres.deleteaccount.addressservice.queue", | ||
"vhost": "/", | ||
"durable": true, | ||
"auto_delete": false, | ||
"arguments": { | ||
"x-queue-type": "classic" | ||
} | ||
}, | ||
{ | ||
"name": "seelanstyres.updatetyre.orderservice.queue", | ||
"vhost": "/", | ||
"durable": true, | ||
"auto_delete": false, | ||
"arguments": { | ||
"x-queue-type": "classic" | ||
} | ||
}, | ||
{ | ||
"name": "seelanstyres.deleteaccount.orderservice.queue", | ||
"vhost": "/", | ||
"durable": true, | ||
"auto_delete": false, | ||
"arguments": { | ||
"x-queue-type": "classic" | ||
} | ||
}, | ||
{ | ||
"name": "seelanstyres.updateaccount.orderservice.queue", | ||
"vhost": "/", | ||
"durable": true, | ||
"auto_delete": false, | ||
"arguments": { | ||
"x-queue-type": "classic" | ||
} | ||
} | ||
], | ||
"exchanges": [ | ||
{ | ||
"name": "exchange.seelanstyres.deleteaccount", | ||
"vhost": "/", | ||
"type": "fanout", | ||
"durable": true, | ||
"auto_delete": false, | ||
"internal": false, | ||
"arguments": {} | ||
}, | ||
{ | ||
"name": "exchange.seelanstyres.updateaccount", | ||
"vhost": "/", | ||
"type": "fanout", | ||
"durable": true, | ||
"auto_delete": false, | ||
"internal": false, | ||
"arguments": {} | ||
}, | ||
{ | ||
"name": "exchange.seelanstyres.updatetyre", | ||
"vhost": "/", | ||
"type": "fanout", | ||
"durable": true, | ||
"auto_delete": false, | ||
"internal": false, | ||
"arguments": {} | ||
} | ||
], | ||
"bindings": [ | ||
{ | ||
"source": "exchange.seelanstyres.deleteaccount", | ||
"vhost": "/", | ||
"destination": "seelanstyres.deleteaccount.addressservice.queue", | ||
"destination_type": "queue", | ||
"routing_key": "", | ||
"arguments": {} | ||
}, | ||
{ | ||
"source": "exchange.seelanstyres.deleteaccount", | ||
"vhost": "/", | ||
"destination": "seelanstyres.deleteaccount.orderservice.queue", | ||
"destination_type": "queue", | ||
"routing_key": "", | ||
"arguments": {} | ||
}, | ||
{ | ||
"source": "exchange.seelanstyres.updateaccount", | ||
"vhost": "/", | ||
"destination": "seelanstyres.updateaccount.orderservice.queue", | ||
"destination_type": "queue", | ||
"routing_key": "", | ||
"arguments": {} | ||
}, | ||
{ | ||
"source": "exchange.seelanstyres.updatetyre", | ||
"vhost": "/", | ||
"destination": "seelanstyres.updatetyre.orderservice.queue", | ||
"destination_type": "queue", | ||
"routing_key": "", | ||
"arguments": {} | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
orchestration/custom-images/rabbitmq/custom-configuration/rabbitmq.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
management.load_definitions = /etc/rabbitmq/definitions.json |
Oops, something went wrong.