protected ProducerActorBase(IActorRef client, IActorRef lookup, IActorRef cnxPool, string topic, ProducerConfigurationData conf, ISchema <T> schema, ProducerInterceptors <T> interceptors, ClientConfigurationData configurationData) { ClientConfiguration = configurationData; Client = client; _topic = topic; if (conf.BatchingEnabled && conf.AckReceivedListerner == null) { conf.AckReceivedListerner = (acked) => { Context.System.Log.Info($"AckReceived(ledger-id:{acked.LedgerId}, entery-id:{acked.EntryId}, sequence-id:{acked.SequenceId}, highest-sequence-id:{acked.HighestSequenceId})"); }; } Conf = conf; Schema = schema; Interceptors = interceptors; SchemaCache = new Dictionary <SchemaHash, byte[]>(); if (!conf.MultiSchema) { _multiSchemaMode = MultiSchemaMode.Disabled; } var pName = ProducerName().GetAwaiter().GetResult(); State = new HandlerState(lookup, cnxPool, topic, Context.System, pName); }
public ConnectionHandler(ClientConfigurationData conf, HandlerState state, Backoff backoff, IActorRef connection) { _state = state; _connection = connection; _backoff = backoff; _log = Context.System.Log; _actorContext = Context; _conf = conf; Listening(); }
public ConsumerActorBase(IActorRef stateActor, IActorRef lookup, IActorRef connectionPool, string topic, ConsumerConfigurationData <T> conf, int receiverQueueSize, IAdvancedScheduler listenerExecutor, ISchema <T> schema) { if (conf.Interceptors != null && conf.Interceptors.Count > 0) { Interceptors = new ConsumerInterceptors <T>(Context.System, conf.Interceptors); } StateActor = stateActor; _topic = topic; _consumerName = conf.ConsumerName ?? Utility.ConsumerName.GenerateRandomName(); State = new HandlerState(lookup, connectionPool, topic, Context.System, _consumerName); _log = Context.GetLogger(); MaxReceiverQueueSize = receiverQueueSize; _subscription = conf.SubscriptionName; Conf = conf; Listener = conf.MessageListener; ConsumerEventListener = conf.ConsumerEventListener; IncomingMessages = new BufferBlock <IMessage <T> >(); UnAckedChunckedMessageIdSequenceMap = Context.ActorOf(Tracker.UnAckedChunckedMessageIdSequenceMap.Prop()); ListenerExecutor = listenerExecutor; Schema = schema; if (conf.BatchReceivePolicy != null) { var userBatchReceivePolicy = conf.BatchReceivePolicy; if (userBatchReceivePolicy.MaxNumMessages > MaxReceiverQueueSize) { BatchReceivePolicy = new BatchReceivePolicy.Builder().MaxNumMessages(MaxReceiverQueueSize).MaxNumBytes(userBatchReceivePolicy.MaxNumBytes).Timeout((int)userBatchReceivePolicy.TimeoutMs).Build(); _log.Warning($"BatchReceivePolicy maxNumMessages: {userBatchReceivePolicy.MaxNumMessages} is greater than maxReceiverQueueSize: {MaxReceiverQueueSize}, reset to maxReceiverQueueSize. batchReceivePolicy: {BatchReceivePolicy}"); } else if (userBatchReceivePolicy.MaxNumMessages <= 0 && userBatchReceivePolicy.MaxNumBytes <= 0) { BatchReceivePolicy = new BatchReceivePolicy.Builder().MaxNumMessages(BatchReceivePolicy.DefaultPolicy.MaxNumMessages).MaxNumBytes(BatchReceivePolicy.DefaultPolicy.MaxNumBytes).Timeout((int)userBatchReceivePolicy.TimeoutMs).Build(); _log.Warning("BatchReceivePolicy maxNumMessages: {} or maxNumBytes: {} is less than 0. " + "Reset to DEFAULT_POLICY. batchReceivePolicy: {}", userBatchReceivePolicy.MaxNumMessages, userBatchReceivePolicy.MaxNumBytes, BatchReceivePolicy.ToString()); } else { BatchReceivePolicy = conf.BatchReceivePolicy; } } else { BatchReceivePolicy = BatchReceivePolicy.DefaultPolicy; } if (BatchReceivePolicy.TimeoutMs > 0) { //BatchReceiveTimeout = ListenerExecutor.ScheduleOnceCancelable(TimeSpan.FromMilliseconds(TimeUnit.MILLISECONDS.ToMilliseconds(BatchReceivePolicy.TimeoutMs)), PendingBatchReceiveTask); } _stateUpdater = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), Self, SendState.Instance, ActorRefs.NoSender); }
public static Props Prop(ClientConfigurationData conf, HandlerState state, Backoff backoff, IActorRef connection) { return(Props.Create(() => new ConnectionHandler(conf, state, backoff, connection))); }