Skip to content

Conversation

@andreasohlund
Copy link
Member

No description provided.

@andreasohlund
Copy link
Member Author

@DavidBoike @mattmercurio this seems to work as intended.

{
entries.Add(new("ReceiverEndpoint", "ReceiverEndpoint", "AzureWebJobsServiceBus"));
entries.Add(new("AnotherReceiverEndpoint", "AnotherReceiverEndpoint", "AzureWebJobsServiceBus"));
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@andreasohlund andreasohlund Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/partial-member

A partial method isn't required to have an implementing declaration in the following cases:

It doesn't have any accessibility modifiers (including the default private).
It returns void.
It doesn't have any out parameters.
It doesn't have any of the following modifiers virtual, override, sealed, new, or extern.

@andreasohlund
Copy link
Member Author

@DavidBoike @mattmercurio I have rebased and added a few more ideas. See comments inline

ConnectionName = "AzureWebJobsServiceBus"
};

var routing = endpoint.UseTransport(transport);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Demo use of routing

builder.Services.AddHostedService<InitializeLogger>();

builder.AddNServiceBusFunction("SenderEndpoint", endpoint =>
builder.AddSendOnlyNServiceBusEndpoint("SenderEndpoint", endpoint =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a separate code path for send-only seems to make validation and other things much cleaner

var transport = new AzureServiceBusServerlessTransport(TopicTopology.Default)
{
//send only endpoints might need to set the connection name
ConnectionName = "AzureWebJobsServiceBus"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the use case where users might want to control the connection name, if so we might want to add this option to AddSendOnlyNServiceBusEndpoint and not on the transport definition

public Task Receiver(
[ServiceBusTrigger("ReceiverEndpoint", Connection = "AzureWebJobsServiceBus", AutoCompleteMessages = true)]
ServiceBusReceivedMessage message,
ServiceBusMessageActions messageActions, FunctionContext context, CancellationToken cancellationToken = default)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were leftovers from the old repo and is, at least currently, not needed


using Microsoft.Extensions.Hosting;

public class FunctionConfigurationValidator : IHostedService
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sure that all functions that we found have been configured by the user

configure(endpointConfiguration);

var settings = endpointConfiguration.GetSettings();
if (settings.GetOrDefault<bool>(AzureServiceBusServerlessTransport.SendOnlyConfigKey))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have a separate code path for send-only we can guard here


var functionManifest = FunctionsRegistry.GetAll().SingleOrDefault(f => f.Name.Equals(endpointName, StringComparison.InvariantCultureIgnoreCase));

if (functionManifest is null)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since send only is on a different code path we must have a correcsponding function at this stage

endpointConfiguration.SendOnly();

// Make sure that the correct transport is used
_ = GetTransport(endpointConfiguration.GetSettings());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugly but gets the job done for now to make sure that the user has configured a AzureServiceBusServerlessTransport

await endpointStarter.GetOrStart(cancellationToken).ConfigureAwait(false);
await transport.MessageProcessor.Process(message, messageActions, cancellationToken).ConfigureAwait(false);

if (transport.MessageProcessor is null)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this new world we can never come here unless the user has configured a non-send-only endpoint but we are guaarding anyway for completeness

@@ -0,0 +1,12 @@
namespace NServiceBus;

static partial class FunctionsRegistry
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidBoike now I get what you meant yesterday, this code will be generated in the user assembly and not here so this won't work.

I have another idea, stay tuned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant