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

ServiceBusSessionMessageActions not working with IsBatched=true #2873

Open
Meorir opened this issue Nov 17, 2024 · 4 comments
Open

ServiceBusSessionMessageActions not working with IsBatched=true #2873

Meorir opened this issue Nov 17, 2024 · 4 comments
Labels
bug Something isn't working extensions: service-bus

Comments

@Meorir
Copy link

Meorir commented Nov 17, 2024

Description

When trying to bind
ServiceBusSessionMessageActions sessionActions

while having IsBatched = true

causes this error:
Result: Function 'ServiceBusHandler', Invocation id '5dae4abd-65bf-434d-97f9-ad28900a6c2d': An exception was thrown by the invocation. Exception: Microsoft.Azure.Functions.Worker.FunctionInputConverterException: Error converting 1 input parameters for Function 'ServiceBusHandler': Cannot convert input parameter 'sessionActions' to type 'Microsoft.Azure.Functions.Worker.ServiceBusSessionMessageActions' from type 'System.String'. Error:System.InvalidOperationException: Expecting SessionId within binding data and value was not present. Sessions must be enabled when binding to ServiceBusSessionMessageActions.

I assume batch processing in session enabled subscription (or queue) should be locked to a single session per invocation due to session locks.

[Function("ServiceBusHandler")]
public async Task ServiceBusHandler(
[ServiceBusTrigger("%ServiceBusTopicName%",
"%ServiceBusSubscriptionName%",
Connection = "ServiceBusConnectionString",
IsSessionsEnabled = true,
AutoCompleteMessages = false,
IsBatched = true)]
ServiceBusReceivedMessage[] messages,
ServiceBusMessageActions messageActions,
ServiceBusSessionMessageActions sessionActions
)

When using with single message everything works fine.
(except SetSessionStateAsync not accepting null as parameter, and not allowing to clear session state, but that is another bug)

Steps to reproduce

Create a trigger for session-enabled ASB subscription:

[Function("ServiceBusHandler")]
public async Task ServiceBusHandler(
[ServiceBusTrigger("%ServiceBusTopicName%",
"%ServiceBusSubscriptionName%",
Connection = "ServiceBusConnectionString",
IsSessionsEnabled = true,
AutoCompleteMessages = false,
IsBatched = true)]
ServiceBusReceivedMessage[] messages,
ServiceBusMessageActions messageActions,
ServiceBusSessionMessageActions sessionActions
)

After invocation the mapping throws an error

@Meorir Meorir added the potential-bug Items opened using the bug report template, not yet triaged and confirmed as a bug label Nov 17, 2024
@jviau
Copy link
Contributor

jviau commented Nov 22, 2024

Duplicate of #2815

@jviau jviau marked this as a duplicate of #2815 Nov 22, 2024
@jviau
Copy link
Contributor

jviau commented Nov 22, 2024

@Meorir please see the issue I duplicated this to - you are experiencing the same problem, source gen is not running for your project.

@jviau jviau closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2024
@jviau
Copy link
Contributor

jviau commented Nov 22, 2024

Re-opening, looked into this a bit more and I think there is a gap with batched receive and ServiceBusSessionMessageActions

@jviau jviau reopened this Nov 22, 2024
@jviau jviau added bug Something isn't working and removed potential-bug Items opened using the bug report template, not yet triaged and confirmed as a bug labels Nov 22, 2024
@jviau
Copy link
Contributor

jviau commented Nov 22, 2024

@Meorir I have identified a gap in our binding support here. Combining session, batch, and ServiceBusSessionMessageActions is not currently supported, leading to the issue you see. For now, you can use ServiceBusSessionMessageActions if you remove the batched behavior from your trigger. We will use this issue to track adding batch support to this area.

Issue

ServiceBusSessionMessageActionsConverter says it supports ServiceBusSessionMessageActions[], however its implementation does not correctly bind to an array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working extensions: service-bus
Projects
None yet
Development

No branches or pull requests

2 participants