English 中文(简体)
I m 带在HyaderManager的电文中读取新字。 收到Nservice信息时的Getheer 客座
原标题:I m getting a NullReferenceException inside MessageHeaderManager.GetHeader when receiving a message with NserviceBus host

I m使用NSERBus 3,当我收到电文时,我会从接收点看到这一错误:

NServiceBus.Unicast.Transport.Transactional.TransactionalTransport [(null)] <(null)> - Failed raising  transport message received  event for message with ID=97d0f2fa-6227-439b-ad37-a304bd2af00010428
System.NullReferenceException: Object reference not set to an instance of an object.
   at NServiceBus.MessageHeaders.MessageHeaderManager.GetHeader(Object message, String key)
   at NServiceBus.MessageHeaders.Bootstrapper.<Run>b__0(Object msg, String key)
   at NServiceBus.ExtensionMethods.GetHeader(Object msg, String key)
   at NServiceBus.ExtensionMethods.GetOriginatingSiteHeader(Object msg)
   at NServiceBus.Gateway.HeaderManagement.GatewayHeaderManager.MutateIncoming(Object message)
   at NServiceBus.Unicast.UnicastBus.<>c__DisplayClass25.<ApplyIncomingMessageMutatorsTo>b__24(IMutateIncomingMessages m)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at NServiceBus.Unicast.UnicastBus.ApplyIncomingMessageMutatorsTo(IBuilder builder, Object originalMessage)
   at NServiceBus.Unicast.UnicastBus.<>c__DisplayClass22.<HandleMessage>b__21(Object msg)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at NServiceBus.Unicast.UnicastBus.HandleMessage(IBuilder builder, TransportMessage m)
   at NServiceBus.Unicast.UnicastBus.HandleTransportMessage(IBuilder childBuilder, TransportMessage msg)
   at NServiceBus.Unicast.UnicastBus.TransportMessageReceived(Object sender, TransportMessageReceivedEventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at NServiceBus.Unicast.Transport.Transactional.TransactionalTransport.OnTransportMessageReceived(TransportMessage msg)

这一信息本身就是这样:

public interface ILinkPersonMessage : IBaseMessage
{
    int PersonId { get; set; }
    List<int> UnitIds { get; set; }
}

public interface IBaseMessage
{
    int UserId { get; set; }
}

在派出一级:

var message = bus.CreateInstance<ILinkPersonMessage>();
message.UserId = currentUser.UserId;
message.PersonId = personId;
message.UnitIds = selectedUnits;

bus.Send(message);

<>Update:

I m 追随《NSERBus法典》,这是造成错误的方法:

    public string GetHeader(object message, string key)
    {
        if (message == ExtensionMethods.CurrentMessageBeingHandled)
            if (bus.CurrentMessageContext.Headers.ContainsKey(key))
                return bus.CurrentMessageContext.Headers[key];
            else
                return null;

        if (messageHeaders == null)
            return null;

        if (!messageHeaders.ContainsKey(message))
            return null;

        if (messageHeaders[message].ContainsKey(key))
            return messageHeaders[message][key];

        return null;
    }

从该守则来看,只有在以下情况下才能做到这一点:<条码>bus.CurrentMessageContext或bus.CurrentMessageContext.Headers 是无效的,或者messageHeaders[message] 存在,但含有无效价值。 不幸的是,我没有能够说明其中哪一种情况(甚至可能)更可能发生。

<<>上>

So using QueueExplorer 我把头盔推出:

<?xml version="1.0"?>
<ArrayOfHeaderInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <HeaderInfo>
        <Key>NServiceBus.Version</Key>
        <Value>3.0.3</Value>
    </HeaderInfo>
    <HeaderInfo>
        <Key>NServiceBus.TimeSent</Key>
        <Value>2012-05-08 06:57:15:691208 Z</Value>
    </HeaderInfo>
    <HeaderInfo>
        <Key>NServiceBus.EnclosedMessageTypes</Key>
        <Value>Namespace.Service.ILinkPersonMessage __impl, NServiceBus.Unicast.Transport__impl, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;Namespace.Service.ILinkPersonMessage, Namespace.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Value>
    </HeaderInfo>
    <HeaderInfo>
        <Key>WinIdName</Key>
        <Value>*{myusername}*</Value>
    </HeaderInfo>
    <HeaderInfo>
        <Key>CorrId</Key>
    </HeaderInfo>
</ArrayOfHeaderInfo>

<><>Update 3

这是目前运作的流层:

Configure.With()
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("Events"))
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("Messages"))
.CastleWindsorBuilder(container)
.XmlSerializer()
.MsmqTransport()
.IsTransactional(true)
.IsolationLevel(IsolationLevel.ReadUncommitted)
.UnicastBus()
.RavenSagaPersister()
.RavenSubscriptionStorage()
.UseRavenTimeoutPersister()
.RunTimeoutManager()
.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install();

(一) 所有名称空间

最佳回答

这是否发生在发送程序启动后的第一个信息,或只是随后的信息?

您的派遣公共汽车的配置是否不止一次? (NSERBus.Configure?)

问题回答

我们最近对头盔管理人员进行了一些轮.,这样就可以把你的工作推向上。 请尝试升级到3.0.4,看看这是否解决了你的问题。

在我身上也发生了同样的事情,那就是,在配置服务公共汽车时,放弃安装Xmlserial化。

var configBus = NServiceBus.Configure.With()
.DefaultBuilder()
.MsmqSubscriptionStorage()
.XmlSerializer() // <== This line here
.MsmqTransport()
    .IsTransactional(true)
    .PurgeOnStartup(false)
.UnicastBus()
.ImpersonateSender(true);




相关问题
synchronized message with nservicebus

I have a web service that needs to make a call to nservicebus in a synchronized manner. How can this be achieved ?

How do I correctly pool multiple message in NServiceBus?

I have an NServiceBus app which receives a particular message when a large database update is required. While this update is happening, I want to either somehow ignore all incoming messages of this ...

NServiceBus - Application as subscriber and worker service

I have a service which needs to run on multiple machines picking jobs off of a single queue ensuring each job is only undertaken by a single service. I also need to publish messages for all services ...

Server architecture question. (WCF+NServiceBus)

First of all i will describe current state: Server consists of several WCF services, hosted in one or several win services on diffirent machines. Service responsible for recieving data from ...

MSMQ Access issue in NServiceBus with asp.net web service

I am trying to implement publisher - subscribe in my project of asp.net (wcf) web services. When i am trying to create bus in global.asax protected void Application_Start(object sender, EventArgs e)...

How to configure nservicebus msmqtransport with code

I m just geting started with NServiceBus and can t figure out what I m missing when configuring the MsmqTransport in code. If I configure the publisher like this; IBus bus = Configure.With() ...

Getting the NServiceBus Distributor Sample To Work

I m trying to use the Distributor in the NServiceBus FullDuplex sample but I can t get it working. I ve been following the this guide Getting the NServiceBus Distributor Working, but it doesn t work. ...

热门标签