Because the new version contains a few breaking changes, we provide a dedicated migration guide to help end-users to migrate to our new approach.
Come and take a quick look what the release has to offer in this overview blog post.
New Azure SDK
Microsoft released a new client library SDK for interacting with Azure Service Bus resources. This new library is part of the overall Azure SDK updates.
We believe we need to align with this new strategy, so we have adopted it in Arcus Security and now it was time to align Arcus Messaging.
The most notable change here for end-users is the move from the Azure Service Bus Message
model towards the ServiceBusReceivedMessage
.
This breaking change has the most impact on our extensions & fallback message handlers, which receive the full Azure Service Bus message in their implementation.
Here is an example of our new signature:
using Arcus.Message.Abstractions.ServiceBus.MessageHandling; | |
using Azure.Messaging.ServiceBus; | |
public class OrderFallbackMessageHandler : IAzureServiceBusFallbackMessageHandler | |
{ | |
private readonly ILogger _logger; | |
public OrderFallbackMessageHandler(ILogger<OrderFallbackMessageHandler> logger) | |
{ | |
_logger = logger; | |
} | |
public Task ProcessMessageAsync( | |
ServiceBusReceivedMessage message, | |
AzureServiceBusMessageContext messageContext, | |
MessageCorrelationInfo messageCorrelationInfo, | |
CancellationToken cancellactionToken) | |
{ | |
_logger.LogInformation("Start processing Azure Service Bus message {MessageId}...", message.MessageId); | |
} | |
} |
Microsoft also provides a dedicated migration guide for this new Azure SDK, if you are curious about any new functionality or changes.
using Arcus.Messaging.Abstractions; | |
using Arcus.Messaging.Abstractions.ServiceBus; | |
using Arcus.Messaging.Abstractions.ServiceBus.MessageHandling; | |
using Azure.Messaging.ServiceBus; | |
using Microsoft.Azure.ServiceBus; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Extensions.Logging; | |
public class OrderProcessingFunction | |
{ | |
private readonly IAzureServiceBusMessageRouter _messageRouter; | |
private readonly string _jobId; | |
public OrderProcessingFunction(IAzureServiceBusMessageRouter messageRouter) | |
{ | |
_messageRouter = messageRouter; | |
_jobId = Guid.NewGuid().ToString(); | |
} | |
[FunctionName("order-processing")] | |
public async Task Run( | |
[ServiceBusTrigger("docker-az-func-queue", Connection = "ARCUS_SERVICEBUS_CONNECTIONSTRING")] ServiceBusReceivedMessage message, | |
ILogger log, | |
CancellationToken cancellationToken) | |
{ | |
log.LogInformation($"C# ServiceBus queue trigger function processed message: {message.MessageId}"); | |
AzureServiceBusMessageContext context = message.GetMessageContext(_jobId); | |
MessageCorrelationInfo correlationInfo = message.GetCorrelationInfo(); | |
await _messageRouter.RouteMessageAsync(message, context, correlationInfo, cancellationToken); | |
} | |
} |
Managed identity authentication
We leverage a new way of authenticating the Azure Service Bus message pump by using password-less authentication with managed identity authentication for both Azure Service Bus queues and topics.
Managed identity authentication allows you to remove secrets and fully rely on the automatically assigned identity to authenticate with any Azure service.
For more information, see the offical Microsoft documentation.
using Microsoft.Extensions.DependencyInjection; | |
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
// Uses managed identity to authenticate with the Azure Service Bus Queue: | |
services.AddServiceBusQueueMessagePumpUsingManagedIdentity( | |
queueName: "orders", | |
serviceBusNamespace: "<your-namespace>" | |
// The optional client id to authenticate for a user assigned managed identity. | |
clientId: "<your-client-id>"); | |
// Uses managed identity to authenticate with the Azure Service Bus Topic: | |
services.AddServiceBusTopicMessagePumpUsingManagedIdentity( | |
topicName: properties.EntityPath, | |
subscriptionName: "Receive-All", | |
serviceBusNamespace: "<your-namespace>" | |
// The optional client id to authenticate for a user assigned managed identity. | |
clientId: "<your-client-id>"); | |
} | |
} |
using Microsoft.Extensions.DependencyInjection; | |
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddServiceBusTopicMessagePump( | |
"<your-servicebus-topic-name>", | |
"<your-servicebus-namespace-connection-string>", | |
options => options.Deserialization.AdditionalMembers = AdditionalMembersHandling.Ignore) | |
.WithServiceBusMessageHandler<OrderMessageHandler, Order>(); | |
} | |
} |
Conclusion
Arcus Messaging v1.0 is a big improvement with a lot of changes and improvements making it more production-ready.
Have a look at our release notes and official documentation for more information on this new release.
If you have any questions, remarks, comments, or just want to discuss something with us; feel free to contact us.
Thanks for reading!
The Arcus team
Subscribe to our RSS feed