当前位置: 首页>>代码示例>>C#>>正文


C# TransportMessage.IsControlMessage方法代码示例

本文整理汇总了C#中NServiceBus.Unicast.Transport.TransportMessage.IsControlMessage方法的典型用法代码示例。如果您正苦于以下问题:C# TransportMessage.IsControlMessage方法的具体用法?C# TransportMessage.IsControlMessage怎么用?C# TransportMessage.IsControlMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NServiceBus.Unicast.Transport.TransportMessage的用法示例。


在下文中一共展示了TransportMessage.IsControlMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToEventData

        private static EventData ToEventData(TransportMessage transportMessage, EventStoreMessageMetadata metadata)
        {
            metadata.CorrelationId = transportMessage.CorrelationId;
            metadata.MessageId = transportMessage.Id;
            metadata.ReplyTo = transportMessage.ReplyToAddress.ToString();
            metadata.Headers = transportMessage.Headers;
            var type = transportMessage.IsControlMessage() 
                              ? "ControlMessage" 
                              : transportMessage.Headers[Headers.EnclosedMessageTypes];

            byte[] data;
            string contentType;
            if (transportMessage.Headers.TryGetValue(Headers.ContentType, out contentType))
            {
                if (contentType != ContentTypes.Json)
                {
                    throw new InvalidOperationException("Invalid content type: "+contentType);
                }
                data = transportMessage.Body;
            }
            else
            {
                data = new byte[0];
            }
            return new EventData(Guid.NewGuid(), type, true, data, metadata.ToJsonBytes());
        }
开发者ID:eric-swann-q2,项目名称:NServiceBus.EventStore,代码行数:26,代码来源:TransportMessageConverter.cs

示例2: Encode

        public IMessage Encode(TransportMessage message, ISession session)
        {
            if (message.IsControlMessage())
            {
                IMessage encoded = session.CreateBytesMessage();

                if (message.Body != null)
                {
                    encoded = session.CreateBytesMessage(message.Body);
                }

                return encoded;
            }

            return null;
        }
开发者ID:afyles,项目名称:NServiceBus,代码行数:16,代码来源:ControlMessageEncoder.cs

示例3: MutateOutgoing

        /// <summary>
        /// Allow for a V3.X subscriber to subscribe/unsubscribe to a V2.6 publisher
        /// Mutate outgoing subscribe/unsubscribe messages: Create and serialize a completion message into the 
        /// body of the transport message.
        /// </summary>
        /// <param name="messages"></param>
        /// <param name="transportMessage"></param>
        public void MutateOutgoing(object[] messages, TransportMessage transportMessage)
        {
            if ((transportMessage.IsControlMessage() &&
                ((transportMessage.MessageIntent == MessageIntentEnum.Subscribe) ||
                (transportMessage.MessageIntent == MessageIntentEnum.Unsubscribe) ||
                (transportMessage.MessageIntent == MessageIntentEnum.Send))))
            {
                var stream = new MemoryStream();
                var completionMessage = new CompletionMessage();
                if (transportMessage.Headers.ContainsKey(Headers.ReturnMessageErrorCodeHeader))
                    completionMessage.ErrorCode = int.Parse(transportMessage.Headers[Headers.ReturnMessageErrorCodeHeader]);

                MessageSerializer.Serialize(new object[]  { completionMessage }, stream);
                transportMessage.Body = stream.ToArray();
                Log.Debug("Added Completion message and sending message intent: " + transportMessage.MessageIntent);
            }
        }
开发者ID:nghead,项目名称:NServiceBus,代码行数:24,代码来源:OutgoingSubscriptionMessageMutator.cs


注:本文中的NServiceBus.Unicast.Transport.TransportMessage.IsControlMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。