public void Build(IRabbitMqHostControl host) { var builder = new RabbitMqReceiveEndpointBuilder(host, this); ApplySpecifications(builder); var receiveEndpointContext = builder.CreateReceiveEndpointContext(); _modelConfigurator.UseFilter(new ConfigureTopologyFilter <ReceiveSettings>(_settings, receiveEndpointContext.BrokerTopology)); IAgent consumerAgent; if (_hostConfiguration.DeployTopologyOnly) { var transportReadyFilter = new TransportReadyFilter <ModelContext>(receiveEndpointContext); _modelConfigurator.UseFilter(transportReadyFilter); consumerAgent = transportReadyFilter; } else { if (_settings.PurgeOnStartup) { _modelConfigurator.UseFilter(new PurgeOnStartupFilter(_settings.QueueName)); } _modelConfigurator.UseFilter(new PrefetchCountFilter(_managementPipe, _settings.PrefetchCount)); var consumerFilter = new RabbitMqConsumerFilter(receiveEndpointContext); _modelConfigurator.UseFilter(consumerFilter); consumerAgent = consumerFilter; } IFilter <ConnectionContext> modelFilter = new ReceiveEndpointFilter(_modelConfigurator.Build()); _connectionConfigurator.UseFilter(modelFilter); var transport = new RabbitMqReceiveTransport(host, _settings, _connectionConfigurator.Build(), receiveEndpointContext); transport.Add(consumerAgent); var receiveEndpoint = new ReceiveEndpoint(transport, receiveEndpointContext); var queueName = _settings.QueueName ?? NewId.Next().ToString(FormatUtil.Formatter); host.AddReceiveEndpoint(queueName, receiveEndpoint); ReceiveEndpoint = receiveEndpoint; }
protected IReceivePipe CreateReceivePipe(IReceiveEndpointBuilder builder) { foreach (var specification in _specifications) { specification.Configure(builder); } _receiveConfigurator.UseDeadLetterQueue(Pipe.New <ReceiveContext>(x => x.UseFilter(new MoveToTransportFilter(DeadLetterAddress, "dead-letter")))); _receiveConfigurator.UseRescue(Pipe.New <ExceptionReceiveContext>(x => x.UseFilter(new MoveExceptionToTransportFilter(ErrorAddress)))); _receiveConfigurator.UseFilter(new DeserializeFilter(builder.MessageDeserializer, builder.ConsumePipe)); IPipe <ReceiveContext> receivePipe = _receiveConfigurator.Build(); return(new ReceivePipe(receivePipe, builder.ConsumePipe)); }
protected IPipe <ReceiveContext> CreateReceivePipe(IBusBuilder builder, Func <IConsumePipe, IReceiveEndpointBuilder> endpointBuilderFactory) { IConsumePipe consumePipe = _consumePipe ?? builder.CreateConsumePipe(_consumePipeSpecification); IReceiveEndpointBuilder endpointBuilder = endpointBuilderFactory(consumePipe); foreach (IReceiveEndpointSpecification specification in _specifications) { specification.Configure(endpointBuilder); } ConfigureAddDeadLetterFilter(builder.SendTransportProvider); ConfigureRescueFilter(builder.SendTransportProvider); _receiveConfigurator.UseFilter(new DeserializeFilter(builder.MessageDeserializer, consumePipe)); return(_receiveConfigurator.Build()); }
public override IReceiveEndpoint Build() { var builder = new AmazonSqsReceiveEndpointBuilder(this); ApplySpecifications(builder); var receiveEndpointContext = builder.CreateReceiveEndpointContext(); _clientConfigurator.UseFilter(new ConfigureTopologyFilter <ReceiveSettings>(_settings, receiveEndpointContext.BrokerTopology)); IAgent consumerAgent; if (_hostConfiguration.BusConfiguration.DeployTopologyOnly) { var transportReadyFilter = new TransportReadyFilter <ClientContext>(receiveEndpointContext); _clientConfigurator.UseFilter(transportReadyFilter); consumerAgent = transportReadyFilter; } else { if (_settings.PurgeOnStartup) { _clientConfigurator.UseFilter(new PurgeOnStartupFilter(_settings.EntityName)); } var consumerFilter = new AmazonSqsConsumerFilter(receiveEndpointContext); _clientConfigurator.UseFilter(consumerFilter); consumerAgent = consumerFilter; } IFilter <ConnectionContext> clientFilter = new ReceiveClientFilter(_clientConfigurator.Build()); _connectionConfigurator.UseFilter(clientFilter); var transport = new SqsReceiveTransport(_hostConfiguration.Host, _settings, _connectionConfigurator.Build(), receiveEndpointContext); transport.Add(consumerAgent); return(CreateReceiveEndpoint(_settings.EntityName ?? NewId.Next().ToString(), transport, receiveEndpointContext)); }
public IReceivePipe CreatePipe(IConsumePipe consumePipe, IMessageDeserializer messageDeserializer) { if (_created) { throw new ConfigurationException("The ReceivePipeConfiguration can only be used once."); } _deadLetterPipeConfigurator.UseFilter(new DeadLetterTransportFilter()); _configurator.UseDeadLetter(_deadLetterPipeConfigurator.Build()); _errorPipeConfigurator.UseFilter(new GenerateFaultFilter()); _errorPipeConfigurator.UseFilter(new ErrorTransportFilter()); _configurator.UseRescue(_errorPipeConfigurator.Build()); _configurator.UseFilter(new DeserializeFilter(messageDeserializer, consumePipe)); _created = true; return(new ReceivePipe(_configurator.Build(), consumePipe)); }
async Task IPipe <SendContext <TRequest> > .Send(SendContext <TRequest> context) { await _readyToSend.Task.ConfigureAwait(false); context.RequestId = ((RequestHandle)this).RequestId; context.ResponseAddress = _context.ResponseAddress; context.Headers.Set(MessageHeaders.Request.Accept, _accept); if (_timeToLive.HasValue) { context.TimeToLive ??= _timeToLive.Value; } IPipe <SendContext <TRequest> > pipe = _pipeConfigurator.Build(); if (pipe.IsNotEmpty()) { await pipe.Send(context).ConfigureAwait(false); } _sendContext.TrySetResult(context); }
public IPipe <ConsumeContext <Batch <TMessage> > > BuildMessagePipe(Action <IPipeConfigurator <ConsumeContext <Batch <TMessage> > > > configure) { configure?.Invoke(_batchMessagePipeConfigurator); return(_batchMessagePipeConfigurator.Build()); }