コード例 #1
0
        public static DelayedMessageRow From(Dictionary <string, string> headers, byte[] body, DateTime due, string destination)
        {
            Guard.AgainstNull(nameof(destination), destination);

            var row = new DelayedMessageRow();

            headers["NServiceBus.SqlServer.ForwardDestination"] = destination;
            row.headers   = DictionarySerializer.Serialize(headers);
            row.bodyBytes = body;
            row.due       = due;
            return(row);
        }
コード例 #2
0
 public static MessageRow From(Dictionary <string, string> headers, byte[] body, TimeSpan toBeReceived)
 {
     return(new MessageRow
     {
         id = Guid.NewGuid(),
         correlationId = TryGetHeaderValue(headers, Headers.CorrelationId, s => s),
         replyToAddress = TryGetHeaderValue(headers, Headers.ReplyToAddress, s => s),
         timeToBeReceived = toBeReceived == TimeSpan.MaxValue ? null : (int?)toBeReceived.TotalMilliseconds,
         headers = DictionarySerializer.Serialize(headers),
         bodyBytes = body
     });
 }
コード例 #3
0
        public static StoreDelayedMessageCommand From(Dictionary <string, string> headers, byte[] body, TimeSpan dueAfter, string destination)
        {
            Guard.AgainstNull(nameof(destination), destination);

            var row = new StoreDelayedMessageCommand();

            headers["NServiceBus.SqlServer.ForwardDestination"] = destination;
            row.headers   = DictionarySerializer.Serialize(headers);
            row.bodyBytes = body;
            row.dueAfter  = dueAfter;
            return(row);
        }
コード例 #4
0
        MessageReadResult TryParse()
        {
            try
            {
                var parsedHeaders = IsNullOrEmpty(headers)
                    ? new Dictionary <string, string>()
                    : DictionarySerializer.DeSerialize(headers);

                if (!IsNullOrEmpty(replyToAddress))
                {
                    parsedHeaders[Headers.ReplyToAddress] = replyToAddress;
                }

                LegacyCallbacks.SubstituteReplyToWithCallbackQueueIfExists(parsedHeaders);
                return(MessageReadResult.Success(new Message(id.ToString(), parsedHeaders, bodyBytes, expired)));
            }
            catch (Exception ex)
            {
                Logger.Error("Error receiving message. Probable message metadata corruption. Moving to error queue.", ex);
                return(MessageReadResult.Poison(this));
            }
        }