public async Task Store(OutgoingMessage message, TimeSpan dueAfter, string destination, SqlConnection connection, SqlTransaction transaction) { var messageRow = StoreDelayedMessageCommand.From(message.Headers, message.Body, dueAfter, destination); using (var command = new SqlCommand(storeCommand, connection, transaction)) { messageRow.PrepareSendCommand(command); await command.ExecuteNonQueryAsync().ConfigureAwait(false); } }
public static StoreDelayedMessageCommand From(Dictionary <string, string> headers, ReadOnlyMemory <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.ToArray(); row.dueAfter = dueAfter; return(row); }
public async Task Store(OutgoingMessage message, TimeSpan dueAfter, string destination, SqlConnection connection, SqlTransaction transaction, CancellationToken cancellationToken = default) { var messageRow = StoreDelayedMessageCommand.From(message.Headers, message.Body, dueAfter, destination); using (var command = new SqlCommand(storeCommand, connection, transaction)) { messageRow.PrepareSendCommand(command); await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false); } OnStoreDelayedMessage?.Invoke(null, DateTime.UtcNow.Add(dueAfter)); }