예제 #1
0
        public static TransportMessage ToTransportmessage(ITimeoutData timeoutData)
        {
            var replyToAddress = Address.Local;

            if (timeoutData.Headers != null && timeoutData.Headers.ContainsKey(HeaderKeys.OriginalReplyToAddress))
            {
                replyToAddress = Address.Parse(timeoutData.Headers[HeaderKeys.OriginalReplyToAddress]);
                timeoutData.Headers.Remove(HeaderKeys.OriginalReplyToAddress);
            }

            return new TransportMessage(timeoutData.MessageId, timeoutData.CorrelationId, replyToAddress, TimeSpan.MaxValue, timeoutData.Headers, timeoutData.Body);
        }
예제 #2
0
        public void Add(ITimeoutData timeout)
        {
            Logger.Debug("Adding timeout {0}", timeout.MessageId);

            using (var connection = new SqlConnection(connectionString))
            {
                connection.Open();
                using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted))
                {
                    using (var command = BuildAddCommand(connection, timeout))
                    {
                        command.Transaction = transaction;
                        command.ExecuteNonQuery();
                    }

                    transaction.Commit();
                }
            }
        }
        public bool TryFetchNextTimeout(out ITimeoutData timeoutData)
        {
            timeoutData = null;

            return false;
        }
 public void Add(ITimeoutData timeout)
 {
 }
예제 #5
0
        private SqlCommand BuildAddCommand(SqlConnection connection, ITimeoutData timoutData)
        {
            var command = connection.CreateCommand();

            if (Settings.IsLocalEndpoint)
            {
                command.CommandText = String.Format(SqlCommands.AddTimeout, Address.Parse(timoutData.DestinationAddress));
            }
            else
            {
                command.CommandText = String.Format(SqlCommands.AddTimeout, Address.Local);
            }

            command.CommandType = CommandType.Text;

            command.Parameters.AddWithValue("@Id", timoutData.MessageId);
            command.Parameters.AddWithValue("@Destination", timoutData.DestinationAddress);
            command.Parameters.AddWithValue("@Headers", objectSerializer.SerializeObject(timoutData.Headers));
            command.Parameters.AddWithValue("@Expires", timoutData.Expires);
            command.Parameters.AddWithValue("@Body", timoutData.Body);

            if (timoutData.CorrelationId != Guid.Empty)
            {
                command.Parameters.AddWithValue("@CorrelationId", timoutData.CorrelationId);
            }
            else
            {
                command.Parameters.AddWithValue("@CorrelationId", DBNull.Value);
            }

            return command;
        }
예제 #6
0
        public bool TryFetchNextTimeout(out ITimeoutData timeoutData)
        {
            using (var connection = new SqlConnection(connectionString))
            {
                connection.Open();
                using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted))
                {
                    using (var command = new SqlCommand(String.Format(SqlCommands.TryRemoveTimeout, Address.Local), connection, transaction))
                    {
                        using (var dataReader = command.ExecuteReader())
                        {
                            timeoutData = FoundTimeoutData(dataReader);
                        }
                    }

                    transaction.Commit();
                }
            }

            return timeoutData != null;
        }