-
Notifications
You must be signed in to change notification settings - Fork 260
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
Merged
iancooper
merged 8 commits into
BrighterCommand:master
from
jtsalva:feature-add-subject
Aug 27, 2024
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c7103e1
feature: Support SNS subject
jtsalva 9408581
Update test
jtsalva 7f89ad8
Address review comments
jtsalva 59e58d2
Retrigger build
jtsalva c027650
Revert publication level subject generator commits
jtsalva 73d0874
Use Message.Header.Subject as SNS subject
jtsalva a3c41c6
Merge branch 'master' into feature-add-subject
jtsalva b53a1ae
Fix commit
jtsalva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,26 +23,29 @@ public class SqsMessageProducerSendTests : IDisposable | |
private readonly string _replyTo; | ||
private readonly string _contentType; | ||
private readonly string _topicName; | ||
private readonly string _subject; | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. As above, we need a test for when there is no subject. |
||
_correlationId = Guid.NewGuid().ToString(); | ||
_replyTo = "http:\\queueUrl"; | ||
_contentType = "text\\plain"; | ||
var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45); | ||
_topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45); | ||
var routingKey = new RoutingKey(_topicName); | ||
_subject = "test subject"; | ||
|
||
SqsSubscription<MyCommand> subscription = new( | ||
name: new SubscriptionName(channelName), | ||
channelName: new ChannelName(channelName), | ||
routingKey: routingKey | ||
routingKey: routingKey, | ||
rawMessageDelivery: false | ||
); | ||
|
||
_message = new Message( | ||
new MessageHeader(_myCommand.Id, _topicName, MessageType.MT_COMMAND, correlationId: _correlationId, | ||
replyTo: _replyTo, contentType: _contentType), | ||
replyTo: _replyTo, contentType: _contentType, subject: _subject), | ||
new MessageBody(JsonSerializer.Serialize((object) _myCommand, JsonSerialisationOptions.Options)) | ||
); | ||
|
||
|
@@ -66,7 +69,7 @@ public async Task When_posting_a_message_via_the_producer() | |
|
||
await Task.Delay(1000); | ||
|
||
var message =_channel.Receive(5000); | ||
var message = _channel.Receive(5000); | ||
|
||
//clear the queue | ||
_channel.Acknowledge(message); | ||
|
@@ -82,6 +85,7 @@ public async Task When_posting_a_message_via_the_producer() | |
message.Header.ReplyTo.Should().Be(_replyTo); | ||
message.Header.ContentType.Should().Be(_contentType); | ||
message.Header.HandledCount.Should().Be(0); | ||
message.Header.Subject.Should().Be(_subject); | ||
//allow for clock drift in the following test, more important to have a contemporary timestamp than anything | ||
message.Header.TimeStamp.Should().BeAfter(RoundToSeconds(DateTime.UtcNow.AddMinutes(-1))); | ||
message.Header.DelayedMilliseconds.Should().Be(0); | ||
|
@@ -96,7 +100,7 @@ public void Dispose() | |
_messageProducer?.Dispose(); | ||
} | ||
|
||
private DateTime RoundToSeconds(DateTime dateTime) | ||
private static DateTime RoundToSeconds(DateTime dateTime) | ||
{ | ||
return new DateTime(dateTime.Ticks - (dateTime.Ticks % TimeSpan.TicksPerSecond), dateTime.Kind); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.