Conversation
|
@DavidBoike @mattmercurio this seems to work as intended. |
| { | ||
| entries.Add(new("ReceiverEndpoint", "ReceiverEndpoint", "AzureWebJobsServiceBus")); | ||
| entries.Add(new("AnotherReceiverEndpoint", "AnotherReceiverEndpoint", "AzureWebJobsServiceBus")); | ||
| } |
There was a problem hiding this comment.
If this isn't generated the compiler is smart enough to just remove the call to it https://github.com/Particular/NServiceBus.AzureFunctions/pull/17/changes#diff-ee8c777d474fb183096f7268d8acc6fb6a653a75ef70b7eeba14423385352d0aR10
There was a problem hiding this comment.
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.
d033c03 to
d8b8b1f
Compare
|
@DavidBoike @mattmercurio I have rebased and added a few more ideas. See comments inline |
| ConnectionName = "AzureWebJobsServiceBus" | ||
| }; | ||
|
|
||
| var routing = endpoint.UseTransport(transport); |
There was a problem hiding this comment.
Demo use of routing
| builder.Services.AddHostedService<InitializeLogger>(); | ||
|
|
||
| builder.AddNServiceBusFunction("SenderEndpoint", endpoint => | ||
| builder.AddSendOnlyNServiceBusEndpoint("SenderEndpoint", endpoint => |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
These were leftovers from the old repo and is, at least currently, not needed
|
|
||
| using Microsoft.Extensions.Hosting; | ||
|
|
||
| public class FunctionConfigurationValidator : IHostedService |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
@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
|
Closed in favour of #20 |
No description provided.