internal static Message <T> Create( BasicGetResult result, IBusSerializer serializer, Action <Message <T> > onDone, Action <Exception, Message <T> > onFail) { var @event = new BasicDeliverEventArgs( string.Empty, result.DeliveryTag, result.Redelivered, result.Exchange, result.RoutingKey, result.BasicProperties, result.Body); return(Create( null, null, null, (RoutingKey)null, serializer, @event, onDone, onFail)); }
public MessageOptions(Exchange exchange, Queue queue, RoutingKey routingKey, int maxAttempts, IBusSerializer serializer) { Exchange = exchange; Queue = queue; RoutingKey = routingKey; MaxAttempts = maxAttempts; Serializer = serializer; }
public CommandBus(string natsConnectionString, IBusLog log, IBusSerializer serializer) { log.Information($"Using natsconnection string: {natsConnectionString}"); this.natsConnectionString = natsConnectionString; this.log = log; this.serializer = serializer; this.subscriptions = new List <IAsyncSubscription>(); }
public BusConnection(BusConnectionString connectionString, IBusSerializer serializer, IServiceScopeFactory serviceScopeFactory, IOptions <BusConnectionOptions> options, IBusLogger logger = null, IRetryBehavior retryBehavior = null) : this(GetConnectionFactory(connectionString), serializer, serviceScopeFactory, options, logger, retryBehavior) { }
public Publisher(ILogger <Publisher <TSerializer, TDeserializer> > logger, IServiceProvider provider, IEnumerable <IPublishSafeStore> safePoints) { _logger = logger; _provider = provider; _serializer = provider.GetService <TSerializer>(); _deserializer = provider.GetService <TDeserializer>(); _stopper = _deserializer == null ? Disposable.Empty : RunRepublishing(safePoints); }
public BusRpcServer( RabbitMQConnection connection, IBusSerializer busSerializer, IOptions <BusRpcOptions <TCommand, TResponse> > options, IMediator mediator) { _connection = connection ?? throw new ArgumentNullException(nameof(connection)); _busSerializer = busSerializer ?? throw new ArgumentNullException(nameof(busSerializer)); _options = options; _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator)); }
public RabbitMQConnection(IConfiguration configuration, IBusSerializer busSerializer, IServiceProvider serviceProvider) { _busSerializer = busSerializer ?? throw new ArgumentNullException(nameof(busSerializer)); _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); var connectionFactory = new ConnectionFactory { Uri = new Uri(configuration.GetConnectionString("RabbitMQ")) }; _connection = connectionFactory.CreateConnection(); _channel = _connection.CreateModel(); }
public byte[] GetBody(IBusSerializer serializer) { if (serializer == null) { throw new ArgumentNullException(nameof(serializer)); } if (_data is IConsumerMessage consumerMessage) { return(consumerMessage.Body); } return(_body.Length == 0 ? _body = serializer.Serialize(_data) : _body); }
public ConsumerOptions(IBusSerializer serializer, Exchange exchange, Queue queue, ushort prefetchCount, Func <IServiceScope, Message <T>, Task> onNext, bool autoAck, int consumerMaxParallelTasks, params RoutingKey[] routingKeys) { if (prefetchCount <= 0) { throw new ArgumentException(nameof(prefetchCount)); } Serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); Exchange = exchange ?? throw new ArgumentNullException(nameof(exchange)); Queue = queue ?? throw new ArgumentNullException(nameof(queue)); PrefetchCount = prefetchCount; OnNext = onNext ?? throw new ArgumentNullException(nameof(onNext)); AutoAck = autoAck; ConsumerMaxParallelTasks = consumerMaxParallelTasks; RoutingKeys = routingKeys; }
public BusConnection(IConnectionFactory connectionFactory, IBusSerializer serializer, IServiceScopeFactory serviceScopeFactory, IOptions <BusConnectionOptions> options, IBusLogger logger = null, IRetryBehavior retryBehavior = null) { _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); _serviceScopeFactory = serviceScopeFactory; _logger = logger; _options = options; _consumers = new ConcurrentBag <IConsumer>(); _connectionFactory = connectionFactory; _publisherBuffer = new BufferList <BatchItem>(_options.Value.PublisherBufferSize, TimeSpan.FromMilliseconds(_options.Value.PublisherBufferTtlInMilliseconds)); _publisherBuffer.Cleared += PublishBufferOnCleared; _retryBehavior = retryBehavior ?? new ConstantRetryBehavior(1); }
protected internal override (byte[], IBasicProperties) GetData(IModel channel, IBusSerializer serializer) { return(Data as byte[], _basicProperties); }
protected internal virtual (byte[], IBasicProperties) GetData(IModel channel, IBusSerializer serializer) { var body = serializer.Serialize(Data).GetAwaiter().GetResult(); var basicProperties = channel.CreateBasicProperties(); basicProperties.Headers = new Dictionary <string, object>(); basicProperties.Headers.Add(nameof(AttemptCount), AttemptCount); basicProperties.Headers.Add(nameof(MaxAttempts), MaxAttempts); return(body, basicProperties); }
public MessageBuilder(IModel channel, IBusSerializer serializer) { _channel = channel; _serializer = serializer; }
protected internal virtual (byte[], IBasicProperties) GetData(IModel channel, IBusSerializer serializer) { var body = serializer.Serialize(Data); var basicProperties = channel.CreateBasicProperties(); basicProperties.Headers = new Dictionary <string, object> { { nameof(AttemptCount), AttemptCount }, { nameof(MaxAttempts), MaxAttempts }, { nameof(RequestKey), RequestKey } }; return(body, basicProperties); }