Skip to content

Commit

Permalink
Merge pull request #52 from NerosoftDev/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Codespilot authored Dec 10, 2023
2 parents b616ac4 + 3ac6be8 commit ff990d9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Source/Euonia.Bus/Core/IHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public interface IHandler<in TMessage> : IHandler
/// Handle message.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="messageContext">The message context.</param>
/// <param name="context">The message context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
Task HandleAsync(TMessage message, MessageContext messageContext, CancellationToken cancellationToken = default);
Task HandleAsync(TMessage message, MessageContext context, CancellationToken cancellationToken = default);
}
29 changes: 21 additions & 8 deletions Source/Euonia.Bus/Core/ServiceBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ public Task PublishAsync<TMessage>(TMessage message, PublishOptions options, Act
{
options ??= new PublishOptions();

if (!_convention.IsTopicType(message.GetType()))
var messageType = message.GetType();

if (!_convention.IsTopicType(messageType))
{
throw new MessageTypeException("The message type is not an event type.");
throw new MessageTypeException("The message type is not an topic type.");
}

var context = _requestAccessor?.Context;

var channelName = options.Channel ?? MessageCache.Default.GetOrAddChannel<TMessage>();
var channelName = options.Channel ?? MessageCache.Default.GetOrAddChannel(messageType);
var pack = new RoutedMessage<TMessage>(message, channelName)
{
MessageId = options.MessageId ?? Guid.NewGuid().ToString(),
Expand All @@ -63,14 +65,16 @@ public Task SendAsync<TMessage>(TMessage message, SendOptions options, Action<Me
{
options ??= new SendOptions();

if (!_convention.IsQueueType(message.GetType()))
var messageType = message.GetType();

if (!_convention.IsQueueType(messageType))
{
throw new MessageTypeException("The message type is not a queue type.");
}

var context = _requestAccessor?.Context;

var channelName = options.Channel ?? MessageCache.Default.GetOrAddChannel<TMessage>();
var channelName = options.Channel ?? MessageCache.Default.GetOrAddChannel(messageType);
var pack = new RoutedMessage<TMessage>(message, channelName)
{
MessageId = options.MessageId ?? Guid.NewGuid().ToString(),
Expand All @@ -90,14 +94,16 @@ public Task<TResult> SendAsync<TMessage, TResult>(TMessage message, SendOptions
{
options ??= new SendOptions();

if (!_convention.IsQueueType(message.GetType()))
var messageType = message.GetType();

if (!_convention.IsQueueType(messageType))
{
throw new MessageTypeException("The message type is not a queue type.");
}

var context = _requestAccessor?.Context;

var channelName = options.Channel ?? MessageCache.Default.GetOrAddChannel<TMessage>();
var channelName = options.Channel ?? MessageCache.Default.GetOrAddChannel(messageType);
var pack = new RoutedMessage<TMessage, TResult>(message, channelName)
{
MessageId = options.MessageId ?? Guid.NewGuid().ToString(),
Expand All @@ -123,9 +129,16 @@ public Task<TResult> SendAsync<TResult>(IQueue<TResult> message, SendOptions opt
{
options ??= new SendOptions();

var messageType = message.GetType();

if (!_convention.IsQueueType(messageType))
{
throw new MessageTypeException("The message type is not a queue type.");
}

var context = _requestAccessor?.Context;

var channelName = options.Channel ?? MessageCache.Default.GetOrAddChannel(message.GetType());
var channelName = options.Channel ?? MessageCache.Default.GetOrAddChannel(messageType);
var pack = new RoutedMessage<IQueue<TResult>, TResult>(message, channelName)
{
MessageId = options.MessageId ?? Guid.NewGuid().ToString(),
Expand Down
2 changes: 1 addition & 1 deletion project.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>8.1.2</Version>
<Version>8.1.3</Version>
<Authors>damon</Authors>
<Company>Nerosoft Ltd.</Company>
<Product>Euonia</Product>
Expand Down

0 comments on commit ff990d9

Please sign in to comment.