Skip to content

Add new MessageModels easily #40

@AlexScigalszky

Description

@AlexScigalszky

The code to select the queue is hard coupled with the type of message.
We can use a list of Scopes (aka Model name) where we can define the consumer and subscriber queue names

-return (typeof(TMessage) == typeof(IntegrationMessage)
-           ? _settings.Consumer?.IntegrationQueue
-           : _settings.Consumer?.DomainQueue)
-       ?? throw new ArgumentException("please configure the queues on the appsettings");
+var scope = typeof(IntegrationMessage).Name.ToString();
+var queueSettings = _settings.Queues.FirstOrDefault(q => q.Scope == scope);
+return queueSettings?.Consumer
+    ?? throw new ArgumentException("please configure the queues on the appsettings");

For this, we need to change the AppSettings.json file

"RabbitMQ": {
-  "Publisher": {
-    "IntegrationExchange": "api.public.exchange"
-  }
+ "Queues": [
+   {
+     "Scope": "IntegrationMessage",
+     "Publisher": "api.public.exchange"
+   }
+ ]
}

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions