Skip to content

Commit

Permalink
Making the Rabbit MQ Listener "Auto Ping" behavior be opt in
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Jun 29, 2024
1 parent 3097eb9 commit c75f35b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ internal class RabbitMqListener : RabbitMqChannelAgent, IListener, ISupportDeadL
NativeDeadLetterQueueEnabled = queue.DeadLetterQueue != null &&
queue.DeadLetterQueue.Mode != DeadLetterQueueMode.WolverineStorage;

// This is trying to be a forcing function to make the channel really connect
var ping = Envelope.ForPing(Address);
Task.Run(() => _sender.Value.SendAsync(ping));
if (transport.AutoPingListeners)
{
// This is trying to be a forcing function to make the channel really connect
var ping = Envelope.ForPing(Address);
Task.Run(() => _sender.Value.SendAsync(ping));
}
}

public RabbitMqQueue Queue { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ internal ConnectionMonitor BuildConnection(ConnectionRole role)
}

public ILogger<RabbitMqTransport> Logger { get; private set; } = NullLogger<RabbitMqTransport>.Instance;

/// <summary>
/// Opt into making Wolverine "auto ping" new listeners by trying to send a fake Wolverine "ping" message
/// This *might* assist in Wolverine auto-starting rabbit mq connections that have failed on the Rabbit MQ side
/// </summary>
public bool AutoPingListeners { get; set; } = false;

public RabbitMqQueue EndpointForQueue(string queueName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ public RabbitMqTransportExpression(RabbitMqTransport transport, WolverineOptions
{
}

/// <summary>
/// Opt into making Wolverine "auto ping" new listeners by trying to send a fake Wolverine "ping" message
/// This *might* assist in Wolverine auto-starting rabbit mq connections that have failed on the Rabbit MQ side
/// Experimental
/// </summary>
public RabbitMqTransportExpression AutoPingListeners()
{
Transport.AutoPingListeners = true;
return this;
}

/// <summary>
/// Make any necessary customizations to the Rabbit MQ client's ConnectionFactory
/// </summary>
Expand Down

0 comments on commit c75f35b

Please sign in to comment.