Example #1
0
        public MessageProducer(ILogger <MessageProducer> logger, JsonSerializerSettings serializerSettings)
        {
            _logger  = logger;
            _options = new MessageHubOptions();

            var conf = new ProducerConfig {
                BootstrapServers = _options.ServerURI
            };

            _testAddedProducer             = new ProducerBuilder <Null, TestAddedMessage>(conf).Build(serializerSettings);
            _testExecutedProducer          = new ProducerBuilder <Null, TestExecutedMessage>(conf).Build(serializerSettings);
            _testAcquiredProducer          = new ProducerBuilder <Null, TestAcquiringResultMessage>(conf).Build(serializerSettings);
            _testCompletedProducer         = new ProducerBuilder <Null, TestCompletedMessage>(conf).Build(serializerSettings);
            _testCompletedOnSourceProducer = new ProducerBuilder <Null, TestCompletedOnSourceMessage>(conf).Build(serializerSettings);
            _testDeletedProducer           = new ProducerBuilder <Null, TestDeletedMessage>(conf).Build(serializerSettings);
            _beginTestProducer             = new ProducerBuilder <Null, BeginTestMessage>(conf).Build(serializerSettings);
            _testRecordedProducer          = new ProducerBuilder <Null, TestRecordedMessage>(conf).Build(serializerSettings);
            _testCancelledProducer         = new ProducerBuilder <Null, TestCancelledMessage>(conf).Build(serializerSettings);
            _cancelTestProducer            = new ProducerBuilder <Null, CancelTestMessage>(conf).Build(serializerSettings);

            _updateTestResultStateProducer   = new ProducerBuilder <Null, UpdateTestResultStateMessage>(conf).Build(serializerSettings);
            _testResultStateAcquiredProducer = new ProducerBuilder <Null, TestResultStateAcquiredMessage>(conf).Build(serializerSettings);
            _testResultStateUpdatedProducer  = new ProducerBuilder <Null, TestResultStateUpdatedMessage>(conf).Build(serializerSettings);
        }
Example #2
0
        public MessageConsumer(ILogger <MessageConsumer> logger, JsonSerializerSettings serializerSettings, MessageHubOptions options,
                               IOptions <MessageConsumerOptions> consumerOptions)
        {
            _logger = logger;

            var conf = new ConsumerConfig
            {
                GroupId          = consumerOptions.Value.GroupId, //"test-consumer-group",
                BootstrapServers = options.ServerURI,
                // Note: The AutoOffsetReset property determines the start offset in the event
                // there are not yet any committed offsets for the consumer group for the
                // topic/partitions of interest. By default, offsets are committed
                // automatically, so in this example, consumption will only start from the
                // earliest message in the topic 'my-topic' the first time you run the program.
                AutoOffsetReset = AutoOffsetReset.Earliest
            };

            var testExecuted = new ConsumerBuilder <Ignore, TestExecutedMessage>(conf)
                               .Build(serializerSettings);
            var testAdded = new ConsumerBuilder <Ignore, TestAddedMessage>(conf)
                            .Build(serializerSettings);
            var testAcquired = new ConsumerBuilder <Ignore, TestAcquiringResultMessage>(conf)
                               .Build(serializerSettings);
            var testCompleted = new ConsumerBuilder <Ignore, TestCompletedMessage>(conf)
                                .Build(serializerSettings);
            var testCompletedOnSource = new ConsumerBuilder <Ignore, TestCompletedOnSourceMessage>(conf)
                                        .Build(serializerSettings);
            var testDeleted = new ConsumerBuilder <Ignore, TestDeletedMessage>(conf)
                              .Build(serializerSettings);
            var beginTest = new ConsumerBuilder <Ignore, BeginTestMessage>(conf)
                            .Build(serializerSettings);
            var testRecorded = new ConsumerBuilder <Ignore, TestRecordedMessage>(conf)
                               .Build(serializerSettings);

            consumeDaemon(testExecuted, options.TestExecutedTopic, m => TestExecutedAsync.InvokeAndWaitAsync(m));
            consumeDaemon(testAdded, options.TestAddedTopic, m => TestAddedAsync.InvokeAndWaitAsync(m));
            consumeDaemon(testAcquired, options.TestAcquiredTopic, m => TestAcquiredAsync.InvokeAndWaitAsync(m));
            consumeDaemon(testCompleted, options.TestCompletedTopic, m => TestCompletedAsync.InvokeAndWaitAsync(m));
            consumeDaemon(testCompletedOnSource, options.TestCompletedOnSourceTopic, m => TestCompletedOnSourceAsync.InvokeAndWaitAsync(m));
            consumeDaemon(testDeleted, options.TestDeletedTopic, m => TestDeletedAsync.InvokeAndWaitAsync(m));
            consumeDaemon(beginTest, options.BeginTestTopic, m => BeginTestAsync.InvokeAndWaitAsync(m));
            consumeDaemon(testRecorded, options.TestRecordedTopic, m => TestRecordedAsync.InvokeAndWaitAsync(m));

            startConsumeDaemon <CancelTestMessage>(conf, serializerSettings, options.CancelTestTopic, m => CancelTestAsync.InvokeAndWaitAsync(m));
            startConsumeDaemon <TestCancelledMessage>(conf, serializerSettings, options.TestCancelledTopic, m => TestCancelledAsync.InvokeAndWaitAsync(m));

            startConsumeDaemon <UpdateTestResultStateMessage>(conf, serializerSettings, null, m => UpdateTestResultAsync.InvokeAndWaitAsync(m));
            startConsumeDaemon <TestResultStateAcquiredMessage>(conf, serializerSettings, null, m => TestResultStateAcquiredAsync.InvokeAndWaitAsync(m));
            startConsumeDaemon <TestResultStateUpdatedMessage>(conf, serializerSettings, null, m => TestResultStateUpdatedAsync.InvokeAndWaitAsync(m));
        }