question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Returning ServiceBusMessage doesn't work correctly

See original GitHub issue

When returning a ServiceBusMessage, the message posted contains incorrect information.

[Function(nameof(Run))]
[ServiceBusOutput("audit", Connection = "AzureServiceBus")]
public async Task<ServiceBusMessage> Run([ServiceBusTrigger("Notifications", Connection = "AzureServiceBus")] ServiceBusReceivedMessage message)
{
    // removed for brevity 

    return new ServiceBusMessage(rawMessage);
}

For an incoming message

image

The returned message body is

image

1 - missing original header 2 - incorrect body 3 - incorrect content type

Expected:

image

1 - the original header (EventType) is found 2 - original body 3 - correct content type

Issue Analytics

  • State:open
  • Created a month ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
SeanFeldmancommented, Aug 18, 2023

I’d probably want to still present the client approach as an option to consider when discussing the single message return in guidance

+1 on that.

Also, I’d suggest showing the sample how to handle the incoming message from middleware. Much of the boilerplate code could be moved from functions into middleware (related to issue #1824) when implementing some sort of custom framework on top of SB-triggered functions.

1reaction
SeanFeldmancommented, Aug 16, 2023

I could imagine simplifying the hypothetical: what if the function can just get the ServiceBusSender and then call .SendMessageAsync(msg)?

This might be more effective as the clients could be cached based on the connection and entity those are requested for.

With all that said, receiving a ServiceBusReceivedMessage and returning from function a ServiceBusMessage would be extremely simple and powerful. And would satisfy a lot of scenarios where an incoming message is generating an outgoing message. For multiple messages, I’d agree that a client is a better approach (IAsyncCollector in In-Proc SDK was a bit of a weird API). But for a single returned message, there’s a value in considering returning just a ServiceBusMessage w/o the need for a client or sender.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In Azure function that returns ServiceBus message, how do ...
I have an azure function which returns a service bus message. However, I want to conditionally return a service bus message, ...
Read more >
Troubleshooting guide for Azure Service Bus
This article provides troubleshooting tips and recommendations for a few issues that you may see when using Azure Service Bus.
Read more >
Azure Service Bus message transfers, locks, and settlement
This article provides an overview of Azure Service Bus message transfers, locks, and settlement operations.
Read more >
Azure Functions Isolated Worker - Sending multiple messages
Hello, I am having a really hard time getting this to work, and I see this error about being 'unable to configure binding',...
Read more >
azure.servicebus package — Azure SDK for Python 2.0.0 ...
Setting this value enables assigning related messages to the same internal partition, so that submission sequence order is correctly recorded. The partition is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found