Rebus 上是否有配置设置来清除总线启动或关闭时的队列?我需要这样做的原因是我为我的集成测试运行了两个 Rebus 实例,如果测试失败,我不希望在后续测试运行中重试失败的消息。
这是我为发送消息的集成测试客户端所拥有的。请注意,RebusHost 只是被测系统的包装器:
using Rebus.Configuration;
using Rebus.Transports.Msmq;
namespace MT.Testing.Integration
{
[TestClass]
public class IntegrationTestFixture
{
private static IMtHost _host;
[AssemblyInitialize]
public static void IntegrationTestInitialize(TestContext testContext)
{
_host = new RebusHost();
_host.Start();
}
[AssemblyCleanup]
public static void IntegrationTestCleanup()
{
_host.Stop();
}
public static IBus GetClientBus(IContainerAdapter containerAdapter)
{
return Configure.With(containerAdapter)
.Transport(t => t.UseMsmq("mt.testing.integration.client.input", "mt.testing.integration.client.error"))
.MessageOwnership(d => d.Use(new IntegrationMessageOwnership()))
.Subscriptions(s => s.StoreInMemory())
.Sagas(s => s.StoreInMemory())
.CreateBus().Start();
}
}
public class IntegrationMessageOwnership : IDetermineMessageOwnership
{
public string GetEndpointFor(Type messageType)
{
return "mt.testing.integration.input";
}
}
}