Exemple #1
0
 public void Publish(RabbitMqPublisherSettings settings, IModel channel, byte[] body)
 {
     channel.BasicPublish(exchange: _exchangeName ?? settings.ExchangeName,
                          routingKey: _queue,//remove
                          basicProperties: null,
                          body: body);
 }
        public void ConfigureServices(ContainerBuilder builder, ILog log)
        {
            var mq = settings.BrokerQuoteFeed.RabbitMq;
            var connectionsString  = $"amqp://{mq.Username}:{mq.Password}@{mq.Host}:{mq.Port}";
            var subscriberSettings = new RabbitMqSubscriberSettings()
            {
                ConnectionString = connectionsString,
                QueueName        = mq.ExchangeOrderbook + ".quotefeedbroker",
                ExchangeName     = mq.ExchangeOrderbook,
                IsDurable        = true
            };
            var publisherSettings = new RabbitMqPublisherSettings
            {
                ConnectionString = connectionsString,
                ExchangeName     = mq.QuoteFeed
            };

            var subscriber = new RabbitMqSubscriber <OrderBook>(subscriberSettings);
            var publisher  = new RabbitMqPublisher <Quote>(publisherSettings);
            var broker     = new Broker(subscriber, publisher, log);

            builder.RegisterInstance(subscriber)
            .As <IStartable>()
            .As <IStopable>();

            builder.RegisterInstance(publisher)
            .As <IStartable>()
            .As <IStopable>();
        }
Exemple #3
0
        public static void RegisterRabbitQueue(this IServiceCollection services, IBaseSettings settings, ILog logger, string exchangePrefix = "")
        {
            string exchangeName     = exchangePrefix + settings.RabbitMq.ExchangeEthereumCore;
            string connectionString = $"amqp://{settings.RabbitMq.Username}:{settings.RabbitMq.Password}@{settings.RabbitMq.Host}:{settings.RabbitMq.Port}";

            #region Default

            RabbitMqPublisherSettings rabbitMqDefaultSettings = new RabbitMqPublisherSettings
            {
                ConnectionString = connectionString,
                ExchangeName     = exchangeName
            };

            RabbitMqPublisher <string> publisher = new RabbitMqPublisher <string>(rabbitMqDefaultSettings)
                                                   .SetSerializer(new BytesSerializer())
                                                   .SetPublishStrategy(new PublishStrategy(settings.RabbitMq.RoutingKey))
                                                   .SetLogger(logger)
                                                   .Start();

            #endregion

            #region Hotwallet

            RabbitMqPublisherSettings rabbitMqHotwalletSettings = new RabbitMqPublisherSettings
            {
                ConnectionString = connectionString,
                ExchangeName     = $"{exchangeName}.hotwallet"
            };

            RabbitMqPublisher <HotWalletEvent> hotWalletCashoutEventPublisher = new RabbitMqPublisher <HotWalletEvent>(rabbitMqHotwalletSettings)
                                                                                .SetSerializer(new BytesSerializer <HotWalletEvent>())
                                                                                .SetPublishStrategy(new PublishStrategy(settings.RabbitMq.RoutingKey))
                                                                                .SetLogger(logger)
                                                                                .Start();

            #endregion

            services.AddSingleton <IMessageProducer <string> >(publisher);
            services.AddSingleton <IMessageProducer <HotWalletEvent> >(hotWalletCashoutEventPublisher);
            services.AddSingleton <IRabbitQueuePublisher, RabbitQueuePublisher>();
        }
Exemple #4
0
        public static void RegisterHistoryOperationPublisher(this ContainerBuilder builder,
                                                             RabbitMqPublisherSettings settings)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            builder.RegisterType <HistoryOperationPublisher>()
            .AsSelf()
            .As <IStartable>()
            .As <IStopable>()
            .AutoActivate()
            .SingleInstance()
            .UsingConstructor(typeof(RabbitMqPublisherSettings), typeof(ILogFactory))
            .WithParameter("settings", settings);
        }
 public OrderBookPublisher(RabbitMqPublisherSettings settings, ILogFactory logFactory)
 {
     _settings   = settings;
     _logFactory = logFactory;
 }
Exemple #6
0
 public void Configure(RabbitMqPublisherSettings settings, IModel channel)
 {
     channel.ExchangeDeclare(exchange: _exchangeName ?? settings.ExchangeName, type: ExchangeType.Fanout, durable: true);
 }
Exemple #7
0
 public TickPricePublisher(RabbitMqPublisherSettings settings, ILogFactory logFactory)
 {
     _settings   = settings;
     _logFactory = logFactory;
 }