Esempio n. 1
0
        public void InitializeCommandListeners(Type type, string queueName)
        {
            Logger.LogInformation("Initializing command listeners for type '{1}'", type);

            foreach (var attributeContent in InitializationUtility.GetAttributeValuesWithMethod <CommandAttribute>(type))
            {
                var parameterType = InitializationUtility.GetParameterTypeOrThrow(attributeContent.Method, Logger);

                _commandListener.SetupCommandListenerAsync(
                    queueName,
                    attributeContent.Key,
                    receivedParameter => InvokeCommand(receivedParameter, attributeContent),
                    parameterType,
                    attributeContent.ExchangeName).Wait();
            }
        }
        public void InitializeEventListeners(Type type, string queueName)
        {
            Logger.LogInformation("Initializing event listeners for type '{1}'", type);

            foreach (var attributeContent in InitializationUtility.GetAttributeValuesWithMethod <EventAttribute>(type))
            {
                var parameterType = InitializationUtility.GetParameterTypeOrThrow(attributeContent.Method, Logger);

                Logger.LogInformation(
                    "Initializing listener for topic {1} in type {2}",
                    attributeContent.Key,
                    type);

                _eventListener.SetupQueueListenerAsync(
                    queueName,
                    attributeContent.Key,
                    (receivedParameter, receivedTopic) => InvokeTopic(receivedParameter, receivedTopic, attributeContent),
                    parameterType);
            }
        }