Skip to content

Commit 45f762d

Browse files
committed
improve worker mq getting started docs
1 parent 983e11d commit 45f762d

File tree

9 files changed

+112
-12
lines changed

9 files changed

+112
-12
lines changed

MyApp/_pages/amazon-sqs-mq.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ slug: amazon-sqs-mq
33
title: Amazon SQS MQ
44
---
55

6+
## Enable in an existing Web App
7+
8+
Use the `sqs` mixin to register an [MQ Server](/messaging) for Amazon SQS with an existing .NET App:
9+
10+
:::sh
11+
x mix sqs
12+
:::
13+
14+
## Worker Service Template
15+
16+
To start using Amazon SQS in stand-alone MQ Servers (i.e. without HTTP access) is to run the MQ Server in an ASP.NET Core Worker Service by starting from a pre-configured project template:
17+
18+
<worker-templates template="worker-sqs"></worker-templates>
19+
20+
## Manual Configuration
21+
622
Support for registering Amazon Simple Queue Service (SQS) as an [MQ Server](/messaging) is available in [ServiceStack.Aws](https://www.nuget.org/packages/ServiceStack.Aws) NuGet package:
723

824
:::copy

MyApp/_pages/azure-service-bus-mq.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
---
2-
slug: azure-service-bus-mq
32
title: Azure Service Bus MQ
43
---
54

5+
## Enable in an existing Web App
6+
7+
Use the `servicebus` mixin to register an [MQ Server](/messaging) for Azure Service Bus with an existing .NET App:
8+
9+
:::sh
10+
x mix servicebus
11+
:::
12+
13+
## Worker Service Template
14+
15+
To start using Azure Service Bus in stand-alone MQ Servers (i.e. without HTTP access) is to run the MQ Server in an ASP.NET Core Worker Service by starting from a pre-configured project template:
16+
17+
<worker-templates template="worker-servicebus"></worker-templates>
18+
19+
## Manual Configuration
20+
621
Support for registering Azure Service Bus as an [MQ Server](/messaging) in ServiceStack is available in [ServiceStack.Azure](https://www.nuget.org/packages/ServiceStack.Azure) NuGet package:
722

823
:::copy
@@ -12,10 +27,22 @@ Support for registering Azure Service Bus as an [MQ Server](/messaging) in Servi
1227
Once installed ServiceBus can be configured the same way as any other [MQ Servers](/messaging), by first registering the ServiceBus `IMessageService` provider followed by registering all ServiceStack Services you want to be able to invoke via MQ’s:
1328

1429
```csharp
15-
container.Register<IMessageService>(c => new ServiceBusMqServer(ConnectionString));
30+
[assembly: HostingStartup(typeof(MyApp.ConfigureMq))]
1631

17-
var mqServer = container.Resolve<IMessageService>();
18-
mqServer.RegisterHandler<MyRequest>(ExecuteMessage);
32+
namespace MyApp;
1933

20-
AfterInitCallbacks.Add(appHost => mqServer.Start());
34+
public class ConfigureMq : IHostingStartup
35+
{
36+
public void Configure(IWebHostBuilder builder) => builder
37+
.ConfigureServices((context, services) => {
38+
services.AddSingleton<IMessageService>(c =>
39+
new ServiceBusMqServer(context.Configuration.GetConnectionString("ServiceBus")));
40+
})
41+
.ConfigureAppHost(afterAppHostInit: appHost => {
42+
var mqServer = appHost.Resolve<IMessageService>().Start();
43+
// Register MQ endpoints for APIs
44+
mqServer.RegisterHandler<MyRequest>(ExecuteMessage);
45+
mqServer.Start();
46+
});
47+
}
2148
```

MyApp/_pages/rabbit-mq.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
---
2-
slug: rabbit-mq
32
title: Rabbit MQ
43
---
54

5+
## Enable in an existing Web App
6+
7+
Use the `rabbitmq` mixin to register an [MQ Server](/messaging) for Amazon SQS with an existing .NET App:
8+
9+
:::sh
10+
x mix rabbitmq
11+
:::
12+
13+
## Worker Service Template
14+
15+
To start usingRabbit MQ in stand-alone MQ Servers (i.e. without HTTP access) is to run the MQ Server in an ASP.NET Core Worker Service by starting from a pre-configured project template:
16+
17+
<worker-templates template="worker-rabbitmq"></worker-templates>
18+
19+
## ServiceStack.RabbitMq
20+
621
A nice advantage of ServiceStack's message-based design is its ability to host its Services on a variety of different endpoints. This design makes it possible to host Services via [MQ Servers](/messaging), enable [SOAP support](/soap-support) in addition to ServiceStack's strong HTTP Web Services story. One MQ Server we support is the extremely popular and robust Open Source AMQP messaging broker: [Rabbit MQ](http://www.rabbitmq.com).
722

823
## Getting Started
@@ -11,8 +26,6 @@ A great way to get started with Rabbit MQ on Windows is by following the
1126
[Rabbit MQ Windows Installation guide](https://github.com/mythz/rabbitmq-windows)
1227
which also includes sample source code for accessing Rabbit MQ Server using the .NET [RabbitMQ.Client](https://www.nuget.org/packages/RabbitMQ.Client) on NuGet.
1328

14-
## ServiceStack.RabbitMq
15-
1629
ServiceStack builds on top of **RabbitMQ.Client** to provide concrete implementations for
1730
[ServiceStack's high-level Messaging APIs](https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Interfaces/Messaging/)
1831
enabling a number of messaging features including publishing and receiving messages as well as registering and processing message handlers. Like other ServiceStack providers, all MQ Servers are interchangeable, visible in the shared common [MqServerIntroTests.cs](https://github.com/ServiceStack/ServiceStack/blob/master/tests/ServiceStack.Server.Tests/Messaging/MqServerIntroTests.cs) and [MqServerAppHostTests.cs](https://github.com/ServiceStack/ServiceStack/blob/master/tests/ServiceStack.Common.Tests/Messaging/MqServerAppHostTests.cs).

MyApp/_pages/redis-mq.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ slug: redis-mq
33
title: Redis MQ
44
---
55

6+
## Enable in an existing Web App
7+
8+
Use the `redismq` mixin to register an [MQ Server](/messaging) for Amazon SQS with an existing .NET App:
9+
10+
:::sh
11+
x mix redismq
12+
:::
13+
14+
## Worker Service Template
15+
16+
To start using Redis MQ in stand-alone MQ Servers (i.e. without HTTP access) is to run the MQ Server in an ASP.NET Core Worker Service by starting from a pre-configured project template:
17+
18+
<worker-templates template="worker-redismq"></worker-templates>
19+
620
## MQ Examples
721

822
The [Reusability ServiceStack.UseCase](https://github.com/ServiceStack/ServiceStack.UseCases/tree/master/Reusability) contains a good introductory demo of using MQ's(message-queues) in ServiceStack where the same services can be called via Web Service or via MQ. Using MQ's provide instant response times, in addition to reliable and durable execution of your services.

MyApp/wwwroot/pages/amazon-sqs-mq.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import WorkerTemplates from "./templates/WorkerTemplates.mjs"
2+
3+
export default {
4+
components: {
5+
WorkerTemplates,
6+
},
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import WorkerTemplates from "./templates/WorkerTemplates.mjs"
2+
3+
export default {
4+
components: {
5+
WorkerTemplates,
6+
},
7+
}

MyApp/wwwroot/pages/rabbit-mq.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import WorkerTemplates from "./templates/WorkerTemplates.mjs"
2+
3+
export default {
4+
components: {
5+
WorkerTemplates,
6+
},
7+
}

MyApp/wwwroot/pages/redis-mq.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import WorkerTemplates from "./templates/WorkerTemplates.mjs"
2+
3+
export default {
4+
components: {
5+
WorkerTemplates,
6+
},
7+
}

MyApp/wwwroot/pages/templates/WorkerTemplates.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ref, computed } from "vue"
2+
import { template } from "./Templates.mjs"
23

34
export default {
45
template: `<section class="not-prose w-full flex flex-col justify-center text-center">
@@ -12,7 +13,7 @@ export default {
1213
<section class="w-full flex flex-col justify-center text-center">
1314
<div class="mt-4 mb-2">
1415
<div class="flex flex-wrap justify-center">
15-
<div>
16+
<div v-if="!template || template == 'worker-rabbitmq'">
1617
<a class="hover:no-underline" :href="zipUrl('NetCoreTemplates/worker-rabbitmq')">
1718
<div class="bg-white dark:bg-gray-800 px-4 py-4 mr-4 mb-4 rounded-lg shadow-lg text-center items-center justify-center hover:shadow-2xl dark:border-2 dark:border-pink-600 dark:hover:border-blue-600" style="min-width:150px">
1819
<div class="text-center font-extrabold flex items-center justify-center mb-2">
@@ -34,7 +35,7 @@ export default {
3435
</div>
3536
</a>
3637
</div>
37-
<div>
38+
<div v-if="!template || template == 'worker-redismq'">
3839
<a class="hover:no-underline" :href="zipUrl('NetCoreTemplates/worker-redismq')">
3940
<div class="bg-white dark:bg-gray-800 px-4 py-4 mr-4 mb-4 rounded-lg shadow-lg text-center items-center justify-center hover:shadow-2xl dark:border-2 dark:border-pink-600 dark:hover:border-blue-600" style="min-width:150px">
4041
<div class="text-center font-extrabold flex items-center justify-center mb-2">
@@ -56,7 +57,7 @@ export default {
5657
</div>
5758
</a>
5859
</div>
59-
<div>
60+
<div v-if="!template || template == 'worker-servicebus'">
6061
<a class="hover:no-underline" :href="zipUrl('NetCoreTemplates/worker-servicebus')">
6162
<div class="bg-white dark:bg-gray-800 px-4 py-4 mr-4 mb-4 rounded-lg shadow-lg text-center items-center justify-center hover:shadow-2xl dark:border-2 dark:border-pink-600 dark:hover:border-blue-600" style="min-width:150px">
6263
<div class="text-center font-extrabold flex items-center justify-center mb-2">
@@ -78,7 +79,7 @@ export default {
7879
</div>
7980
</a>
8081
</div>
81-
<div>
82+
<div v-if="!template || template == 'worker-sqs'">
8283
<a class="hover:no-underline" :href="zipUrl('NetCoreTemplates/worker-sqs')">
8384
<div class="bg-white dark:bg-gray-800 px-4 py-4 mr-4 mb-4 rounded-lg shadow-lg text-center items-center justify-center hover:shadow-2xl dark:border-2 dark:border-pink-600 dark:hover:border-blue-600" style="min-width:150px">
8485
<div class="text-center font-extrabold flex items-center justify-center mb-2">
@@ -104,6 +105,7 @@ export default {
104105
</div>
105106
</section>
106107
</section>`,
108+
props: { template: String },
107109
setup(props) {
108110
const project = ref('MyApp')
109111
const projectZip = computed(() => (project.value || 'MyApp') + '.zip')

0 commit comments

Comments
 (0)