Skip to content

Conversation

@SeanFeldman
Copy link
Contributor

@SeanFeldman SeanFeldman commented Jun 30, 2020

Fixes Particular/NServiceBus.AzureFunctions.Worker.ServiceBus#43

WARNING: experimental and needs to be validated

@SeanFeldman SeanFeldman self-assigned this Jun 30, 2020
/// Processes a message received from an AzureServiceBus trigger using the NServiceBus message pipeline.
/// </summary>
public async Task Process(Message message, ExecutionContext executionContext, ILogger functionsLogger = null)
public async Task Process(Message message, ExecutionContext executionContext, ILogger functionsLogger = null, IMessageReceiver messageReceiver = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should consider creating a dedicated overload where the message receiver is not optional (and maybe even name it differently)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What benefits will it provide?

Copy link
Contributor

Choose a reason for hiding this comment

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

better indication to the user what it does to provide this parameter

@SeanFeldman SeanFeldman force-pushed the sends-atomic-with-receive branch from e274b65 to 2dda284 Compare June 30, 2020 20:53
functionExecutionContext.Logger.LogDebug($"Failed to move a poisonous message with native ID: `{message.MessageId}` to the dead-letter queue. Message will be retried.", ex);
}

return;
Copy link
Contributor

Choose a reason for hiding this comment

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

if we would rethrow here instead, what would happen given that we moved the message to the DLQ already?

{
public static Task SafeCompleteAsync(this IMessageReceiver messageReceiver, TransportTransactionMode transportTransactionMode, string lockToken)
{
if (transportTransactionMode != TransportTransactionMode.None)
Copy link
Contributor

Choose a reason for hiding this comment

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

that will never be the case because we only switch between SendOnly and SendsAtomicWithReceive?

{
if (transportTransactionMode != TransportTransactionMode.None)
{
return messageReceiver.CompleteAsync(lockToken);
Copy link
Contributor

@timbussmann timbussmann Jul 1, 2020

Choose a reason for hiding this comment

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

wouldn't that currently throw NREs when not providing a message receiver? (same issue on all the extension methods here)

await messageReceiver.SafeAbandonAsync(transportTransactionMode, lockToken).ConfigureAwait(false);

// Indicate to the Functions runtime not to complete the incoming message
throw;
Copy link
Contributor

Choose a reason for hiding this comment

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

this part should probably not be included in the try/catch because it would be just rethrown again on line 126 with an incorrect log message?

@stale
Copy link

stale bot commented Feb 5, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 5, 2021
@stale stale bot closed this Feb 12, 2021
@mikeminutillo
Copy link
Member

I had a look through this and it looks like it's on the right track. We might want to consider dropping the transaction scope in favor of explicitly floating a commitable transaction.

@SeanFeldman
Copy link
Contributor Author

We might want to consider dropping the transaction scope in favor of explicitly floating a commitable transaction.

Have to, not might want 🙂
This spike PR was bears on the transport prior to the changes that happened how transient transaction is avoided. Hence, it would be required to update the code to use a commitable transaction.

@DavidBoike DavidBoike deleted the sends-atomic-with-receive branch November 2, 2021 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for SendsAtomicWithReceive

4 participants