ServiceStack: how to make InMemoryTransientMessageService running in the background

What needs to be done to get InMemoryTransientMessageService to work in the background thread? I publish things inside the service using

base.MessageProducer.Publish(new RequestDto()); 

and they are executed directly in the service request.

The project itself.

Here is a quick unit test showing the blocking of the current request instead of deferring it to the background:

+4
source share
1 answer

There is nothing out of the box. You will have to build your own. Take a look at ServiceStack.Redis.Messaging.RedisMqHost - most of what you need is there and it's probably easier (one thread does everything) so you go compared to ServiceStack.Redis.Messaging.RedisMqServer (one thread for listening in line, one for each worker). I suggest you take this class and adapt it to your needs.

A few pointers:

  • ServiceStack.Message.InMemoryMessageQueueClient does not implement WaitForNotifyOnAny() , so you will need an alternative way to make the background thread wait for incoming messages.
  • The closely related implementation of ServiceStack.Redis uses topic subscriptions, which in this class are used to port WorkerStatus.StopCommand , which means you need to find an alternative way to stop the background thread.
  • Finally, you can adapt ServiceStack.Redis.Messaging.RedisMessageProducer , because its Publish() method calls the message requested in the queue and pushes the channel / queue name to the TopicIn queue. After reading the code, you can see how the three points are related to each other.

Hope this helps ...

+1
source

All Articles