我没有仅使用 MQMessaging 的 HTTP 功能,因此不需要设置我的应用程序主机和侦听端口(此时)。我确实想要所有的管道,尽管默认情况下,即 IoC 等。
这可能吗?仅供参考,我现在正在使用 Topshelf 引导服务,它似乎工作正常,我只是不需要监听 HTTP 请求。
谢谢你,斯蒂芬
public class Program
{
public static void Main()
{
HostFactory.Run(x =>
{
x.Service<AppHost>(s =>
{
s.ConstructUsing(name => new AppHost());
s.WhenStarted(ah =>
{
ah.Init();
ah.Start("http://*:8088/");
"Lead message processor listening at http://localhost:8088 ".Print();
});
s.WhenStopped(ah => ah.Stop());
});
x.RunAsLocalSystem();
x.SetDescription("Processes all messages for the Leads application.");
x.SetDisplayName("Leads Message Processor");
x.SetServiceName("LOLeadsProcessor");
});
}
}
public class AppHost : AppSelfHostBase
{
public AppHost()
: base("LO.Leads.Processor", typeof(HelloService).Assembly)
{
// Logging
LogManager.LogFactory = new NLogFactory();
}
public override void Configure(Container container)
{
//RabbitMQ
container.Register<IMessageService>(c => new RabbitMqServer("cdev-9010.example.com", "test", "test")
{
AutoReconnect = true,
DisablePriorityQueues = true,
});
RabbitMqServer mqServer = (RabbitMqServer)container.Resolve<IMessageService>();
mqServer.RegisterHandler<HelloIntro>(m =>
{
return new HelloIntroResponse { Result = "Hello, {0}!".Fmt(m.GetBody().Name) };
});
mqServer.Start();
}
}