|
|
@@ -2,7 +2,9 @@ |
|
|
|
// Licensed under the MIT License. See License.txt in the project root for license information. |
|
|
|
|
|
|
|
using DotNetCore.CAP.Transport; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Pulsar.Client.Api; |
|
|
|
|
|
|
|
namespace DotNetCore.CAP.Pulsar |
|
|
|
{ |
|
|
@@ -11,10 +13,15 @@ namespace DotNetCore.CAP.Pulsar |
|
|
|
private readonly IConnectionFactory _connection; |
|
|
|
private readonly IOptions<PulsarOptions> _pulsarOptions; |
|
|
|
|
|
|
|
public PulsarConsumerClientFactory(IConnectionFactory connection, IOptions<PulsarOptions> pulsarOptions) |
|
|
|
public PulsarConsumerClientFactory(IConnectionFactory connection, ILoggerFactory loggerFactory, IOptions<PulsarOptions> pulsarOptions) |
|
|
|
{ |
|
|
|
_connection = connection; |
|
|
|
_pulsarOptions = pulsarOptions; |
|
|
|
|
|
|
|
if (_pulsarOptions.Value.EnableClientLog) |
|
|
|
{ |
|
|
|
PulsarClient.Logger = loggerFactory.CreateLogger<PulsarClient>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public IConsumerClient Create(string groupId) |
|
|
@@ -22,7 +29,7 @@ namespace DotNetCore.CAP.Pulsar |
|
|
|
try |
|
|
|
{ |
|
|
|
var client = _connection.RentClient(); |
|
|
|
var consumerClient = new PulsarConsumerClient(client,groupId, _pulsarOptions); |
|
|
|
var consumerClient = new PulsarConsumerClient(client, groupId, _pulsarOptions); |
|
|
|
return consumerClient; |
|
|
|
} |
|
|
|
catch (System.Exception e) |
|
|
|