コード例 #1
0
        public async Task AddConsumer <TValue>(string groupId, string topic, Func <string, TValue, Task> messageHandler)
        {
            if (string.IsNullOrWhiteSpace(groupId))
            {
                throw new ArgumentNullException(nameof(groupId));
            }

            if (string.IsNullOrWhiteSpace(topic))
            {
                throw new ArgumentNullException(nameof(topic));
            }

            var consumerHandler      = LocalMessageCustomerConsumerFactory.GetConsumerHandler <TValue>(topic);
            var groupConsumerHandler = consumerHandler.GetGroupConsumerHandler(groupId);

            groupConsumerHandler.AddHandler(messageHandler);

            await Task.CompletedTask;
        }
コード例 #2
0
        public async Task Publish <TValue>(string topic, string key, TValue value)
        {
            var consumerHandler = LocalMessageCustomerConsumerFactory.GetConsumerHandler <TValue>(topic);

            await consumerHandler.Publish(key, value);
        }