Exemplo n.º 1
0
 public Sender(Func <CancellationToken, Task <DbConnection> > connectionFunc, HeadersBuilder headersBuilder, Table attachmentsTable, Table dedupeTable, ILogger logger)
 {
     this.connectionFunc = connectionFunc;
     attachments         = new Persister(new  NServiceBus.Attachments.Sql.Raw.Table(attachmentsTable.TableName, attachmentsTable.Schema, false));
     this.headersBuilder = headersBuilder;
     this.dedupeTable    = dedupeTable;
     this.logger         = logger;
 }
Exemplo n.º 2
0
 public Sender(Func <CancellationToken, Task <SqlConnection> > connectionFunc, HeadersBuilder headersBuilder, Table attachmentsTable, Table dedupeTable, ILogger logger)
 {
     this.connectionFunc = connectionFunc;
     attachments         = new(new(attachmentsTable.TableName, attachmentsTable.Schema, false));
     this.headersBuilder = headersBuilder;
     this.dedupeTable    = dedupeTable;
     this.logger         = logger;
 }
Exemplo n.º 3
0
 public async Task <long> Send(PassthroughMessage message, Table destination, CancellationToken cancellation)
 {
     try
     {
         return(await InnerSend(message, destination, cancellation));
     }
     catch (Exception exception)
     {
         throw new SendFailureException(message, exception);
     }
 }
Exemplo n.º 4
0
    async Task <long> InnerSend(PassthroughMessage message, Table destination, CancellationToken cancellation)
    {
        await using var connection = await connectionFunc(cancellation);

        await using var transaction = connection.BeginTransaction();
        var rowVersion = await SendInsideTransaction(message, destination, cancellation, transaction);

        await transaction.CommitAsync(cancellation);

        return(rowVersion);
    }
Exemplo n.º 5
0
    async Task <long> SendInsideTransaction(PassthroughMessage message, Table destination, CancellationToken cancellation, DbTransaction transaction)
    {
        var headersString = headersBuilder.GetHeadersString(message);

        LogSend(message);
        var outgoingMessage = new OutgoingMessage(
            message.Id,
            headers: headersString,
            bodyBytes: Encoding.UTF8.GetBytes(message.Body));
        var queueManager     = new QueueManager(destination, transaction, dedupeTable);
        var attachmentExpiry = DateTime.UtcNow.AddDays(10);

        await SendAttachments(transaction, attachmentExpiry, cancellation, message);

        return(await queueManager.Send(outgoingMessage, cancellation));
    }