Skip to content

Commit

Permalink
Merge pull request #39 from ojdev/dev
Browse files Browse the repository at this point in the history
修改默认的队列名前缀
  • Loading branch information
ojdev committed Oct 21, 2019
2 parents b46dd03 + e9c1d64 commit 17c834c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void LoggingWriteLevel(LogLevel level)
/// 队列名前缀
/// </summary>
/// <param name="queuePrefix"><see cref="QueuePrefixType"/></param>
public void QueuePrefix(QueuePrefixType queuePrefix = QueuePrefixType.ExchangeName)
public void QueuePrefix(QueuePrefixType queuePrefix = QueuePrefixType.ClientProvidedName)
{
Configuration.Prefix = queuePrefix;
}
Expand Down
4 changes: 3 additions & 1 deletion src/RabbitMQ.EventBus.AspNetCore/DefaultRabbitMQEventBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public void Subscribe(Type eventType, string type = ExchangeType.Topic)
{
if (attribute is EventBusAttribute attr)
{
string queue = attr.Queue ?? (_persistentConnection.Configuration.Prefix == QueuePrefixType.ExchangeName ? $"{ attr.Exchange }.{ eventType.Name }" : _persistentConnection.Configuration.ClientProvidedName);
string queue = attr.Queue ?? (_persistentConnection.Configuration.Prefix == QueuePrefixType.ExchangeName
? $"{ attr.Exchange }.{ eventType.Name }"
: $"{_persistentConnection.Configuration.ClientProvidedName}.{ eventType.Name }");//.{DateTimeOffset.Now.ToUnixTimeMilliseconds()}
if (!_persistentConnection.IsConnected)
{
_persistentConnection.TryConnect();
Expand Down
12 changes: 10 additions & 2 deletions src/RabbitMQ.EventBus.AspNetCore/Events/EventHandlerArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Text.Json;

namespace RabbitMQ.EventBus.AspNetCore.Events
Expand Down Expand Up @@ -55,7 +56,14 @@ public TEvent Event
}
catch
{
_event = (TEvent)TypeDescriptor.GetConverter(typeof(TEvent)).ConvertFromInvariantString(Original);
try
{
_event = (TEvent)TypeDescriptor.GetConverter(typeof(TEvent)).ConvertFromInvariantString(Original);
}
catch (Exception ex)
{
throw ex;
}
}
}
return _event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.0.0" />
<PackageReference Include="Polly" Version="7.1.1" />
<PackageReference Include="RabbitMQ.Client" Version="5.1.1" />
<PackageReference Include="RabbitMQ.Client" Version="5.1.2" />
<PackageReference Include="System.Text.Json" Version="4.6.0" />
</ItemGroup>

Expand Down

0 comments on commit 17c834c

Please sign in to comment.