/// <summary> /// Converts incoming Limit order to Byte stream /// Sends to the singular order request sender function /// </summary> /// <param name="limitOrder">TradeHub LimitOrder</param> private void SendLimitOrderRequest(LimitOrder limitOrder) { // Convert MarketOrder to Byte Stream and pass it onto distuptor byte[] responseBytes = Encoding.UTF8.GetBytes(limitOrder.DataToPublish()); //SendOrderRequests(responseBytes); _sendOrderRequests(responseBytes); }
public void LimitOrderMessageTestCase() { Thread.Sleep(1000); bool limitOrderReceived = false; var limitOrderEvent = new ManualResetEvent(false); _executionMqServer.LimitOrderRequestRecieved += delegate(LimitOrder obj, string arg2) { limitOrderReceived = true; limitOrderEvent.Set(); Logger.Info("Limit Order Request receievd: " + obj, "MQServerTestCases", "ConsumeOrderRequestQueue"); }; LimitOrder limitOrder = new LimitOrder("01", "BUY", 10, "GTC", "EUR", new Security() { Symbol = "TEST" }, "TestCase"); limitOrder.LimitPrice = 100.0M; byte[] message = Encoding.UTF8.GetBytes("A00," + limitOrder.DataToPublish()); string corrId = Guid.NewGuid().ToString(); IBasicProperties replyProps = _rabbitMqOrderChannel.CreateBasicProperties(); replyProps.CorrelationId = corrId; // Publish Order Reqeusts to MQ Exchange _rabbitMqOrderChannel.BasicPublish("orderexecution_exchange", "orderexecution.engine.orderrequest", replyProps, message); //IMessage<LimitOrder> message = new Message<LimitOrder>(new LimitOrder("")); //_advancedBus.Publish(_adminExchange, "orderexecution.engine.limitorder", true, false, message); limitOrderEvent.WaitOne(10000, false); Assert.AreEqual(true, limitOrderReceived, "Limit Order Received"); }