Skip to content
Permalink
Browse files

Add MqQueueClientFilter/MqProducerFilter

  • Loading branch information...
mythz committed May 14, 2019
1 parent 725c872 commit 529255f8fe6aefc764754ec11923d70dc80b6171
Showing with 23 additions and 4 deletions.
  1. +10 −2 src/ServiceStack.RabbitMq/RabbitMqMessageFactory.cs
  2. +13 −2 src/ServiceStack.RabbitMq/RabbitMqServer.cs
@@ -7,6 +7,10 @@ namespace ServiceStack.RabbitMq
public class RabbitMqMessageFactory : IMessageFactory
{
public ConnectionFactory ConnectionFactory { get; private set; }

public Action<RabbitMqQueueClient> MqQueueClientFilter { get; set; }
public Action<RabbitMqProducer> MqProducerFilter { get; set; }

public Action<string, IBasicProperties, IMessage> PublishMessageFilter { get; set; }
public Action<string, BasicGetResult> GetMessageFilter { get; set; }

@@ -65,20 +69,24 @@ public RabbitMqMessageFactory(ConnectionFactory connectionFactory)

public virtual IMessageQueueClient CreateMessageQueueClient()
{
return new RabbitMqQueueClient(this) {
var client = new RabbitMqQueueClient(this) {
RetryCount = RetryCount,
PublishMessageFilter = PublishMessageFilter,
GetMessageFilter = GetMessageFilter,
};
MqQueueClientFilter?.Invoke(client);
return client;
}

public virtual IMessageProducer CreateMessageProducer()
{
return new RabbitMqProducer(this) {
var client = new RabbitMqProducer(this) {
RetryCount = RetryCount,
PublishMessageFilter = PublishMessageFilter,
GetMessageFilter = GetMessageFilter,
};
MqProducerFilter?.Invoke(client);
return client;
}

public virtual void Dispose()
@@ -55,6 +55,18 @@ public bool UsePolling
private RabbitMqMessageFactory messageFactory;
public IMessageFactory MessageFactory => messageFactory;

public Action<RabbitMqQueueClient> MqQueueClientFilter
{
get => messageFactory.MqQueueClientFilter;
set => messageFactory.MqQueueClientFilter = value;
}

public Action<RabbitMqProducer> MqProducerFilter
{
get => messageFactory.MqProducerFilter;
set => messageFactory.MqProducerFilter = value;
}

public Action<string, IBasicProperties, IMessage> PublishMessageFilter
{
get => messageFactory.PublishMessageFilter;
@@ -304,8 +316,7 @@ public virtual void Init()
{
var worker = workers[i];

int[] workerIds;
if (!queueWorkerIndexMap.TryGetValue(worker.QueueName, out workerIds))
if (!queueWorkerIndexMap.TryGetValue(worker.QueueName, out var workerIds))
{
queueWorkerIndexMap[worker.QueueName] = new[] { i };
}

0 comments on commit 529255f

Please sign in to comment.
You can’t perform that action at this time.