Skip to content

Commit

Permalink
-Added the ReconnectRetryLimit and SubscribeRetryLimit values to Amqp…
Browse files Browse the repository at this point in the history
…Client to expose them from the underlying IAmqpBrokerConnection instance.

-Corrected ReconnectRetryLimit default value to uint.MaxValue instead of int.MaxValue since its a uint.
  • Loading branch information
meverett committed Mar 19, 2017
1 parent 5b34481 commit 74c4fd7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public RabbitMqBrokerConnection(string name, string server, int amqpPort, int we
exchangeSubscriptions = new List<AmqpExchangeSubscription>();
queueSubscriptions = new List<AmqpQueueSubscription>();

ReconnectRetryLimit = int.MaxValue;
ReconnectRetryLimit = uint.MaxValue;
SubscribeRetryLimit = 10;
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,38 @@ public bool IsConnected
get { return client != null ? client.IsConnected : false; }
}

/// <summary>
/// Gets or sets the maximum number of times the client will attempt to reconnect to the host before aborting.
/// </summary>
public uint ReconnectRetryLimit
{
get { return client != null ? client.ReconnectRetryLimit : uint.MaxValue; }

set
{
client.ReconnectRetryLimit = value;
}
}

/// <summary>
/// Gets or sets the maximum number of failed subscriptions the client will tolerate before preventing connection to the host.
/// </summary>
/// <remarks>
/// Presently in RabbitMQ if there is an error during subscription the host will close the connection
/// so the client must reconnect. In cases where the client attempts to resubscribe the same failing subscription
/// this can lead to an endless loop of connect->subscribe->error->reconnect->infinity. Putting a limit
/// prevents the loop from going on infinitely.
/// </remarks>
public byte SubscribeRetryLimit
{
get { return client != null ? client.SubscribeRetryLimit : (byte)10; }

set
{
client.SubscribeRetryLimit = value;
}
}

/// <summary>
/// The underlying broker connection used by the client.
/// </summary>
Expand Down Expand Up @@ -861,6 +893,27 @@ public void DisconnectFromHost()
client.Disconnect();
}

/// <summary>
/// Resets the connection when it has ended up in an aborted state.
/// </summary>
public static void DiscoResetConnection()
{
if (Instance == null) return;
Instance.ResetConnectionToHost();
}

/// <summary>
/// Resets the connection when it has ended up in an aborted state.
/// </summary>
public void ResetConnectionToHost()
{
if (client == null) return;

// Connect the client
Log("Reseting connection for AMQP host: {0}", AmqpHelper.GetConnectionInfo(client));
client.ResetConnection();
}

#endregion Connection

#region Event Handlers
Expand Down
Binary file modified unity/CymaticLabsUnityAmqp.unitypackage
Binary file not shown.

0 comments on commit 74c4fd7

Please sign in to comment.