public async void PublishBinaryMessages()
    {
        string randomName     = _pubsubFixture.RandomName();
        string topicId        = $"testTopicForProtoBinaryMessageCreation{randomName}";
        string subscriptionId = $"testSubscriptionForProtoBinaryMessageCreation{randomName}";
        string schemaId       = $"testSchemaForProtoBinaryMessageCreation{randomName}";

        var schema = _pubsubFixture.CreateProtoSchema(schemaId);

        _pubsubFixture.CreateTopicWithSchema(topicId, schema.Name.ToString(), Encoding.Binary);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        List <Utilities.State> messageTexts = new List <Utilities.State> {
            new Utilities.State {
                Name = "New York", PostAbbr = "NY"
            }, new Utilities.State {
                Name = "Pennsylvania", PostAbbr = "PA"
            }
        };

        var output = await _publishProtoMessagesAsyncSample.PublishProtoMessagesAsync(_pubsubFixture.ProjectId, topicId, messageTexts);

        Assert.Equal(messageTexts.Count, output);

        // Pull the Message to confirm it is valid
        var result = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, false);

        Assert.True(result > 0);
    }
Esempio n. 2
0
    public async Task PublishBinaryMessages()
    {
        string randomName     = _pubsubFixture.RandomName();
        string topicId        = $"testTopicAvroBinaryMessageCreation{randomName}";
        string subscriptionId = $"testSubscriptionAvroBinaryMessageCreation{randomName}";
        string schemaId       = $"testSchemaAvroBinaryMessageCreation{randomName}";

        var schema = _pubsubFixture.CreateAvroSchema(schemaId);

        _pubsubFixture.CreateTopicWithSchema(topicId, schema.Name.ToString(), Encoding.Binary);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        List <AvroUtilities.State> messageTexts = new List <AvroUtilities.State> {
            new AvroUtilities.State {
                name = "New York", post_abbr = "NY"
            }, new AvroUtilities.State {
                name = "Pennsylvania", post_abbr = "PA"
            }
        };

        var output = await _publishAvroMessagesAsyncSample.PublishAvroMessagesAsync(_pubsubFixture.ProjectId, topicId, messageTexts);

        Assert.Equal(messageTexts.Count, output);

        // Pull the Message to confirm it is valid
        await _pubsubFixture.Pull.Eventually(async() =>
        {
            var result = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, false);
            Assert.True(result > 0);
        });
    }
Esempio n. 3
0
    public async void AcknowledgeMessage()
    {
        string topicId        = "testTopicForMessageAck" + _pubsubFixture.RandomName();
        string subscriptionId = "testSubscriptionForMessageAck" + _pubsubFixture.RandomName();
        var    message        = _pubsubFixture.RandomName();

        _pubsubFixture.CreateTopic(topicId);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        await _publishMessagesAsyncSample.PublishMessagesAsync(_pubsubFixture.ProjectId, topicId, new string[] { message });

        // Pull and acknowledge the messages
        var result = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, true);

        Assert.Equal(1, result);

        //Pull the Message to confirm it's gone after it's acknowledged
        result = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, true);

        Assert.True(result == 0);
    }
    public async Task PullMessagesAsync()
    {
        string randomName     = _pubsubFixture.RandomName();
        string topicId        = $"testTopicForMessageAck{randomName}";
        string subscriptionId = $"testSubscriptionForMessageAck{randomName}";
        var    message        = _pubsubFixture.RandomName();

        _pubsubFixture.CreateTopic(topicId);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        await _publishMessagesAsyncSample.PublishMessagesAsync(_pubsubFixture.ProjectId, topicId, new string[] { message });

        await _pubsubFixture.Pull.Eventually(async() =>
        {
            // Pull and acknowledge the messages
            var result = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, true);
            Assert.Equal(1, result);
        });

        //Pull the Message to confirm it's gone after it's acknowledged
        var result = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, true);

        Assert.Equal(0, result);
    }
    public async void PublishMessageWithRetrySettingsAsync()
    {
        string randomName     = _pubsubFixture.RandomName();
        string topicId        = $"testTopicForMessageWithRetrySettingsAsync{randomName}";
        string subscriptionId = $"testSubscriptionForMessageWithRetrySettingsAsync{randomName}";

        _pubsubFixture.CreateTopic(topicId);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        await _publishMessageWithRetrySettingsAsyncSample
        .PublishMessageWithRetrySettingsAsync(_pubsubFixture.ProjectId, topicId, "Hello World!");

        // Pull the Message to confirm it is valid
        var messageCount = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, true);

        Assert.Equal(1, messageCount);
    }
Esempio n. 6
0
    public async void PublishMessage()
    {
        string topicId        = "testTopicForMessageCreation" + _pubsubFixture.RandomName();
        string subscriptionId = "testSubscriptionForMessageCreation" + _pubsubFixture.RandomName();

        _pubsubFixture.CreateTopic(topicId);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        List <string> messageTexts = new List <string> {
            "Hello World!", "Good day.", "Bye bye."
        };

        var output = await _publishMessagesAsyncSample.PublishMessagesAsync(_pubsubFixture.ProjectId, topicId, messageTexts);

        Assert.Equal(messageTexts.Count, output);

        // Pull the Message to confirm it is valid
        var result = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, false);

        Assert.True(result > 0);
    }
    public async void PublishMessage()
    {
        string randomName     = _pubsubFixture.RandomName();
        string topicId        = $"testTopicForOrderedPublish{randomName}";
        string subscriptionId = $"testSubscriptionForOrderedPublish{randomName}";

        _pubsubFixture.CreateTopic(topicId);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        List <(string, string)> messages = new List <(string, string)> {
            ("Key1", "Hello World!"), ("Key2", "Good day."), ("Key1", "Bye bye")
        };

        var publishedMessages = await _publishOrderedMessagesAsyncSample.PublishOrderedMessagesAsync(_pubsubFixture.ProjectId, topicId, messages);

        Assert.Equal(messages.Count, publishedMessages);

        // Pull the Message to confirm it is valid
        var messagesPulled = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, false);

        Assert.True(messagesPulled > 0);
    }
Esempio n. 8
0
    public async Task PublishBatchMessagesAsync()
    {
        string randomName     = _pubsubFixture.RandomName();
        string topicId        = $"testTopicForBatchMessageCreation{randomName}";
        string subscriptionId = $"testSubscriptionForBatchMessageCreation{randomName}";

        _pubsubFixture.CreateTopic(topicId);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        List <string> messageTexts = new List <string> {
            "Hello World!", "Good day.", "Bye bye."
        };

        var output = await _publishBatchedMessagesAsyncSample.PublishBatchMessagesAsync(_pubsubFixture.ProjectId, topicId, messageTexts);

        Assert.Equal(messageTexts.Count, output);

        // Pull the Message to confirm it is valid
        await _pubsubFixture.Pull.Eventually(async() =>
        {
            var result = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, false);
            Assert.True(result > 0);
        });
    }