Book Image

Mastering ServiceStack

By : Andreas Niedermair
Book Image

Mastering ServiceStack

By: Andreas Niedermair

Overview of this book

Table of Contents (13 chapters)

In Memory MQ


The most basic implementation of messaging that is shipped with ServiceStack is a solution, which runs in the same process and memory, as shown in the following figure:

This queue offers you a simple in-process messaging with all the downsides that come with the linking of the process. For example, the messages will not survive an application restart as there's no storage implemented for the queue.

The factory, client, and server are located in the main ServiceStack NuGet package (ServiceStack.Messaging), as shown here:

using ServiceStack;
var inMemoryTransientMessageFactory = new ServiceStack.Messaging.InMemoryTransientMessageFactory();
var messageService = inMemoryTransientMessageFactory.CreateMessageService();

messageService.RegisterHandler<Hello>(message =>
{
  var hello = message.GetBody();
  var name = hello.Name;
  var helloResponse = new HelloResponse
                      {
                        Result = "Hello {0}".Fmt(name)
                      };
  return...