Skip to content

Commit

Permalink
6.0.3 - add IServiceBusCommunicationListener to DefaultServiceBusMess…
Browse files Browse the repository at this point in the history
…ageReceiver
  • Loading branch information
Loek committed Jan 9, 2019
1 parent 8b7a288 commit 729bcb2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@
/ServiceFabric.ServiceBus.Clients/bin/x64/Release
**/*.nupkg
/ServiceFabric.ServiceBus.Services.Netstd/obj
/ServiceFabric.ServiceBus.Services.Netstd/bin/
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace ServiceFabric.ServiceBus.Services.Netstd
/// Func&lt;IServiceBusCommunicationListener, IServiceBusMessageReceiver&gt; receiverFactory</remarks>
public abstract class DefaultServiceBusMessageReceiver : IServiceBusMessageReceiver
{
private readonly IServiceBusCommunicationListener _receiver;

/// <summary>
/// Gets or sets a callback for writing logs. (Defaults to null)
Expand All @@ -28,15 +27,20 @@ public abstract class DefaultServiceBusMessageReceiver : IServiceBusMessageRecei
/// <inheritdoc />
/// <summary>Defaults to true.</summary>
public bool AutoComplete { get; set; } = true;


/// <summary>
/// Provides access to the provided <see cref="IServiceBusCommunicationListener"/>.
/// </summary>
protected IServiceBusCommunicationListener Listener { get; }

/// <summary>
/// Creates a new instance using the provided log callback.
/// </summary>
/// <param name="receiver"></param>
/// <param name="logAction"></param>
protected DefaultServiceBusMessageReceiver(IServiceBusCommunicationListener receiver, Action<string> logAction)
{
_receiver = receiver ?? throw new ArgumentNullException(nameof(receiver));
Listener = receiver ?? throw new ArgumentNullException(nameof(receiver));
LogAction = logAction;
}
/// <summary>
Expand All @@ -45,7 +49,7 @@ protected DefaultServiceBusMessageReceiver(IServiceBusCommunicationListener rece
/// <param name="receiver"></param>
protected DefaultServiceBusMessageReceiver(IServiceBusCommunicationListener receiver)
{
_receiver = receiver ?? throw new ArgumentNullException(nameof(receiver));
Listener = receiver ?? throw new ArgumentNullException(nameof(receiver));
}

/// <summary>
Expand All @@ -61,7 +65,7 @@ public async Task ReceiveMessageAsync(Message message, CancellationToken cancell
await ReceiveMessageImplAsync(message, cancellationToken);
if (AutoComplete)
{
await _receiver.Complete(message);
await Listener.Complete(message);
}
}
catch (Exception ex)
Expand All @@ -81,7 +85,7 @@ public async Task ReceiveMessageAsync(Message message, CancellationToken cancell
protected virtual async Task<bool> HandleReceiveMessageError(Message message, Exception ex)
{
WriteLog($"Abandoning message {message.MessageId}. Error:'{ex}'.");
await _receiver.Abandon(message).ConfigureAwait(false);
await Listener.Abandon(message).ConfigureAwait(false);
//assuming overriding code handles exceptions.
return true;
}
Expand All @@ -94,7 +98,7 @@ protected virtual async Task<bool> HandleReceiveMessageError(Message message, Ex
protected Task AbandonMessage(Message message, IDictionary<string, object> propertiesToModify)
{
WriteLog($"Moving message {message.MessageId} to dead letter queue.");
return _receiver.Abandon(message, propertiesToModify);
return Listener.Abandon(message, propertiesToModify);
}

/// <summary>
Expand All @@ -105,7 +109,7 @@ protected Task AbandonMessage(Message message, IDictionary<string, object> prope
protected Task DeadLetterMessage(Message message, IDictionary<string, object> propertiesToModify)
{
WriteLog($"Moving message {message.MessageId} to dead letter queue.");
return _receiver.DeadLetter(message, propertiesToModify);
return Listener.DeadLetter(message, propertiesToModify);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Receive BrokeredMessages in ServiceFabric Services through Service Bus. Add this package to your Reliable Service projects. The ServiceFabric.ServiceBus.Services Class Library can be used in conjunction with ServiceFabric.ServiceBus.Clients (optional)</Description>
<Copyright>2019</Copyright>
<VersionPrefix>6.0.2</VersionPrefix>
<VersionPrefix>6.0.3</VersionPrefix>
<Authors>Loek Duys</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
Expand Down

0 comments on commit 729bcb2

Please sign in to comment.