add applications properties to Message Sent to Service bus (#4492)

Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
This commit is contained in:
jdevillard 2023-10-07 23:33:07 +02:00 committed by GitHub
parent 1f014c9264
commit 60508d40b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,6 +52,15 @@ public class SendMessage : CodeActivity
/// The formatter to use when serializing the message body.
/// </summary>
public Input<Type?> FormatterType { get; set; } = default!;
/// <summary>
/// The application properties to embed with the Service Bus Message
/// </summary>
[Input(Category = "Advanced",
DefaultSyntax = "Json",
SupportedSyntaxes = new[] { "JavaScript", "Json" },
UIHint = InputUIHints.MultiLine)
]
public Input<IDictionary<string, object>?> ApplicationProperties { get; set; } = default;
/// <inheritdoc />
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
@ -69,6 +78,9 @@ public class SendMessage : CodeActivity
// TODO: Maybe expose additional members?
};
if (context.Get(ApplicationProperties) != null)
foreach (var property in context.Get(ApplicationProperties))
message.ApplicationProperties.Add(property.Key, ((System.Text.Json.JsonElement)property.Value).GetString());
var client = context.GetRequiredService<ServiceBusClient>();