Example #1
0
    public async Task Single()
    {
        await TestDataBuilder.SendData(table);

        var consumer = new QueueManager(table, SqlConnection);

        await using var result = await consumer.Consume();
        await Verify(result !.ToVerifyTarget());
    }
Example #2
0
    async Task RunBatch(QueueManager consumer, Func <IncomingMessage, Task> action, CancellationToken cancellation)
    {
        while (true)
        {
            var result = await consumer.Consume(batchSize, action, cancellation);

            if (result.Count < batchSize)
            {
                break;
            }
        }
    }
    public async Task Batch()
    {
        await TestDataBuilder.SendMultipleDataAsync(table);

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

        Assert.Equal(3, result.Count);
    }
Example #4
0
    async Task Consume()
    {
        #region Consume

        var queueManager = new QueueManager("endpointTable", sqlConnection);
        var message      = await queueManager.Consume()
                           .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 #5
0
    public async Task Run()
    {
        await SqlConnection.DropTable(null, table);

        var manager = new QueueManager(table, SqlConnection);
        await manager.Create();

        var configuration = await EndpointCreator.Create("IntegrationConsumer");

        configuration.SendOnly();
        var endpoint = await Endpoint.Start(configuration);

        await SendStartMessage(endpoint);

        var consumer = new QueueManager(table, SqlConnection);

        await using var message = await consumer.Consume();

        Assert.NotNull(message);
    }
    async Task Consume()
    {
        #region Consume

        var manager = new QueueManager("endpointTable", sqlConnection);
        var message = await manager.Consume();

        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
    }
Example #7
0
    async Task ConsumeBatch()
    {
        #region ConsumeBatch

        var queueManager = new QueueManager("endpointTable", sqlConnection);
        var result       = await queueManager.Consume(
            size : 5,
            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
    }