RedisMqServer
Creates a Redis MQ Server that processes each message on its own background thread. i.e. if you register 3 handlers it will create 7 background threads:
- 1 listening to the Redis MQ Subscription, getting notified of each new message
- 3x1 Normal InQ for each message handler
- 3x1 PriorityQ for each message handler (Turn off with DisablePriorityQueues)
When RedisMqServer Starts it creates a background thread subscribed to the Redis MQ Topic that listens for new incoming messages. It also starts 2 background threads for each message type:
- 1 for processing the services Priority Queue and 1 processing the services normal Inbox Queue.
Priority Queue's can be enabled on a message-per-message basis by specifying types in the OnlyEnablePriorityQueuesForTypes property. The DisableAllPriorityQueues property disables all Queues.
The Start/Stop methods are idempotent i.e. It's safe to call them repeatedly on multiple threads and the Redis MQ Server will only have Started or Stopped once.
Assembly: ServiceStack.Server.dll
View Source
public class RedisMqServer : object, IMessageService
Properties
RetryCount
View Source
public int RetryCount { get; set; }
WaitBeforeNextRestart
View Source
public TimeSpan? WaitBeforeNextRestart { get; set; }
MessageFactory
View Source
public IMessageFactory MessageFactory { get; }
ReplyClientFactory
View Source
public Func<string, IOneWayClient> ReplyClientFactory { get; set; }
RequestFilter
Execute global transformation or custom logic before a request is processed. Must be thread-safe.
View Source
public Func<IMessage, IMessage> RequestFilter { get; set; }
ResponseFilter
Execute global transformation or custom logic on the response. Must be thread-safe.
View Source
public Func<object, object> ResponseFilter { get; set; }
ErrorHandler
Execute global error handler logic. Must be thread-safe.
View Source
public Action<Exception> ErrorHandler { get; set; }
PriorityQueuesWhitelist
If you only want to enable priority queue handlers (and threads) for specific msg types
View Source
public string[] PriorityQueuesWhitelist { get; set; }
DisablePriorityQueues
Don't listen on any Priority Queues
View Source
public bool DisablePriorityQueues { set; }
RedisPubSub
View Source
public IRedisPubSubServer RedisPubSub { get; set; }
ClientsManager
View Source
public IRedisClientsManager ClientsManager { get; }
PublishResponsesWhitelist
Opt-in to only publish responses on this white list. Publishes all responses by default.
View Source
public string[] PublishResponsesWhitelist { get; set; }
DisablePublishingResponses
Don't publish any response messages
View Source
public bool DisablePublishingResponses { set; }
PublishToOutqWhitelist
Opt-in to only publish .outq messages on this white list. Publishes all responses by default.
View Source
public string[] PublishToOutqWhitelist { get; set; }
DisablePublishingToOutq
Don't publish any messages to .outq
View Source
public bool DisablePublishingToOutq { set; }
RegisteredTypes
View Source
public List<Type> RegisteredTypes { get; }
CaptureEvents
View Source
public bool CaptureEvents { get; set; }
Fields
DefaultRetryCount
View Source
public const int DefaultRetryCount = null
Methods
CreateMessageQueueClient()
View Source
public IMessageQueueClient CreateMessageQueueClient()
Returns
ServiceStack.Messaging.IMessageQueueClient
GetCapturedEvents()
View Source
public string GetCapturedEvents()
Returns
System.String
RegisterHandler<T>(Func<IMessage<T>, Object>)
View Source
public void RegisterHandler<T>(Func<IMessage<T>, object> processMessageFn)
Parameters
Type | Name |
---|---|
Func<ServiceStack.Messaging.IMessage<<T>>,System.Object> | processMessageFn |
Type Parameters
T
RegisterHandler<T>(Func<IMessage<T>, Object>, Int32)
View Source
public void RegisterHandler<T>(Func<IMessage<T>, object> processMessageFn, int noOfThreads)
Parameters
Type | Name |
---|---|
Func<ServiceStack.Messaging.IMessage<<T>>,System.Object> | processMessageFn |
System.Int32 | noOfThreads |
Type Parameters
T
RegisterHandler<T>(Func<IMessage<T>, Object>, Action<IMessageHandler, IMessage<T>, Exception>)
View Source
public void RegisterHandler<T>(Func<IMessage<T>, object> processMessageFn, Action<IMessageHandler, IMessage<T>, Exception> processExceptionEx)
Parameters
Type | Name |
---|---|
Func<ServiceStack.Messaging.IMessage<<T>>,System.Object> | processMessageFn |
Action<ServiceStack.Messaging.IMessageHandler,ServiceStack.Messaging.IMessage<<T>>,Exception> | processExceptionEx |
Type Parameters
T
RegisterHandler<T>(Func<IMessage<T>, Object>, Action<IMessageHandler, IMessage<T>, Exception>, Int32)
View Source
public void RegisterHandler<T>(Func<IMessage<T>, object> processMessageFn, Action<IMessageHandler, IMessage<T>, Exception> processExceptionEx, int noOfThreads)
Parameters
Type | Name |
---|---|
Func<ServiceStack.Messaging.IMessage<<T>>,System.Object> | processMessageFn |
Action<ServiceStack.Messaging.IMessageHandler,ServiceStack.Messaging.IMessage<<T>>,Exception> | processExceptionEx |
System.Int32 | noOfThreads |
Type Parameters
T
CreateMessageHandlerFactory<T>(Func<IMessage<T>, Object>, Action<IMessageHandler, IMessage<T>, Exception>)
View Source
protected IMessageHandlerFactory CreateMessageHandlerFactory<T>(Func<IMessage<T>, object> processMessageFn, Action<IMessageHandler, IMessage<T>, Exception> processExceptionEx)
Returns
ServiceStack.Messaging.IMessageHandlerFactory
Parameters
Type | Name |
---|---|
Func<ServiceStack.Messaging.IMessage<<T>>,System.Object> | processMessageFn |
Action<ServiceStack.Messaging.IMessageHandler,ServiceStack.Messaging.IMessage<<T>>,Exception> | processExceptionEx |
Type Parameters
T
OnError(Exception)
View Source
public void OnError(Exception ex)
Parameters
Type | Name |
---|---|
Exception | ex |
OnEvent(String)
View Source
public void OnEvent(string message)
Parameters
Type | Name |
---|---|
System.String | message |
OnStart()
View Source
public void OnStart()
OnStop()
View Source
public void OnStop()
OnInit()
View Source
public void OnInit()
OnMessage(String, String)
View Source
public void OnMessage(string channel, string msg)
Parameters
Type | Name |
---|---|
System.String | channel |
System.String | msg |
Start()
View Source
public void Start()
Stop()
View Source
public void Stop()
Restart()
View Source
public void Restart()
NotifyAll()
View Source
public void NotifyAll()
StartWorkerThreads()
View Source
public void StartWorkerThreads()
ForceRestartWorkerThreads()
View Source
public void ForceRestartWorkerThreads()
StopWorkerThreads()
View Source
public void StopWorkerThreads()
GetStats()
View Source
public IMessageHandlerStats GetStats()
Returns
ServiceStack.Messaging.IMessageHandlerStats
GetStatus()
View Source
public string GetStatus()
Returns
System.String
GetStatsDescription()
View Source
public string GetStatsDescription()
Returns
System.String
Dispose()
View Source
public virtual void Dispose()
WorkerThreadsStatus()
View Source
public List<string> WorkerThreadsStatus()
Returns
List<System.String>
ExpireTemporaryQueues(Int32)
View Source
public long ExpireTemporaryQueues(int afterMs = null)
Returns
System.Int64
Parameters
Type | Name |
---|---|
System.Int32 | afterMs |
Implements
- ServiceStack.Messaging.IMessageService
IDisposable