订阅者不读取事件消息

时间:2014-06-18 08:33:58

标签: c# msmq nservicebus publish-subscribe

我有一个小型服务,它建立在NServiceBus上,旨在倾听在其他地方发生的某些事件。端点配置类如下所示:

public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
    public void Init()
    {
        var container = new WindsorContainer();

        try
        {
            SetLoggingLibrary.Log4Net(() => XmlConfigurator.Configure());

            Configure.Serialization.Xml();
            Configure.Features.Enable<Sagas>();
            Configure.With()
                .CastleWindsorBuilder(container)
                .DefiningCommandsAs(t => 
                   t.GetCustomAttributes(typeof(CustomCommandAttribute), false)
                    .GetLength(0) > 0)
                .DefiningEventsAs(t => 
                   t.GetCustomAttributes(typeof(CustomEventAttribute), false)
                    .GetLength(0) > 0)
                .Log4Net()
                .UseNHibernateTimeoutPersister()
                .UseNHibernateSagaPersister()
                ;
        }
        catch (Exception ex)
        {
            throw new Exception("Configuration did not work. " + Environment.NewLine +
                                                    string.Format("Config file: {0}", AppDomain.CurrentDomain.SetupInformation.ConfigurationFile) +
                                                    Environment.NewLine +
                                                    ex.Message, ex);
        }
        //More stuff adding other non-NSB facilities into the container.
        //Pretty certain it's not relevant here, but if people think it is it can be added
    }
}

该服务包含一个处理一个事件的处理程序 - 事件类本身使用CustomEventAttribute属性进行修饰,其他订阅已构建订阅同一发布者和同一事件。一切似乎都很好。

服务启动,我可以在发布商的订阅数据库中看到一个条目:

SubscriberEndpoint                  MessageType                            Version       TypeName
----------------------------------- -------------------------------------- ------------- ---------------------------
MySubscriber@MySubscribersMachine   Namespaces.PrincipalAdded,1.1.3.37147  1.1.3.37147   Namespaces.PrincipalAdded

在此之后,发布商已发布了4条此类消息,我可以在MySubscriber上的MySubscribersMachine队列中看到4条消息。然后 - 没有任何反应。

我们的log4net配置将NServiceBus记录为DEBUG级别 - 所以我看到,例如,这个相同的服务每分钟轮询一次NSB超时 - 但我还没有看到任何有关它的信息,甚至尝试使用这些消息并调用处理程序。

此时我可以做些什么来获得更好的诊断信息?

NServiceBus版本为4.3。服务器是Windows Server 2008 R2。

1 个答案:

答案 0 :(得分:1)

显然,如果服务运行的用户帐户没有访问自己队列的权限,则不值得在日志中发送任何内容。

我们已授予帐户从队列中读取的权限,现在它已正常运行。

相关问题