Last active
August 4, 2024 03:27
-
-
Save gistlyn/aa22fae27f9e9f860d405ad153ad4448 to your computer and use it in GitHub Desktop.
Use Memory Background MQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using ServiceStack; | |
using ServiceStack.Messaging; | |
[assembly: HostingStartup(typeof(MyApp.ConfigureMq))] | |
namespace MyApp; | |
/** | |
Register Services you want available via MQ in your AppHost, e.g: | |
var mqServer = appHost.Resolve<IMessageService>(); | |
mqServer.RegisterHandler<MyRequest>(ExecuteMessage); | |
*/ | |
public class ConfigureMq : IHostingStartup | |
{ | |
public void Configure(IWebHostBuilder builder) => builder | |
.ConfigureServices(services => { | |
services.AddSingleton<IMessageService>(c => new BackgroundMqService()); | |
}) | |
.ConfigureAppHost(afterAppHostInit: appHost => { | |
appHost.Resolve<IMessageService>().Start(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment