Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send messages or publish events to multiple destinations? #123

Open
ashovlin opened this issue Apr 2, 2024 · 4 comments
Open

Send messages or publish events to multiple destinations? #123

ashovlin opened this issue Apr 2, 2024 · 4 comments
Labels
feature-request A feature should be added or improved. p2 This is a standard priority issue

Comments

@ashovlin
Copy link
Contributor

ashovlin commented Apr 2, 2024

Describe the feature

Currently for configuration like the following:

services.AddAWSMessageBus(builder =>
{
    bus.AddSQSPublisher<ChatMessage>("https://sqs.us-east-1.amazonaws.com/012345678910/QueueA");
    bus.AddSQSPublisher<ChatMessage>("https://sqs.us-east-1.amazonaws.com/012345678910/QueueB" );
});

When sending a ChatMessage, the framework will send it to QueueA because it happened to be registered first.

var publisherMapping = PublisherMappings.FirstOrDefault(x => messageType == x.MessageType);


We're looking feedback on:

  1. Should sending a message or publishing a event to multiple destinations be supported? For the above example, the message would be published to both QueueA and QueueB?
  2. Alternatively if not supported, should configuration like the above be disallowed via an exception at startup? Or perhaps at least a LogWarning explaining the precedence.
@ashovlin ashovlin added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 2, 2024
@ashovlin ashovlin changed the title Send Message or Publish Event to Multiple Destinations? Send messages or publish events to multiple destinations? Apr 2, 2024
@ashishdhingra ashishdhingra pinned this issue Apr 5, 2024
@martincostello
Copy link

martincostello commented Apr 15, 2024

We used to have a feature like 1 in JustSaying, where we would publish one message to two regions as part of a (with hindsight over-complicated) disaster recovery scenario, hence used to.

At first sight, 2 feels counter intuitive as to how the MS DI container works by default i.e. last one wins.

If those were the only two options, 1 feels like the least surprising to me.

@HEskandari
Copy link

What you may need here, is to think bigger than messages. Conceptually 'messages' can be used as commands or events. Commands are sent to a destination to perform an action. There's always 1-1 mapping between the sender/recipient of a command. Events on the other hand signal an event that has already happened and can be sent to multiple recipients. The mapping between publisher of an event to subscribers are 1-many. Admittedly AWS messaging may not be the right abstraction to build this, but need to make it so that this is possible.

@normj
Copy link
Contributor

normj commented Apr 16, 2024

@HEskandari I would expect the the 1 to many scenario be handled in the configuration of the AWS resources. For example if you need multiple consumers then the endpoint of the message type should be an SNS topic or EventBridge which can fan out the publishing of the message. It doesn't seem worth it to have the application logic itself hand the dispatching of the message to multiple endpoints.

@ashishdhingra ashishdhingra added needs-review p2 This is a standard priority issue and removed needs-review labels Jun 17, 2024
@ashovlin
Copy link
Contributor Author

Thanks for the feedback so far, we're going to leave this open for at least a few months longer to see if folks are still looking for 1-to-many support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

5 participants