-
Notifications
You must be signed in to change notification settings - Fork 36
Service Bus Batch Trigger #15
Comments
I think this would be extremely useful. I ran a simple test to use the ServiceBusTrigger in a WebJob S2 instance and the performance I got was about 22 messages a second. The current model is just not sufficient for higher throughput. The sample I am using is here https://github.com/tcsatheesh/samples/tree/master/ServiceBusTrigger If you change the PrefetchCount and MaxConcurrentCalls to say 100 and 100. I still only see a throughput of 21msg/sec. |
Related to Azure/azure-webjobs-sdk#570, but keeping this one open due to the completness of the request. |
Are there any work in progress with this issue? |
I have the same exact issue but for azure storage queues. I need to subscribe to a "batch" of queue messages instead of just one using Azure Functions. |
Any update on this? Performance of |
Our organization would really love to leverage this functionality when it becomes available |
This would be great for us also, we use javascript for our funcs so perhaps another config parameter in the binding configuration to specify batch size and max wait time for that batch size |
+1 |
We also have customers asking for this one |
ServiceBus batch trigger would be a great option for multiple scenarios. |
+1 |
1 similar comment
+1 |
Can people please thumbs up on the issue rather than +1? +1 causes an email, which I don't really want in this scenario (and now I'm causing an email with this! 😃) |
@christopheranderson any updates on this?! Thanks. |
Is there any update on when to expect this? Would be critical for a current project volume. Thanks! |
ServiceBus SDK does not support batched receive. I marked the issue as blocked until batched receive be implemented in ServiceBus SDK. |
Service Bus supports |
The feature is in beta state (Microsoft.Azure.WebJobs.Extensions.ServiceBus 3.1.0-beta4-batch). If you want to try please reference the package from here: I would be grateful for any feedback. |
@alrod could you please share a link to the documentation (or PR) for this new addition? Thank you. |
There is not documentation in the moment.
Also you can specify Note PR: |
@alrod does that batching work with sessions enabled? I.e., can we batch read and have the "isSessionsEnabled" attribute? |
Unfortunately |
@alrod I think when you use ISessionClient (which inherits and expands on IMessageReceiver) it will still be able to ReceiveAsync with a batch for a specific SessionId (gotta call AcceptMessageSessionAsync first to get an IMessageSession). I created a simple sample netcoreapp2.2 here: https://github.com/nzthiago/ServiceBusBatchReceiveWithSessions As you can see it sends 10 messages to 2 sessions ("1", and "2"). Then it tries to read from only session "1" in batches of 5 and it's successful: |
VERIFIED THAT THIS WORKS WITH THE BETA PACKAGE. IGNORE MESSAGE! Would be nice to have the metadata properties available for the earlier versions supported as valid parameter Types in the new package version - Microsoft.Azure.WebJobs.Extensions.ServiceBus 3.1.0-beta4-batch I got an error while executing a function with the 'EnqueuedTimeUtc' property - |
@alrod Microsoft.Azure.WebJobs.Extensions.ServiceBus was updated to 3.1.0 a couple of days ago |
@JoeyRobles it looks like it doesn't. It looks like the 3.1.0 is based on the 3.1.0-beta4 and not on the 3.1.0-beta4-batch. :-( |
Also how the batch size would work in relation to prefetch count? thanks. |
@alrod Does the Service Bus trigger batching work for node.js functions? |
@RobertPinson yes, it works. you need to add |
@batizar, Prefetching vs batching: |
thanks @alrod the cardinality: many worked in my node function, can you set maxMessageCount in a node function? |
Addressing this documentation feedback would help with all these later questions in this thread: https://github.com/MicrosoftDocs/azure-docs/issues/52706 |
@RobertPinson, @batizar Example:
|
Created a task to track this (internal doc tracking site with our team) https://dev.azure.com/mseng/TechnicalContent/_workitems/edit/1778524 @alrod other piece here would be what the |
Assuming you have Batching via the array of Messages, as per:
Assuming AutoComplete is off, an unhandled exception is thrown "Operation is not valid due to the current state of the object." when using the MessageReceiver to Complete or DeadLetter the message.
If you remove batching, by removing the array, the same operations no longer generate the exception? Does batching, via the array, somehow prevent interact with the MessageReceiver to throw the exception? |
@alrod thanks for you reply, how is
|
I have a Function with a ServiceBusTrigger, such as below Microsoft.Azure.WebJobs.Script.WebHost: Scope disposed{no name} is disposed and scoped instances are disposed and no longer available. However, if I simply swap "Message message" to "string message", it works? I should add, I want to use Batch Messages, with the message receiver, with autocomplete disabled, such that I can manage failures of each message in the batch independently. |
Hi @RobertPinson, when I try this, I get an error:
similar to this: Azure/azure-functions-templates#905
Nevermind, I found my problem, I needed to ensure I get the 2.x extensions:
However, the batching still doesn't work.... |
Hi @tripodsan the Service Bus batch read feature is in the latest version of the Microsoft.Azure.WebJobs.Extensions.ServiceBus 4.2.0 which is not in the latest extension bundle. the version of the service bus extension in the latest bundle is 3.2.0. To explicitly install the extensions you need to remove the instructions here https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-register |
Really appreciate the support for a batch trigger, however, I can't find it documented anywhere. Is there any official documentation of this functionality? |
|
|
I would recommend that to be in the official docs on https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus for better discoverability given @nicklasjepsen couldn't find it (including non .NET languages) |
@alrod Can we use service bus batching in java?Should we add anything in the @ServiceBusQueueTrigger annotation to enable this |
@jothyb it doesn't seem like there's documentation for the batch trigger in Java yet; but it's certainly possible, with the Cardinality set to MANY and an array of string in the trigger declaration, see here for an example: https://github.com/Azure/azure-functions-java-worker/blob/976635d81a31f2464f8b5ca1925d91b6e1b139a2/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/ServiceBusQueueTriggerTests.java#L24 |
@jothyb yes you'll need to update the extension bundle to v2, it seems the current VS Code template still points to v1. I did some digging, it seems that the User Properties are exposed by the Service Bus extension, so I played with it a little and was able to get the user properties by using @BindingName("UserPropertiesArray"). Here's my example: package com.function;
import java.util.*;
import com.microsoft.azure.functions.annotation.*;
import com.microsoft.azure.functions.*;
public class Sbjavatesttempfunc {
@FunctionName("Sbjavatesttempfunc")
public void Sbjavatesttempfunc(
@ServiceBusQueueTrigger(name = "messages", queueName = "sbjavatesttempqueue", connection = "ServiceBusConnString",
cardinality = Cardinality.MANY, dataType = "string") List<String> messages,
@BindingName("UserPropertiesArray") List<String> userPropertiesArray,
final ExecutionContext context) {
context.getLogger().info("Java Service Bus trigger processed a request. Total message count:" + messages.size());
for(int i = 0; i < messages.size(); i++){
context.getLogger().info("Message number : " + i);
context.getLogger().info(messages.get(i));
context.getLogger().info("User properties for message: " + i);
context.getLogger().info(userPropertiesArray.get(i));
}
}
} When it reads a batch of messages, it will print out as follows: You can probably convert the userPropertiesArray to a Map, but I kept it simple, let me know if this works for you. |
Thank you @nzthiago ,it worked 👍 . |
Hello there, Is batching currently supported only for InProcess funcitons? I tried the host batch configurations, for Isolated function, with string[] ServiceBusTrigger param but it's not working. Any update if this is supported for Isolated functions? |
Here are some examples: https://github.com/Azure-Samples/azure-functions-samples-java/blob/master/src/main/java/com/functions/ServiceBusQueueTriggerFunction.java#L26 |
SB batch trigger should work in isolated worker so the team will investigate as part of Azure/azure-functions-dotnet-worker#906 to see if there's any issues. Please follow that issue given this one is closed. |
@nzthiago I am trying to use batch messages in service bus trigger for Azure functions . I am using Azure functions python library . As per the below URL I can see that the batching was enabled on python version from 1.5.0 onwards Azure function version : 4 host.json
function.json
sample code in function app
am I missing anything here ? |
I'd like to start a conversation around supporting batches of messages from an Azure Service Bus. A similar request was made for Storage Queues in Azure/azure-webjobs-sdk#625
Ideally, I'd be able to specify something like:
There are a lot of scenarios where batching message processing is far more efficient than working with an individual message. In my specific case, I'm doing database inserts and those could be done much more efficiently in a batch.
I'm going to look into a similar project that supports Storage Queues: https://github.com/ealsur/WebJobs.Extensions.GroupQueueTrigger
Is this something others would be interested in?
The text was updated successfully, but these errors were encountered: