public OrderEventsPublisher(IProducerConfiguration configuration) { _connectionLazy = new Lazy <IConnection>(() => CreateRabbitMqConnection(configuration)); _channelLazy = new Lazy <IModel>(() => _connectionLazy.Value.CreateModel()); _hasher = MD5.Create(); _configuration = configuration; }
public ProducerBase(IProducerConfiguration producerConfiguration, IEventSerializer eventSerializer) { _eventSerializer = eventSerializer; _configuration = producerConfiguration; _cancel = new CancellationTokenSource(); _state = new BehaviorSubject <ProducerState>(ProducerState.None); }
/// <summary> /// Construct a Producer class. /// </summary> /// <param name="router">The router used to direct produced messages to the correct partition.</param> /// <param name="configuration">The configuration parameters.</param> /// <param name="leaveRouterOpen">Whether to dispose the router when the producer is disposed.</param> /// <remarks> /// The <see cref="IProducerConfiguration.RequestParallelization"/> parameter provides a mechanism for minimizing the amount of /// async requests in flight at any one time by blocking the caller requesting the async call. This effectively puts an upper /// limit on the amount of times a caller can call SendMessagesAsync before the caller is blocked. /// /// The <see cref="IProducerConfiguration.BatchSize"/> parameter provides a way to limit the max amount of memory the driver uses /// should the send pipeline get overwhelmed and the buffer starts to fill up. This is an inaccurate limiting memory use as the /// amount of memory actually used is dependant on the general message size being buffered. /// /// A message will start its timeout countdown as soon as it is added to the producer async queue. If there are a large number of /// messages sitting in the async queue then a message may spend its entire timeout cycle waiting in this queue and never getting /// attempted to send to Kafka before a timeout exception is thrown. /// </remarks> public Producer(IRouter router, IProducerConfiguration configuration = null, bool leaveRouterOpen = true) { _leaveRouterOpen = leaveRouterOpen; Router = router; Configuration = configuration ?? ProducerConfiguration.Default; _produceMessageQueue = new AsyncProducerConsumerQueue <ProduceTask>(); _produceRequestSemaphore = new SemaphoreSlim(Configuration.RequestParallelization, Configuration.RequestParallelization); _sendTask = Task.Run(DedicatedSendAsync, _disposeToken.Token); }
public KafkaOptions(Uri kafkaServerUri = null, IConnectionConfiguration connectionConfiguration = null, IRouterConfiguration routerConfiguration = null, IConnectionFactory connectionFactory = null, IProducerConfiguration producerConfiguration = null, IConsumerConfiguration consumerConfiguration = null, ILog log = null) : this(ImmutableList <Uri> .Empty.AddNotNull(kafkaServerUri), connectionConfiguration, routerConfiguration, connectionFactory, producerConfiguration, consumerConfiguration, log) { }
/// <summary> /// Construct a Producer class. /// </summary> /// <param name="brokerRouter">The router used to direct produced messages to the correct partition.</param> /// <param name="configuration">The configuration parameters.</param> /// <param name="leaveRouterOpen">Whether to dispose the router when the producer is disposed.</param> /// <remarks> /// The <see cref="IProducerConfiguration.RequestParallelization"/> parameter provides a mechanism for minimizing the amount of /// async requests in flight at any one time by blocking the caller requesting the async call. This effectively puts an upper /// limit on the amount of times a caller can call SendMessagesAsync before the caller is blocked. /// /// The <see cref="IProducerConfiguration.BatchSize"/> parameter provides a way to limit the max amount of memory the driver uses /// should the send pipeline get overwhelmed and the buffer starts to fill up. This is an inaccurate limiting memory use as the /// amount of memory actually used is dependant on the general message size being buffered. /// /// A message will start its timeout countdown as soon as it is added to the producer async queue. If there are a large number of /// messages sitting in the async queue then a message may spend its entire timeout cycle waiting in this queue and never getting /// attempted to send to Kafka before a timeout exception is thrown. /// </remarks> public Producer(IBrokerRouter brokerRouter, IProducerConfiguration configuration = null, bool leaveRouterOpen = true) { _leaveRouterOpen = leaveRouterOpen; BrokerRouter = brokerRouter; Configuration = configuration ?? new ProducerConfiguration(); _produceMessageQueue = new AsyncProducerConsumerQueue <ProduceTopicTask>(); _produceRequestSemaphore = new SemaphoreSlim(Configuration.RequestParallelization, Configuration.RequestParallelization); _stopToken = new CancellationTokenSource(); _batchSendTask = Task.Run(BatchSendAsync, _stopToken.Token); }
private static IConnection CreateRabbitMqConnection(IProducerConfiguration configuration) { var factory = new ConnectionFactory() { HostName = configuration.RabbitMQHost, Port = configuration.RabbitMQPort, UserName = configuration.RabbitMQUser, Password = configuration.RabbitMQPass, }; return(factory.CreateConnection()); }
public KafkaOptions( Uri kafkaServerUri = null, IConnectionConfiguration connectionConfiguration = null, ICacheConfiguration cacheConfiguration = null, IConnectionFactory connectionFactory = null, IPartitionSelector partitionSelector = null, IProducerConfiguration producerConfiguration = null, IConsumerConfiguration consumerConfiguration = null, ILog log = null) : this(ImmutableList <Uri> .Empty.AddNotNull(kafkaServerUri), connectionConfiguration, cacheConfiguration, connectionFactory, partitionSelector, producerConfiguration, consumerConfiguration, log) { }
public KafkaOptions(IEnumerable <Uri> kafkaServerUris = null, IConnectionConfiguration connectionConfiguration = null, IRouterConfiguration routerConfiguration = null, IConnectionFactory connectionFactory = null, IProducerConfiguration producerConfiguration = null, IConsumerConfiguration consumerConfiguration = null, ILog log = null) { ServerUris = ImmutableList <Uri> .Empty.AddNotNullRange(kafkaServerUris); RouterConfiguration = routerConfiguration ?? KafkaClient.RouterConfiguration.Default; ConnectionConfiguration = connectionConfiguration ?? Connections.ConnectionConfiguration.Default; ConnectionFactory = connectionFactory ?? new ConnectionFactory(); ProducerConfiguration = producerConfiguration ?? KafkaClient.ProducerConfiguration.Default; ConsumerConfiguration = consumerConfiguration ?? KafkaClient.ConsumerConfiguration.Default; Log = log ?? TraceLog.Log; }
public Market(String name, IProducerConfiguration configuration, IEventSerializer eventSerializer, TimeSpan priceGenerationDelay) : base(configuration, eventSerializer) { _priceGenerationDelay = priceGenerationDelay; _name = name; _cancel = new CancellationTokenSource(); Prices = new List <ChangeCcyPairPrice>(); OnDestroyed += () => { _cancel.Cancel(); }; OnRunning += () => { _workProc = Task.Run(HandleWork, _cancel.Token).ConfigureAwait(false); }; }
public KafkaOptions( IEnumerable <Uri> kafkaServerUris = null, IConnectionConfiguration connectionConfiguration = null, ICacheConfiguration cacheConfiguration = null, IConnectionFactory connectionFactory = null, IPartitionSelector partitionSelector = null, IProducerConfiguration producerConfiguration = null, IConsumerConfiguration consumerConfiguration = null, ILog log = null) { ServerUris = ImmutableList <Uri> .Empty.AddNotNullRange(kafkaServerUris); CacheConfiguration = cacheConfiguration ?? new CacheConfiguration(); ConnectionConfiguration = connectionConfiguration ?? new ConnectionConfiguration(); ConnectionFactory = connectionFactory ?? new ConnectionFactory(); PartitionSelector = partitionSelector ?? new PartitionSelector(); ProducerConfiguration = producerConfiguration ?? new ProducerConfiguration(); ConsumerConfiguration = consumerConfiguration ?? new ConsumerConfiguration(); Log = log ?? TraceLog.Log; }
public SchemaProducerFactory(SchemaSerializerProvider schemaSerializerProvider, IProducerConfiguration producerConfiguration) { _schemaSerializerProvider = schemaSerializerProvider; _producerConfiguration = producerConfiguration; _list = new ConcurrentDictionary <string, IDisposable>(); }
public TransactionCommandProducer(EnvironmentContext env, IProducerConfiguration configuration) : base(new TransactionCommandsTopicV1(env.Environment), configuration) { }