Пример #1
0
        public Producer(
            Guid correlationId,
            Uri serviceUrl,
            string topic,
            ulong initialSequenceId,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state,
            IProducerChannelFactory factory,
            ISchema <TMessage> schema)
        {
            var messageMetadataPolicy = new DefaultPooledObjectPolicy <PulsarApi.MessageMetadata>();

            _messageMetadataPool = new DefaultObjectPool <PulsarApi.MessageMetadata>(messageMetadataPolicy);
            _correlationId       = correlationId;
            ServiceUrl           = serviceUrl;
            Topic          = topic;
            _sequenceId    = new SequenceId(initialSequenceId);
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _factory       = factory;
            _schema        = schema;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId));
        }
Пример #2
0
 public Producer(
     Uri serviceUrl,
     ProducerOptions <TMessage> options,
     ProcessManager processManager,
     IHandleException exceptionHandler,
     IConnectionPool connectionPool,
     ICompressorFactory?compressorFactory)
 {
     _operationName = $"{options.Topic} send";
     _tags          = new KeyValuePair <string, object?>[]
     {
         new KeyValuePair <string, object?>("messaging.destination", options.Topic),
         new KeyValuePair <string, object?>("messaging.destination_kind", "topic"),
         new KeyValuePair <string, object?>("messaging.system", "pulsar"),
         new KeyValuePair <string, object?>("messaging.url", serviceUrl),
     };
     _sequenceId        = new SequenceId(options.InitialSequenceId);
     _state             = new StateManager <ProducerState>(ProducerState.Disconnected, ProducerState.Closed, ProducerState.Faulted);
     ServiceUrl         = serviceUrl;
     Topic              = options.Topic;
     _isDisposed        = 0;
     _options           = options;
     _exceptionHandler  = exceptionHandler;
     _connectionPool    = connectionPool;
     _compressorFactory = compressorFactory;
     _processManager    = processManager;
     _messageRouter     = options.MessageRouter;
     _cts       = new CancellationTokenSource();
     _executor  = new Executor(Guid.Empty, this, _exceptionHandler);
     _producers = new ConcurrentDictionary <int, SubProducer <TMessage> >();
     _          = Setup();
 }
Пример #3
0
 public ProducerStreamFactory(ConnectionPool connectionPool, ProducerOptions options, IFaultStrategy faultStrategy)
 {
     _connectionPool = connectionPool;
     _options        = options;
     _faultStrategy  = faultStrategy;
     _sequenceId     = new SequenceId(options.InitialSequenceId);
 }
Пример #4
0
 public ProducerChannel(ulong id, string name, SequenceId sequenceId, IConnection connection)
 {
     _cachedMetadata = new MessageMetadata {
         ProducerName = name
     };
     _sendPackagePool = new DefaultObjectPool <SendPackage>(new DefaultPooledObjectPolicy <SendPackage>());
     _id         = id;
     _name       = name;
     _sequenceId = sequenceId;
     _connection = connection;
 }
Пример #5
0
        public ProducerChannel(ulong id, string name, SequenceId sequenceId, IConnection connection)
        {
            _cachedMetadata = new MessageMetadata {
                ProducerName = name
            };

            var commandSend = new CommandSend {
                ProducerId = id, NumMessages = 1
            };

            _cachedSendPackage = new SendPackage(commandSend, _cachedMetadata);

            _id         = id;
            _sequenceId = sequenceId;
            _connection = connection;
        }
Пример #6
0
        public ProducerChannelFactory(
            Guid correlationId,
            IRegisterEvent eventRegister,
            IConnectionPool connectionPool,
            IExecute executor,
            ProducerOptions options)
        {
            _correlationId  = correlationId;
            _eventRegister  = eventRegister;
            _connectionPool = connectionPool;
            _executor       = executor;
            _sequenceId     = new SequenceId(options.InitialSequenceId);

            _commandProducer = new CommandProducer
            {
                ProducerName = options.ProducerName,
                Topic        = options.Topic
            };
        }
Пример #7
0
        public ProducerStream(ulong id, string name, SequenceId sequenceId, Connection connection, IFaultStrategy faultStrategy, IProducerProxy proxy)
        {
            _cachedMetadata = new PulsarApi.MessageMetadata
            {
                ProducerName = name
            };

            var commandSend = new CommandSend
            {
                ProducerId  = id,
                NumMessages = 1
            };

            _cachedSendPackage = new SendPackage(commandSend, _cachedMetadata);

            _id            = id;
            _sequenceId    = sequenceId;
            _connection    = connection;
            _faultStrategy = faultStrategy;
            _proxy         = proxy;
        }
Пример #8
0
        public Producer(
            Guid correlationId,
            string topic,
            ulong initialSequenceId,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state)
        {
            var messageMetadataPolicy = new DefaultPooledObjectPolicy <PulsarApi.MessageMetadata>();

            _messageMetadataPool = new DefaultObjectPool <PulsarApi.MessageMetadata>(messageMetadataPolicy);
            _correlationId       = correlationId;
            Topic          = topic;
            _sequenceId    = new SequenceId(initialSequenceId);
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId, this));
        }