在发送 Web 应用程序中,NServiceBus 正在扫描并将每种类型分配给端点。这大约需要三分钟,然后超时交易。我尝试过 configure.with(assemblies) 来限制扫描程序集,并且我尝试过“约定优于配置”不显眼的 configure.definingas 方法来限制消息实现。我们正在从旧版本迁移到最新版本,因此我们仍在使用 IMessage 实现约定。
这是我在发件人中的 bus.start 代码
我正在研究烟雾……我非常感谢一些帮助。
//hack for the moment
string dir = System.Web.HttpContext.Current.Server.MapPath("/");
dir = Path.Combine(dir, "bin");
TraceDirect("Shared", System.Diagnostics.TraceEventType.Information, dir);
System.Reflection.Assembly[] asss = { System.Reflection.Assembly.LoadFile(Path.Combine(dir, "myfirst.dll")), System.Reflection.Assembly.LoadFile(Path.Combine(dir, "mysecond.dll")) };
try
{
using (TransactionScope ambient = new TransactionScope( TransactionScopeOption.Suppress))
{
theMagicBus = NServiceBus.Configure.With(asss)
.DefineEndpointName("app")
.DefiningMessagesAs(t => typeof(IMessage).IsAssignableFrom(t))
.DefiningCommandsAs(t => typeof(ICommand).IsAssignableFrom(t))
.DefiningEventsAs(t => typeof(IEvent).IsAssignableFrom(t))
.DefaultBuilder()
.XmlSerializer()
.MsmqTransport().TransactionTimeout(TimeSpan.FromMinutes(5))
.IsTransactional(true)
.PurgeOnStartup(false)
.UnicastBus()
.ImpersonateSender(false)
.Log4Net<NServiceBusAppender>(a => { a.Name = "Shared"; })
.CreateBus()
.Start(() => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());}}
这是我的配置
<MsmqTransportConfig NumberOfWorkerThreads="1" MaxRetries="5" />
<MessageForwardingInCaseOfFaultConfig ErrorQueue="error"/>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="myfirst" Endpoint="endpoint"/>
<add Messages="mysecond" Endpoint="msgsvcpubinputqueue"/>
</MessageEndpointMappings>
</UnicastBusConfig>
</MsmqTransportConfig>