Example #1
0
    async Task ReadBatch()
    {
        #region ReadDelayedBatch

        var manager = new DelayedQueueManager("endpointTable", sqlConnection);
        var result  = await manager.Read(
            size : 5,
            startRowVersion : 10,
            action : async message =>
        {
            Console.WriteLine(message.Headers);
            if (message.Body == null)
            {
                return;
            }

            using var reader = new StreamReader(message.Body);
            var bodyText     = await reader.ReadToEndAsync();
            Console.WriteLine(bodyText);
        });

        Console.WriteLine(result.Count);
        Console.WriteLine(result.LastRowVersion);

        #endregion
    }
Example #2
0
    public DelayedReaderTests()
    {
        var manager = new DelayedQueueManager(table, SqlConnection);

        manager.Drop().Await();
        manager.Create().Await();
    }
Example #3
0
    async Task SendBatch()
    {
        string headers1 = null;

        byte[] body1    = null;
        string headers2 = null;

        byte[] body2 = null;

        #region SendDelayedBatch

        var queueManager = new DelayedQueueManager("endpointTable.Delayed", sqlConnection);
        var messages     = new List <OutgoingDelayedMessage>
        {
            new OutgoingDelayedMessage(
                due: DateTime.UtcNow.AddDays(1),
                headers: headers1,
                bodyBytes: body1),
            new OutgoingDelayedMessage(
                due: DateTime.UtcNow.AddDays(1),
                headers: headers2,
                bodyBytes: body2),
        };
        await queueManager.Send(messages)
        .ConfigureAwait(false);

        #endregion
    }
Example #4
0
    async Task ReadBatch()
    {
        #region ReadDelayedBatch

        var queueManager = new DelayedQueueManager("endpointTable", sqlConnection);
        var result       = await queueManager.Read(
            size : 5,
            startRowVersion : 10,
            action : async message =>
        {
            Console.WriteLine(message.Headers);
            using (var reader = new StreamReader(message.Body))
            {
                var bodyText = await reader.ReadToEndAsync()
                               .ConfigureAwait(false);
                Console.WriteLine(bodyText);
            }
        })
                           .ConfigureAwait(false);

        Console.WriteLine(result.Count);
        Console.WriteLine(result.LastRowVersion);

        #endregion
    }
Example #5
0
    public async Task Single()
    {
        await DelayedTestDataBuilder.SendData(table);

        var reader = new DelayedQueueManager(table, SqlConnection);

        await using var result = await reader.Read(1);
        await Verify(result !.ToVerifyTarget());
    }
Example #6
0
    async Task CreateQueue()
    {
        #region CreateDelayedQueue

        var queueManager = new DelayedQueueManager("endpointTable.Delayed", sqlConnection);
        await queueManager.Create().ConfigureAwait(false);

        #endregion
    }
Example #7
0
    async Task DeleteQueue()
    {
        #region DeleteDelayedQueue

        var manager = new DelayedQueueManager("endpointTable.Delayed", sqlConnection);
        await manager.Drop();

        #endregion
    }
Example #8
0
    public async Task Single_nulls()
    {
        await DelayedTestDataBuilder.SendNullData(table);

        var consumer = new DelayedQueueManager(table, SqlConnection);

        await using var result = await consumer.Consume();
        await Verify(result !.ToVerifyTarget());
    }
Example #9
0
    public static async Task <IOrderedEnumerable <IncomingDelayedVerifyTarget> > ReadDelayedData(string table, SqlConnection connection)
    {
        var reader   = new DelayedQueueManager(table, connection);
        var messages = new ConcurrentBag <IncomingDelayedVerifyTarget>();
        await reader.Read(size : 10,
                          startRowVersion : 1,
                          action : message => { messages.Add(message.ToVerifyTarget()); });

        return(messages.OrderBy(x => x.Due));
    }
    public async Task Run()
    {
        await using var connection = Connection.OpenConnectionFromNewClient();
        var manager = new DelayedQueueManager("DelayedQueueCreationTests", connection);
        await manager.Drop();

        await manager.Create();

        var settings = new VerifySettings();

        settings.SchemaSettings(includeItem: s => s == "DelayedQueueCreationTests");
        await Verify(connection, settings);
    }
    static async Task CreateTables()
    {
        await using var dbConnection = await ConnectionBuilder();

        var main = new QueueManager("SampleEndpoint", dbConnection);
        await main.Create();

        var delayed = new DelayedQueueManager("SampleEndpoint.Delayed", dbConnection);
        await delayed.Create();

        var subscription = new SubscriptionManager("SubscriptionRouting", dbConnection);
        await subscription.Create();
    }
Example #12
0
    public async Task Batch()
    {
        await DelayedTestDataBuilder.SendMultipleData(table);

        var consumer = new DelayedQueueManager(table, SqlConnection);
        var messages = new ConcurrentBag <IncomingDelayedVerifyTarget>();
        var result   = await consumer.Consume(size : 3,
                                              action : message => { messages.Add(message.ToVerifyTarget()); });

        Assert.Equal(3, result.Count);
        Assert.Equal(3, result.LastRowVersion);
        await Verify(messages.OrderBy(x => x.Due));
    }
Example #13
0
    async Task Send()
    {
        string headers = null !;

        byte[] body = null !;

        #region SendDelayed

        var manager = new DelayedQueueManager("endpointTable.Delayed", sqlConnection);
        var message = new OutgoingDelayedMessage(
            due: DateTime.UtcNow.AddDays(1),
            headers: headers,
            bodyBytes: body);
        await manager.Send(message);

        #endregion
    }
Example #14
0
    async Task Read()
    {
        #region ReadDelayed

        var queueManager = new DelayedQueueManager("endpointTable", sqlConnection);
        var message      = await queueManager.Read(rowVersion : 10)
                           .ConfigureAwait(false);

        Console.WriteLine(message.Headers);
        using (var reader = new StreamReader(message.Body))
        {
            var bodyText = await reader.ReadToEndAsync()
                           .ConfigureAwait(false);

            Console.WriteLine(bodyText);
        }

        #endregion
    }
Example #15
0
    async Task Read()
    {
        #region ReadDelayed

        var manager = new DelayedQueueManager("endpointTable", sqlConnection);
        var message = await manager.Read(rowVersion : 10);

        if (message != null)
        {
            Console.WriteLine(message.Headers);
            if (message.Body != null)
            {
                using var reader = new StreamReader(message.Body);
                var bodyText = await reader.ReadToEndAsync();

                Console.WriteLine(bodyText);
            }
        }

        #endregion
    }