2
我的Web程序發送命令到域,並處理事件(通過SIgnalR推到瀏覽器)。它是在IIS快遞/ Win7的X64的Web應用程序訂閱事件,但不處理它們
在隨機運行ASP.NET MVC3和.NET 4,有時從一開始就正確的,它決定停止分發事件處理我。這些事件位於Web端點的日記隊列中,但沒有其他跟蹤。他們從日誌完全,我在處理程序斷點從不打缺,並且兩個端點和錯誤隊列爲空。
Func<Type, bool> isMessage = t => typeof(IMessage).IsAssignableFrom(t);
Func<Type, bool> isCommand = t => typeof(ICommand).IsAssignableFrom(t);
Func<Type, bool> isEvent = t => typeof(IEvent).IsAssignableFrom(t);
Configure.WithWeb()
.NinjectBuilder(Kernel)
.DefineEndpointName("Hospital.Web")
.DefiningMessagesAs(isMessage)
.DefiningCommandsAs(isCommand)
.DefiningEventsAs(isEvent)
.Log4Net()
.JsonSerializer()
.MsmqTransport()
.UnicastBus()
.LoadMessageHandlers()
.PurgeOnStartup(true)
.CreateBus()
.Start();
這裏是我的web.config的NSB部分:
<MsmqTransportConfig ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Hospital.Commands" Endpoint="Hospital.CommandHandlers" />
<add Messages="Hospital.Events" Endpoint="Hospital.CommandHandlers" />
</MessageEndpointMappings>
</UnicastBusConfig>
這裏是我的處理程序之一:
public class StatsHandler :
IHandleMessages<PatientAdmitted>,
IHandleMessages<BedAssigned>,
IHandleMessages<PatientDischarged>
{
private static readonly ILog Log = LogManager.GetLogger(typeof (StatsHandler));
private readonly IConnectionManager _connectionManager;
public StatsHandler(IConnectionManager connectionManager)
{
_connectionManager = connectionManager;
}
protected dynamic Clients
{
get { return _connectionManager.GetClients<StatsHub>(); }
}
public void Handle(PatientAdmitted message)
{
Log.DebugFormat("Admitted {0} {1}", message.FirstName, message.LastName);
Clients.patientAdmitted();
}
public void Handle(BedAssigned message)
{
Log.DebugFormat("Assigned {0} to {1}", message.PatientId, message.Bed);
Clients.bedAssigned();
}
public void Handle(PatientDischarged message)
{
Log.DebugFormat("Discharged {0}", message.PatientId);
Clients.patientDischarged();
}
}
我也asked this question in the NServiceBus group。該消息附有一個日誌文件。
感謝安德烈亞斯。我今晚會試一試。 – 2012-02-22 15:04:23
修復了它。謝謝! – 2012-02-23 15:35:41