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

feat: add tenantId to PublishMessageCommand. #693

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
23 changes: 23 additions & 0 deletions Client.UnitTests/PublishMessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
5 changes: 3 additions & 2 deletions Client/Api/Commands/IPublishMessageCommandStep1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public interface IPublishMessageCommandStep2
IPublishMessageCommandStep3 CorrelationKey(string correlationKey);
}

public interface IPublishMessageCommandStep3 : IFinalCommandWithRetryStep<IPublishMessageResponse>
public interface IPublishMessageCommandStep3 : IFinalCommandWithRetryStep<IPublishMessageResponse>,
ITenantIdCommandStep<IPublishMessageCommandStep3>
{
/// <summary>
/// Set the id of the message. The message is rejected if another message is already published
Expand Down Expand Up @@ -77,4 +78,4 @@ public interface IPublishMessageCommandStep3 : IFinalCommandWithRetryStep<IPubli
/// it to the broker.</returns>
IPublishMessageCommandStep3 Variables(string variables);
}
}
}
6 changes: 6 additions & 0 deletions Client/Impl/Commands/PublishMessageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public IPublishMessageCommandStep3 TimeToLive(TimeSpan timeToLive)
return this;
}

public IPublishMessageCommandStep3 AddTenantId(string tenantId)
{
request.TenantId = tenantId;
return this;
}

public async Task<IPublishMessageResponse> Send(TimeSpan? timeout = null, CancellationToken token = default)
{
var asyncReply = gatewayClient.PublishMessageAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token);
Expand Down
Loading