/// <summary>
        /// Sends TradeHub Inquiry Message to MQ Exchange on the depending routing key
        /// </summary>
        /// <param name="inquiry">TradeHub Inquiry Message</param>
        public void SendInquiryMessage(InquiryMessage inquiry)
        {
            try
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("Inquiry message recieved for publishing", _type.FullName, "SendInquiryMessage");
                }

                string routingKey;
                if (_peMqServerParameters.TryGetValue("InquiryRoutingKey", out routingKey))
                {
                    Message <InquiryMessage> inquiryMessage = new Message <InquiryMessage>(inquiry);
                    inquiryMessage.Properties.AppId   = _applicationId;
                    inquiryMessage.Properties.ReplyTo = _clientMqParameters["InquiryResponseRoutingKey"];

                    // Send Message for publishing
                    PublishMessages(inquiryMessage, routingKey);
                }
                else
                {
                    Logger.Info("Inquiry message not sent for publishing as routing key is unavailable.", _type.FullName,
                                "SendInquiryMessage");
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "SendInquiryMessage");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Requests Order Execution Engine for Unique Application ID
        /// </summary>
        private void RequestAppId()
        {
            try
            {
                try
                {
                    InquiryMessage inquiry = new InquiryMessage();
                    inquiry.Type = TradeHubConstants.InquiryTags.AppID;

                    if (_asyncClassLogger.IsDebugEnabled)
                    {
                        _asyncClassLogger.Debug("Sending inquiry request message for: " + inquiry.Type, _type.FullName,
                                                "RequestAppId");
                    }

                    // Send Message through the MQ Server
                    _mqServer.SendInquiryMessage(inquiry);
                }
                catch (Exception exception)
                {
                    _asyncClassLogger.Error(exception, _type.FullName, "RequestAppId");
                }
            }
            catch (Exception exception)
            {
                _asyncClassLogger.Error(exception, _type.FullName, "RequestAppId");
            }
        }
Beispiel #3
0
        public void RequestNewStrategyIdTestCase()
        {
            InquiryMessage inquiryMessage = new InquiryMessage()
            {
                Type = Constants.InquiryTags.AppID
            };
            Message <InquiryMessage> message = new Message <InquiryMessage>(inquiryMessage);

            var manualInquiryEvent = new ManualResetEvent(false);

            bool inquiryArrived = false;

            message.Properties.AppId   = "test_app_id";
            message.Properties.ReplyTo = "inquiry.strategy.key";

            _advancedBus.Consume <InquiryResponse>(
                _inquiryQueue, (msg, messageReceivedInfo) =>
                Task.Factory.StartNew(() =>
            {
                inquiryArrived = true;
                manualInquiryEvent.Set();
            }));

            //using (var channel = _advancedBus.OpenPublishChannel())
            {
                _advancedBus.Publish(_adminExchange, "marketdata.engine.inquiry", true, false, message);
            }
            manualInquiryEvent.WaitOne(9000, false);

            Assert.AreEqual(true, inquiryArrived);
        }
Beispiel #4
0
        /// <summary>
        /// Sends Inquiry Request to Market Data Engine to get given market data provider information
        /// </summary>
        /// <param name="marketDataProvider">Name of the market data provider for which to get details</param>
        public void SendInquiryRequest(string marketDataProvider)
        {
            try
            {
                if (_asyncClassLogger.IsDebugEnabled)
                {
                    _asyncClassLogger.Debug("Sending Inquiry request message for: " + marketDataProvider, _type.FullName,
                                            "SendInquiryRequest");
                }

                InquiryMessage inquiryMessage = new InquiryMessage();
                inquiryMessage.Type = TradeConstants.InquiryTags.MarketDataProviderInfo;
                inquiryMessage.MarketDataProvider = marketDataProvider;

                // Send message though the Mq Server
                _mqServer.SendInquiryMessage(inquiryMessage);
            }
            catch (Exception exception)
            {
                _asyncClassLogger.Error(exception, _type.FullName, "SendInquiryRequest");
            }
        }