-
Notifications
You must be signed in to change notification settings - Fork 56
ASP.NET hosted ServiceStack Service (RabbitMQ callable)
Sunny Ahuwanya edited this page Jan 24, 2016
·
8 revisions
To create a RabbitMQ callable ServiceStack service hosted on IIS (ASP.NET Webforms, MVC, etc.)
-
Follow the instructions at Create your first (ServiceStack) webservice and Run servicestack side by side with another web framework to create the ServiceStack service.
-
Install the RestBus.RabbitMQ and RestBus.ServiceStack NuGet packages.
PM> Install-Package RestBus.RabbitMQ
PM> Install-Package RestBus.ServiceStack
- Add code in the
Application_Start
method of the Global.asax file that starts the RestBus host.
RestBusHost restbusHost = null; //Make this a field in the class
var amqpUrl = "amqp://localhost:5672"; //AMQP URI for RabbitMQ server
var serviceName = "samba"; //Uniquely identifies this service
var msgMapper = new BasicMessageMapper(amqpUrl, serviceName);
var subscriber = new RestBusSubscriber(msgMapper);
restbusHost = new RestBusHost(subscriber);
restbusHost.Start();
- Add code in the
Application_End
method of the Global.asax file that stops the RestBus host.
if (restbusHost != null)
restbusHost.Stop();
Complete ASP.NET Webforms and ASP.NET MVC 4 examples are available in the RestBus.Examples repo.
To call this service from a client, see Calling a Service Endpoint