static void Main(string[] args) { Core core1 = new Core(); var consumerConfig = new QueueConfig { ExchangeName = "engine-in", ExchangeType = "fanout", QueueName = "engine-reader", RoutingKey = "#", HostName = "localhost", Vhost = "/", User = "******", Password = "******" }; var producerConfig = new QueueConfig { ExchangeName = "engine-out", ExchangeType = "fanout", QueueName = "settlement", RoutingKey = "#", HostName = "localhost", Vhost = "/", User = "******", Password = "******" }; core1.Start(consumerConfig, producerConfig, "output.bin", new TimeProvider(), 0, 1); Console.ReadLine(); core1.Stop(); }
public void Start(QueueConfig consumerQueuConfig, QueueConfig producerQueueConfig, string filePath, ITimeProvider timeProvider, int quoteCurrencyDecimalPlances, int stepSize) { _outboundChannel = Channel.CreateBounded <byte[]>(new BoundedChannelOptions(100000) { FullMode = BoundedChannelFullMode.Wait, SingleReader = true, SingleWriter = true, AllowSynchronousContinuations = false }); _outboundChannelReader = _outboundChannel.Reader; _outboundChannelWritter = _outboundChannel.Writer; var tradeListner = new TradeListener(_outboundChannelWritter, timeProvider); _matchingEngine = new MatchingEngine(quoteCurrencyDecimalPlances, stepSize, tradeListner, new TimeProvider()); _inboundChannel = Channel.CreateBounded <Message>(new BoundedChannelOptions(100000) { FullMode = BoundedChannelFullMode.Wait, SingleReader = true, SingleWriter = true, AllowSynchronousContinuations = false }); _inboundChannelReader = _inboundChannel.Reader; _inboundChannelWritter = _inboundChannel.Writer; _outboundQueueChannel = Channel.CreateBounded <byte[]>(new BoundedChannelOptions(100000) { FullMode = BoundedChannelFullMode.Wait, SingleReader = true, SingleWriter = true, AllowSynchronousContinuations = false }); _outboundQueueChannelReader = _outboundQueueChannel.Reader; _outboundQueueChannelWritter = _outboundQueueChannel.Writer; _outboundFileChannel = Channel.CreateBounded <byte[]>(new BoundedChannelOptions(100000) { FullMode = BoundedChannelFullMode.Wait, SingleReader = true, SingleWriter = true, AllowSynchronousContinuations = false }); _outboundFileChannelReader = _outboundFileChannel.Reader; _outboundFileChannelWritter = _outboundFileChannel.Writer; _tradeLogger = new TradeLogger(filePath); _queueProducer = new QueueProducer(producerQueueConfig.ExchangeName, producerQueueConfig.ExchangeType, producerQueueConfig.QueueName, producerQueueConfig.RoutingKey, producerQueueConfig.HostName, producerQueueConfig.Vhost, producerQueueConfig.User, producerQueueConfig.Password); _queueConsumer = new QueueConsumer(consumerQueuConfig.ExchangeName, consumerQueuConfig.ExchangeType, consumerQueuConfig.QueueName, consumerQueuConfig.RoutingKey, consumerQueuConfig.HostName, consumerQueuConfig.Vhost, consumerQueuConfig.User, consumerQueuConfig.Password); _inboundQueueProcessor = Task.Factory.StartNew(QueueConsumer); _inboundChannelProcessor = Task.Factory.StartNew(async() => await InboundMessageProcessor()); _outboundChannelProcessor = Task.Factory.StartNew(async() => await OutboundMessageProcessor()); _outboundQueueChannelProcessor = Task.Factory.StartNew(async() => await OutboundQueueMessageProcessor()); _outboundFileChannelProcessor = Task.Factory.StartNew(async() => await OutboundFileMessageProcessor()); }