在我的应用程序中添加日志记录(使用log4net)之后,它不再正确处理订阅消息并将它们放到错误队列中。下面,一些命名空间名称已被更改以保护无辜者。
的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.
答案 0 :(得分:1)
这是由于RC4中的错误,请尝试使用
RC5,看看是否能解决问题。
答案 1 :(得分:0)
我找到了错误/问题的一个原因。如果在app.config(ForwardReceivedMessagesTo)中指定了消息转发队列,但主机上不存在该队列,那么您将收到相同的错误。
<强>的app.config 强>
<UnicastBusConfig ForwardReceivedMessagesTo="auditqueue">
<MessageEndpointMappings>
<add Messages="<assembly>.BankRequestBatchClosed,<assembly>" Endpoint="ScheduledBatchAgentInputQueue_DEV2" />
</MessageEndpointMappings>
问题是由于我运行的六个进程中只有一个进程在Test环境中命名为缺少的队列。五个被设置为'auditqueue',一个是'auditqueue_test2',遗憾的是它是正确的名称,除了它不存在并且它不会在这个实例中自动创建队列,也没有在DEBUG语句中做出任何评论,这是问题
我创建了一个名为'auditqueue_test2'的新事务队列,它现在正在运行。我将再次添加日志记录,看看它是否有效。