-
Notifications
You must be signed in to change notification settings - Fork 259
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
feature: Support the Subject property when publishing to SNS #3270
feature: Support the Subject property when publishing to SNS #3270
Conversation
/// <summary> | ||
/// The optional Subject passed through to the published SNS message | ||
/// </summary> | ||
public Func<Message, string> SnsSubject { get; set; } = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming here suggests that this is actual value for the subject, rather than something that generates subjects for a given message. I would suggest something like SnsSubjectGenerator
, with a description of "An optional delegate for generating the SNS subject for a given message".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few questions here.
Typically we compose the body of a message from the properties of the request that is being serialized. We don't tend to add metadata in via the publish process, but via that message mapping pipeline (either the sink or intermediary middleware).
The publication is accessible via middleware, so it might make sense to add a subject, particularly if we are adding metadata into the body of the message, via that middleware and not via the serialization of the request in the sink. This allows you to not have to remember to add in subject in every mapper, just add the middleware (especially as V10 wants to add default mappers).
As subject is meant for an email header, it would feel that you are doing something specific here i.e. composing a message that will be sent as an email, so adding middleware that supports an SNS subject may be the right approach.
We may need to think about our goal here. I am not sure this is the right approach. I can see why you would opt for it, without knowing about the mapping pipeline however. So I do get that.
Summary of chat with @iancooper Ideally, Brighter would avoid this work because the SNS
|
@@ -45,7 +45,7 @@ public SqsMessagePublisher(string topicArn, AmazonSimpleNotificationServiceClien | |||
public string Publish(Message message) | |||
{ | |||
var messageString = message.Body.Value; | |||
var publishRequest = new PublishRequest(_topicArn, messageString); | |||
var publishRequest = new PublishRequest(_topicArn, messageString, message.Header.Subject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know what happens if the subject is null or empty? We probably need a test for that, as modifying the existing test won't tell us if it is breaking for existing consumers. It just needs a conditional if it breaks anyone.
|
||
public SqsMessageProducerSendTests() | ||
{ | ||
_myCommand = new MyCommand{Value = "Test"}; | ||
_myCommand = new MyCommand{Value = "Testttttttt"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, we need a test for when there is no subject.
9fa04ea
to
b53a1ae
Compare
@jtsalva merged |
Use
Message.Header.Subject
as SNS subject