-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from NerosoftDev/develop
Service bus optimization.
- Loading branch information
Showing
12 changed files
with
960 additions
and
681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,45 @@ | ||
namespace Nerosoft.Euonia.Bus.InMemory; | ||
| ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Nerosoft.Euonia.Bus.InMemory; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class InMemoryQueueConsumer : InMemoryRecipient, IQueueConsumer | ||
{ | ||
private readonly IHandlerContext _handler; | ||
private readonly ILogger<InMemoryQueueConsumer> _logger; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="InMemoryQueueConsumer"/> class. | ||
/// </summary> | ||
/// <param name="handler"></param> | ||
public InMemoryQueueConsumer(IHandlerContext handler) | ||
: base(handler) | ||
/// <param name="logger"></param> | ||
public InMemoryQueueConsumer(IHandlerContext handler, ILoggerFactory logger) | ||
{ | ||
_handler = handler; | ||
_logger = logger.CreateLogger<InMemoryQueueConsumer>(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public string Name => nameof(InMemoryQueueConsumer); | ||
|
||
/// <inheritdoc/> | ||
protected override async Task HandleAsync(string channel, object message, MessageContext context, CancellationToken cancellationToken = default) | ||
{ | ||
try | ||
{ | ||
await _handler.HandleAsync(channel, message, context, cancellationToken); | ||
} | ||
catch (Exception exception) | ||
{ | ||
_logger.LogError(exception, "Message '{Id}' Handle Error: {Message}", context.MessageId, exception.Message); | ||
context.Failure(exception); | ||
} | ||
finally | ||
{ | ||
context.Complete(null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
namespace Nerosoft.Euonia.Bus.InMemory; | ||
| ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Nerosoft.Euonia.Bus.InMemory; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class InMemoryTopicSubscriber : InMemoryRecipient, ITopicSubscriber | ||
{ | ||
private readonly IHandlerContext _handler; | ||
private readonly ILogger<InMemoryTopicSubscriber> _logger; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="InMemoryTopicSubscriber"/> class. | ||
/// </summary> | ||
/// <param name="handler"></param> | ||
public InMemoryTopicSubscriber(IHandlerContext handler) | ||
: base(handler) | ||
/// <param name="logger"></param> | ||
public InMemoryTopicSubscriber(IHandlerContext handler, ILoggerFactory logger) | ||
{ | ||
_handler = handler; | ||
_logger = logger.CreateLogger<InMemoryTopicSubscriber>(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public string Name => nameof(InMemoryTopicSubscriber); | ||
|
||
/// <inheritdoc /> | ||
protected override async Task HandleAsync(string channel, object message, MessageContext context, CancellationToken cancellationToken = default) | ||
{ | ||
try | ||
{ | ||
await _handler.HandleAsync(channel, message, context, cancellationToken); | ||
} | ||
catch (Exception exception) | ||
{ | ||
_logger.LogError(exception, "Message '{Id}' Handle Error: {Message}", context.MessageId, exception.Message); | ||
} | ||
finally | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.