nServiceBus注册订阅者但订阅者没有接收消息

时间:2011-01-16 12:46:42

标签: nservicebus

我的订阅者队列没有收到消息。看起来它们最终会出现在错误队列中。

唯一不同寻常的方面是发布者正在接收从网站(然后是类库)生成的消息,然后这些消息将被WCF发送给代表网站/类库发布的发布者。 / p>

如果我删除了发布商的<add Messages="">,那么我会收到错误消息,说明发布商不知道在哪里发送消息。

  

没有为消息指定目的地   Messages.ContactRequest。信息   无法发送。检查   您的UnicastBusConfig部分   配置文件并确保一个   MessageEndpointMapping存在于   消息类型。

帮助!我差点切断了WcfIntegration和PubSub样本,所以我不知道它为什么不起作用!

出版商:

  <MsmqTransportConfig
    InputQueue="RSApp_InputQueue"
    ErrorQueue="error"
    NumberOfWorkerThreads="1"
    MaxRetries="5"
  />

  <UnicastBusConfig
    DistributorControlAddress=""
    DistributorDataAddress=""
    ForwardReceivedMessagesTo="">
    <MessageEndpointMappings>
      <add Messages="Messages" Endpoint="RSApp_InputQueue" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

SUBSCRIBER:

  <!-- SUBSCRIBER -->
  <MsmqTransportConfig
    InputQueue="RSApp_SubscriberQueue"
    ErrorQueue="error"
    NumberOfWorkerThreads="1"
    MaxRetries="5"
  />

  <UnicastBusConfig
    DistributorControlAddress=""
    DistributorDataAddress=""
    ForwardReceivedMessagesTo="">
    <MessageEndpointMappings>
      <add Messages="Messages" Endpoint="RSApp_InputQueue" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

P.S。 nservicebus自动创建的WCF端点是否也自动bus.publish&lt;&gt;()消息?

P.S。我不明白我需要做什么: -

[的ServiceContract] 公共接口IContactRequestService {     [OperationContract(Action =“http://tempuri.org/IWcfServiceOf_ContactRequest_ErrorCodes/Process”,         ReplyAction =“http://tempuri.org/IWcfServiceOf_ContactRequest_ErrorCodes/ProcessResponse”)]     ErrorCodes Process(Messages.ContactRequest请求); }

这是我的客户端调用代码: -

public void MakeContactRequest(int id, Guid RequestingUserId, Guid RequesteeUserId, Messages.ContactRequestType type)
{
    //get extra information
    var u = Services.UserService.FetchUserProfile(id);

    //add it to local database
    var RequestIdentifier = Guid.NewGuid();

    //create message
    var req = new ContactRequest()
        {
            contactRequestType = type,
            Name = u.DisplayName,
            RequestCreationDate = DateTime.Now,
            TagLine = u.Tagline,
            RequesterUserId = RequestingUserId,
            RequesteeUserId = RequesteeUserId,
            RequestIdentifier = RequestIdentifier
        };

    //drop it onto distributed message queue
    IContactRequestService client = ChannelFactory.CreateChannel();
    try
    {
        ErrorCodes returnCode = client.Process(req);
    }
    finally
    {
        try
        {
            ((IChannel)client).Close();
        }
        catch
        {
            ((IChannel)client).Abort();
        }
    }
}

奇怪的是,在不使用WCF的情况下将消息放在总线上是一种享受!!

public void Run()
{
    Console.WriteLine("This will publish IEvent and EventMessage alternately.");
    Console.WriteLine("Press 'Enter' to publish a message.To exit, Ctrl + C");

    bool publishIEvent = true;
    while (Console.ReadLine() != null)
    {
        var eventMessage = publishIEvent ? Bus.CreateInstance<ContactRequest>() : new ContactRequest();

        Bus.Publish(eventMessage);

        Console.WriteLine("Published event ");

        publishIEvent = !publishIEvent;
    }

1 个答案:

答案 0 :(得分:0)

NSB不会为你做Publish(),你必须像任何NSB端点一样把它放在你的消息处理程序中。通过WCF公开端点不需要您执行任何操作,除了实现抽象类WcfService&lt; TRequest,TResponse&gt;。您不应该需要其他代码,因为NSB在内部处理它。从技术上讲,发布者不需要消息映射,因为它在内部管理订阅,所以我不确定你为什么会在那里收到错误。

如果消息在错误队列中,那么您应该在日志中看到异常。如果您使用Lite(默认配置文件),则许多人希望将日志记录配置为指向文件或持久的内容。

相关问题