Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nservicebus 订阅服务器无法处理来自发布服务器的消息_Nservicebus - Fatal编程技术网

Nservicebus 订阅服务器无法处理来自发布服务器的消息

Nservicebus 订阅服务器无法处理来自发布服务器的消息,nservicebus,Nservicebus,我正在ASP.NET MVC3上测试NServiceBus。目前,我能够将命令消息发送到后端,消息处理程序正在侦听它。但是当我试图发布同一条消息时,消息处理程序没有监听 我发现的问题是消息没有发布到订阅者的队列。当我调试并检查NServiceBushot控制台时,它会说 2012-01-19 22:53:35,042 [1] INFO NServiceBus.Unicast.UnicastBus [(null)] <(null )> - Subscribing to SampleM

我正在ASP.NET MVC3上测试NServiceBus。目前,我能够将命令消息发送到后端,消息处理程序正在侦听它。但是当我试图发布同一条消息时,消息处理程序没有监听

我发现的问题是消息没有发布到订阅者的队列。当我调试并检查NServiceBushot控制台时,它会说

2012-01-19 22:53:35,042 [1] INFO  NServiceBus.Unicast.UnicastBus [(null)] <(null
)> - Subscribing to SampleMessage.Person1WasCreated, SampleMessage, Version=1.0.
0.0, Culture=neutral, PublicKeyToken=null at publisher queue Test-web
ServiceHost2项目中的App.Config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    <section name="MsmqSubscriptionStorageConfig" type="NServiceBus.Config.MsmqSubscriptionStorageConfig, NServiceBus.Core" />
  </configSections>
  <MsmqSubscriptionStorageConfig Queue="Service2-AC1-subscriptionstorage" />
  <MsmqTransportConfig InputQueue="Service2-AC1" ErrorQueue="Service2-AC1-Error" NumberOfWorkerThreads="1" MaxRetries="5" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
    <add Messages="SampleMessage" Endpoint="Test-web" />
    </MessageEndpointMappings>
  </UnicastBusConfig>
  <appSettings>
    <add key="EndpointConfigurationType" value="ServiceHost2.EndpointConfig, ServiceHost2"/>
  </appSettings>
</configuration>
发布消息的控制器中的方法

public ActionResult CreatePerson(Person p)
        {
            var Person1WasCreated = new Person1WasCreated {Id = p.Id,Name = p.Name};
            Global.Bus.Publish(Person1WasCreated);
            return View();
        }

谢谢。

我想我找到了原因。我今天读了一篇关于

很明显,这条消息不应该从网络上发布。不知何故,我的web项目创建的订阅存储不允许任何东西订阅它


因此,我的解决方案是,将命令消息从web发送到Service1中的消息处理程序,并将新事件消息发布到Service2。甚至事件消息也可以订阅到Service1的订阅存储中。现在一切正常。谢谢。

我看不出任何明显的错误,您的日志输出显示您实际上正在订阅该活动。。。你确定它没有出版吗?检查您的订阅队列以查看是否存在订阅?我再次检查,但它不在那里。它显示我订阅了邮件,但订阅存储“Service2-AC1-subscriptionstorage”中没有值。很奇怪。仅供参考,im使用NServiceBus 2.6订阅服务器存储在发布服务器端(您的网站)。检查测试订阅存储队列?@AndreasÖhlund,测试订阅存储队列中没有消息。每当我启动ServiceHost2时,我都会继续看到以下消息:订阅SampleMessage.Person 1WasCreated,SampleMessage,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null在发布者队列测试web上。也就是说,消息不在队列中。My ServiceHost.exe控制台在此行停止,并且从不移动:SubscriptionMessageType:SampleMessage.Person1WasCreated,SampleMessage,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null,EnclosedMessageTypes:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    <section name="MsmqSubscriptionStorageConfig" type="NServiceBus.Config.MsmqSubscriptionStorageConfig, NServiceBus.Core" />
  </configSections>
  <MsmqSubscriptionStorageConfig Queue="Service2-AC1-subscriptionstorage" />
  <MsmqTransportConfig InputQueue="Service2-AC1" ErrorQueue="Service2-AC1-Error" NumberOfWorkerThreads="1" MaxRetries="5" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
    <add Messages="SampleMessage" Endpoint="Test-web" />
    </MessageEndpointMappings>
  </UnicastBusConfig>
  <appSettings>
    <add key="EndpointConfigurationType" value="ServiceHost2.EndpointConfig, ServiceHost2"/>
  </appSettings>
</configuration>
namespace ServiceHost2
{
    public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
    {
        public void Init()
        {
            Configure.With()
                .Log4Net()
                .CastleWindsorBuilder()
                .MsmqTransport()
                .MsmqSubscriptionStorage()
                .XmlSerializer()
                .UnicastBus().LoadMessageHandlers()
                ;
        }
    }
}
public ActionResult CreatePerson(Person p)
        {
            var Person1WasCreated = new Person1WasCreated {Id = p.Id,Name = p.Name};
            Global.Bus.Publish(Person1WasCreated);
            return View();
        }