public RequestConsumerFutureDefinition(IConsumerDefinition <TConsumer> consumerDefinition)
        {
            if (consumerDefinition is IFutureRequestDefinition <TRequest> requestDefinition)
            {
                _requestDefinition = requestDefinition;
            }

            EndpointDefinition = new RequestConsumerFutureEndpointDefinition <TFuture>(this, consumerDefinition);
        }
        IConsumerDefinition <TConsumer> GetConsumerDefinition(IConfigurationServiceProvider provider)
        {
            if (_definition != null)
            {
                return(_definition);
            }

            _definition = provider.GetService <IConsumerDefinition <TConsumer> >() ?? new DefaultConsumerDefinition <TConsumer>();

            var endpointDefinition = provider.GetService <IEndpointDefinition <TConsumer> >();

            if (endpointDefinition != null)
            {
                _definition.EndpointDefinition = endpointDefinition;
            }

            return(_definition);
        }
        public AzureTopologyDefinition BuildFrom(IConsumerDefinition definition)
        {
            var topic        = BuildTopic(definition.MessageType);
            var queue        = BuildQueue(definition.ConsumerType);
            var subscription = BuildSubscription(topic.Name, queue.Name, definition.ConsumerType);

            return(new AzureTopologyDefinition
            {
                Queues = new[] { queue },
                Topics = new[] { topic },
                Subscriptions = new[] { subscription },
                Reciever = new RecieverDefinition {
                    Queue = queue
                },
                Sender = new SenderDefinition {
                    Queue = queue
                }
            });
        }
        public async ValueTask StartAsync(IConsumerDefinition definition, IConsumerPipelineFactory pipelineFactory)
        {
            var topologyDefinition = _topology.BuildFrom(definition);

            _processor = await _client.BuildProcessorAsync(topologyDefinition);

            _sender = await _client.BuildSenderAsync(topologyDefinition);

            _processor.ProcessMessageAsync += async e =>
            {
                var message      = new DefaultServiceBusMessage(e.Message.Body);
                var context      = new DefaultConsumerContext(message, definition);
                var azureContext = new AzureConsumerContext(context, e, _bus, _sender);
                var pipeline     = pipelineFactory.Create(null);
                await pipeline.Execute(azureContext);
            };
            _processor.ProcessErrorAsync += e =>
            {
                _logger.LogError(e.Exception, e.ToString());
                return(Task.CompletedTask);
            };
            await _processor.StartProcessingAsync();
        }
 public RequestConsumerFutureEndpointDefinition(IDefinition definition, IConsumerDefinition consumerDefinition)
 {
     _definition         = definition;
     _consumerDefinition = consumerDefinition;
 }
Esempio n. 6
0
 IConsumerDefinition <TConsumer> GetConsumerDefinition(IConfigurationServiceProvider provider)
 {
     return(_definition ?? (_definition = provider.GetService <IConsumerDefinition <TConsumer> >() ?? new DefaultConsumerDefinition <TConsumer>()));
 }
 public DefaultConsumerContext(IServiceBusMessage message, IConsumerDefinition consumerDefinition)
 {
     Message            = message;
     ConsumerDefinition = consumerDefinition;
 }
Esempio n. 8
0
 public PriceCalculationFutureDefinition(IConsumerDefinition <CalculatePriceConsumer> consumerDefinition)
     : base(consumerDefinition)
 {
 }