Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions docs/src/content/docs/infra/azure-service-bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ Producer options:

When producing messages, you can supply per-message options using `ServiceBusProduceOptions`:

| Option | Description |
|--------------------|----------------------------------------------------------|
| `Subject` | Message subject |
| `To` | Forward-to address |
| `ReplyTo` | Reply-to address |
| `SessionId` | Session id for session-enabled queues/topics |
| `ReplyToSessionId` | Reply-to session id |
| `TimeToLive` | Message time-to-live, default is `TimeSpan.MaxValue` |
| Option | Description |
|------------------------|--------------------------------------------------------------------|
| `Subject` | Message subject |
| `To` | Forward-to address |
| `ReplyTo` | Reply-to address |
| `SessionId` | Session id for session-enabled queues/topics |
| `ReplyToSessionId` | Reply-to session id |
| `TimeToLive` | Message time-to-live, default is `TimeSpan.MaxValue` |
| `ScheduledEnqueueTime` | Datetime when service bus makes the message available to receivers |

Message metadata is mapped to Azure Service Bus application properties. The attribute names used for standard properties (message type, stream name, correlation id, etc.) can be customized via `ServiceBusMessageAttributeNames`.

Expand Down
17 changes: 9 additions & 8 deletions docs/src/content/docs/next/infra/azure-service-bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ Producer options:

When producing messages, you can supply per-message options using `ServiceBusProduceOptions`:

| Option | Description |
|--------------------|----------------------------------------------------------|
| `Subject` | Message subject |
| `To` | Forward-to address |
| `ReplyTo` | Reply-to address |
| `SessionId` | Session id for session-enabled queues/topics |
| `ReplyToSessionId` | Reply-to session id |
| `TimeToLive` | Message time-to-live, default is `TimeSpan.MaxValue` |
| Option | Description |
|------------------------|--------------------------------------------------------------------|
| `Subject` | Message subject |
| `To` | Forward-to address |
| `ReplyTo` | Reply-to address |
| `SessionId` | Session id for session-enabled queues/topics |
| `ReplyToSessionId` | Reply-to session id |
| `TimeToLive` | Message time-to-live, default is `TimeSpan.MaxValue` |
| `ScheduledEnqueueTime` | Datetime when service bus makes the message available to receivers |

Message metadata is mapped to Azure Service Bus application properties. The attribute names used for standard properties (message type, stream name, correlation id, etc.) can be customized via `ServiceBusMessageAttributeNames`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ internal ServiceBusMessage CreateServiceBusMessage(ProducedMessage message) {
ReplyToSessionId = options?.ReplyToSessionId
};

if (options?.ScheduledEnqueueTime is {} scheduledEnqueueTime) {
serviceBusMessage.ScheduledEnqueueTime = scheduledEnqueueTime;
}

// We set the SessionId only when a value is present because
// it overrides the PartitionKey, even if the SessionId is null.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public class ServiceBusProduceOptions {
/// Gets or sets the time interval after which the message expires.
/// </summary>
public TimeSpan TimeToLive { get; set; } = TimeSpan.MaxValue;
}

/// <summary>
/// Gets or sets the date and time, in UTC, when service bus makes the message available to receivers
/// </summary>
public DateTimeOffset? ScheduledEnqueueTime { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Eventuous.Tests.Azure.ServiceBus;

public class ConvertEventToMessage {
readonly Guid _messageId = Guid.NewGuid();
readonly Guid _messageId = Guid.NewGuid();
readonly ServiceBusMessage _message;

public ConvertEventToMessage() {
Expand All @@ -13,23 +13,24 @@ public ConvertEventToMessage() {
"test-stream",
new(),
new() {
Subject = "test-subject",
To = "test-to",
ReplyTo = "test-reply-to",
TimeToLive = TimeSpan.FromMinutes(5)
Subject = "test-subject",
To = "test-to",
ReplyTo = "test-reply-to",
TimeToLive = TimeSpan.FromMinutes(5),
ScheduledEnqueueTime = new DateTimeOffset(2026, 3, 23, 16, 31, 0, TimeSpan.Zero)
}
);

_message = builder.CreateServiceBusMessage(
new(
new SomeEvent {
Id = "event-id",
Id = "event-id",
Name = "Test Event"
},
new() {
[MetaTags.CorrelationId] = "correlation-id",
[MetaTags.CausationId] = "causation-id",
["AAA"] = 1111
[MetaTags.CausationId] = "causation-id",
["AAA"] = 1111
},
new() { ["BBB"] = "12345" },
_messageId
Expand Down Expand Up @@ -72,6 +73,10 @@ public async Task CorrelationId() {
await Assert.That(_message.CorrelationId).IsEqualTo("correlation-id");
}

[Test]
public async Task ScheduledEnqueueTime() =>
await Assert.That(_message.ScheduledEnqueueTime).IsEqualTo(new DateTimeOffset(2026, 3, 23, 16, 31, 0, TimeSpan.Zero));

[Test]
[Arguments("MessageId")]
[Arguments("CorrelationId")]
Expand All @@ -92,21 +97,21 @@ public class WithMessagePropertiesInMetaData {

public WithMessagePropertiesInMetaData() {
var attributeNames = new ServiceBusMessageAttributeNames();
var builder = new ServiceBusMessageBuilder(DefaultEventSerializer.Instance, "test-stream", attributeNames, new());
var builder = new ServiceBusMessageBuilder(DefaultEventSerializer.Instance, "test-stream", attributeNames, new());

_message = builder.CreateServiceBusMessage(
new(
new SomeEvent {
Id = "event-id",
Id = "event-id",
Name = "Test Event"
},
new() {
[attributeNames.MessageId] = "12345",
[attributeNames.MessageId] = "12345",
[attributeNames.CorrelationId] = "correlation-id",
[attributeNames.CausationId] = "causation-id",
[attributeNames.ReplyTo] = "test-reply-to",
[attributeNames.Subject] = "test-subject",
[attributeNames.To] = "test-to"
[attributeNames.CausationId] = "causation-id",
[attributeNames.ReplyTo] = "test-reply-to",
[attributeNames.Subject] = "test-subject",
[attributeNames.To] = "test-to"
},
new()
)
Expand Down
Loading