添加日誌(使用log4net的),我的應用程序後,當錯誤,它不再正確處理訂閱郵件,並將它們放在到錯誤隊列。下面,一些名稱空間名稱已被更改以保護無辜者。處理NServiceBus訂閱郵件
的app.config
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="MsmqSubscriptionStorageConfig" type="NServiceBus.Config.MsmqSubscriptionStorageConfig, NServiceBus.Core" />
<section name="Logging" type="NServiceBus.Config.Logging, NServiceBus.Core" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<Logging Threshold="INFO" />
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] <%X{auth}> - %m%n"/>
</layout>
</appender>
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] <%X{auth}> - %m%n"/>
</layout>
</appender>
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] <%X{auth}> - %m%n"/>
</layout>
</appender>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="logfile.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="ConsoleAppender"/>
<appender-ref ref="FileAppender"/>
</root>
</log4net>
<MsmqTransportConfig
InputQueue="BankRequestDispatcherInputQueue_DEV2"
ErrorQueue="error"
NumberOfWorkerThreads="1"
MaxRetries="5"
/>
<UnicastBusConfig ForwardReceivedMessagesTo="auditqueue">
<MessageEndpointMappings>
<add Messages="<assembly>.BankRequestBatchClosed,<assembly>" Endpoint="ScheduledBatchAgentInputQueue_DEV2" />
</MessageEndpointMappings>
</UnicastBusConfig>
<MsmqSubscriptionStorageConfig Queue="BRDispatcher_DEV2_subscriptions" />
<!-- Neccessary for Fluent/NHibernate/SQLLite dlls -->
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<appSettings>
<add key="TempRequestFileLocation" value="c:\temp\"/>
<add key="KeepRequestFiles" value="true"/>
<add key="Environment" value="TEST"/>
</appSettings>
</configuration>
我也改變了端點配置這樣:
namespace myNamespace.BRDispatcher
{
/// <summary>
/// Interface tells NServiceBus which roles to setup for this class.
/// </summary>
public class BRDEndpointConfig : IConfigureThisEndpoint, IWantCustomInitialization
{
#region Class References -1-
/// <summary>
/// Reference to Logger object.
/// </summary>
private static readonly ILog Logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
public void Init()
{
NServiceBus.SetLoggingLibrary.Log4Net(log4net.Config.XmlConfigurator.Configure);
Logger.Info("BankRequestDispatcher - Init()");
NServiceBus.Configure.With()
//.Log4Net()
.DefaultBuilder()
.XmlSerializer()
.MsmqSubscriptionStorage()
.MsmqTransport()
.IsTransactional(true)
.PurgeOnStartup(false)
.UnicastBus()
.ImpersonateSender(false)
.LoadMessageHandlers()
.CreateBus()
.Start();
Logger.Info("BankRequestDispatcher - Init() Complete");
}
}
}
當它激發起來,收到任何訂閱消息被傾倒到錯誤排隊,我看到這在日誌中:
2012-02-22 17:02:48,013 [Worker.8] ERROR NServiceBus.Unicast.Transport.Msmq.MsmqTransport [(null)] - Message has failed the maximum number of times allowed, ID=94b95c71-896f-4991-b3ba-9d2068a68c63\81504.
我沒有忘記提及我使用的是2.6版本。是否會升級到NSB 3.0? – Fellmeister 2012-02-22 22:21:41
此外,記錄在調試工作正常,我的開發計算機上,但這些DLL的發佈版本有作爲與NServiceBus.Host.Exe – Fellmeister 2012-02-22 22:46:46
服務運行應該是相當容易的試機的時候對這個問題(但預計一些破變化) – 2012-02-29 09:37:05