diff --git a/Client.UnitTests/PublishMessageTest.cs b/Client.UnitTests/PublishMessageTest.cs index 73a50838..bf9c4817 100644 --- a/Client.UnitTests/PublishMessageTest.cs +++ b/Client.UnitTests/PublishMessageTest.cs @@ -120,5 +120,28 @@ await ZeebeClient var request = TestService.Requests[typeof(PublishMessageRequest)][0]; Assert.AreEqual(expectedRequest, request); } + + [Test] + public async Task ShouldSendRequestWithTenantIdAsExpected() + { + // given + var expectedRequest = new PublishMessageRequest + { + Name = "test", + CorrelationKey = "123", + TenantId = "tenant1" + }; + + // when + await ZeebeClient.NewPublishMessageCommand() + .MessageName("test") + .CorrelationKey("123") + .AddTenantId("tenant1") + .Send(); + + // then + var request = TestService.Requests[typeof(PublishMessageRequest)][0]; + Assert.AreEqual(expectedRequest, request); + } } } \ No newline at end of file diff --git a/Client/Api/Commands/IPublishMessageCommandStep1.cs b/Client/Api/Commands/IPublishMessageCommandStep1.cs index 35e33a83..42f2e777 100644 --- a/Client/Api/Commands/IPublishMessageCommandStep1.cs +++ b/Client/Api/Commands/IPublishMessageCommandStep1.cs @@ -41,7 +41,8 @@ public interface IPublishMessageCommandStep2 IPublishMessageCommandStep3 CorrelationKey(string correlationKey); } - public interface IPublishMessageCommandStep3 : IFinalCommandWithRetryStep + public interface IPublishMessageCommandStep3 : IFinalCommandWithRetryStep, + ITenantIdCommandStep { /// /// Set the id of the message. The message is rejected if another message is already published @@ -77,4 +78,4 @@ public interface IPublishMessageCommandStep3 : IFinalCommandWithRetryStep IPublishMessageCommandStep3 Variables(string variables); } -} +} \ No newline at end of file diff --git a/Client/Impl/Commands/PublishMessageCommand.cs b/Client/Impl/Commands/PublishMessageCommand.cs index 56b3a36a..70b40e3c 100644 --- a/Client/Impl/Commands/PublishMessageCommand.cs +++ b/Client/Impl/Commands/PublishMessageCommand.cs @@ -68,6 +68,12 @@ public IPublishMessageCommandStep3 TimeToLive(TimeSpan timeToLive) return this; } + public IPublishMessageCommandStep3 AddTenantId(string tenantId) + { + request.TenantId = tenantId; + return this; + } + public async Task Send(TimeSpan? timeout = null, CancellationToken token = default) { var asyncReply = gatewayClient.PublishMessageAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token);