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

added publisher confirms functionality to RabbitMQ #1906

Merged
merged 7 commits into from
Mar 27, 2024

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented Mar 27, 2024

Changes

Implements https://www.rabbitmq.com/docs/confirms#publisher-confirms functionality to AmqpSink and AmqpFlow stages, for an extra dose of guaranteed reliability.

Checklist

@Aaronontheweb Aaronontheweb added the rabbitmq Issues affecting RabbitMQ / AMQP connectors label Mar 27, 2024
@Aaronontheweb Aaronontheweb added this to the Alpakka v1.5.19 milestone Mar 27, 2024
Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

Detailed my changes

Copy link
Member Author

Choose a reason for hiding this comment

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

End to end spec using AmpqSink and AmpqFlow with publisher confirmations enabled

@@ -12,11 +13,11 @@ namespace Akka.Streams.Amqp.RabbitMq
public class AmqpFlowStage<TPassThrough> : GraphStageWithMaterializedValue<FlowShape<(OutgoingMessage, TPassThrough), TPassThrough>, Task>
{
public static readonly Attributes DefaultAttributes =
Attributes.CreateName("AmqpFlow").And(ActorAttributes.CreateDispatcher("akka.stream.default-blocking-io-dispatcher"));
Copy link
Member Author

Choose a reason for hiding this comment

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

No need to run on the blocking I/O dispatcher

@@ -59,6 +60,13 @@ public Logic(AmqpFlowStage<TPassThrough> stage, TaskCompletionSource<Done> promi
elem.Mandatory,
elem.Properties,
elem.Bytes.ToArray());

if(_stage.Settings.WaitForConfirms)
Copy link
Member Author

Choose a reason for hiding this comment

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

Upon publish, wait for confirms before we push downstream.

if (_stage.Settings.WaitForConfirms)
{
// enable publisher confirms
Channel.ConfirmSelect();
Copy link
Member Author

Choose a reason for hiding this comment

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

Need this in order to enable publisher confirmations on the channel

@@ -56,6 +58,14 @@ public AmqpSinkStageLogic(AmqpSinkStage stage, TaskCompletionSource<Done> promis
elem.Mandatory,
elem.Properties,
elem.Bytes.ToArray());

if(_stage.Settings.WaitForConfirms)
Copy link
Member Author

Choose a reason for hiding this comment

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

Mirrors what we did in the flow

if (_stage.Settings.WaitForConfirms)
{
// enable publisher confirms
Channel.ConfirmSelect();
Copy link
Member Author

Choose a reason for hiding this comment

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

Mirrors what we did in the flow

/// </remarks>
public bool WaitForConfirms => WaitForConfirmsTimeout is not null;

public TimeSpan? WaitForConfirmsTimeout { get; }
Copy link
Member Author

Choose a reason for hiding this comment

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

Settings - when this gets set to a non-null value that will enabled publisher confirms using the specified timeout.

@Aaronontheweb Aaronontheweb marked this pull request as ready for review March 27, 2024 19:54
@Aaronontheweb Aaronontheweb merged commit 33e567f into akkadotnet:dev Mar 27, 2024
1 of 4 checks passed
@Aaronontheweb Aaronontheweb deleted the wait-for-confirms branch March 27, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rabbitmq Issues affecting RabbitMQ / AMQP connectors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant