Beispiel #1
0
        string PublishOrder(string userOrderId, string orderDateString)
        {
            Connect();

            var order = new Order {
                UserOrderId = userOrderId, FixMessageType = "D"
            };
            var orderDate = DateTime.Parse(orderDateString);

            var sb = new StringBuilder(128);

            sb.Append(NmsSession.topicPrefix).Append(".");
            sb.Append(string.Format(@"{0:yyyyMMdd}", orderDate));
            sb.Append(".").Append(userOrderId);

            var producer    = CreateTopicProducer(NmsSession.topicPrefix + ".20090708." + userOrderId);
            var messageBody = MessageUtil.CreateMessage(order.ToDictionary());
            var textMessage = producer.CreateTextMessage(messageBody);

            producer.Send(textMessage);

            Disconnect();

            return(textMessage.NMSMessageId);
        }
Beispiel #2
0
        public ITextMessage SendMessageResponse(IDictionary <string, string> order)
        {
            var textMessage = session.CreateTextMessage(MessageUtil.CreateMessage(order));

            textMessage.NMSReplyTo = consumerQueue;

            Send(textMessage);
            return(textMessage);
        }
Beispiel #3
0
        public ITextMessage SendMessageResponse(IDictionary <string, string> order)
        {
            var textMessage = session.CreateTextMessage(MessageUtil.CreateMessage(order));

            textMessage.Properties.SetString("ReplyTo", replyTo);

            Send(textMessage);
            return(textMessage);
        }
Beispiel #4
0
        public void TestMessageCreateSimple()
        {
            var messageString = MessageUtil.CreateMessage("TestTopic", "fieldNameOne", "fieldValueOne");

            Assert.AreEqual(true, messageString.Contains("MSTimestamp"));
            Assert.AreEqual(true, messageString.Contains("MSTopicName"));
            Assert.AreEqual(true, messageString.Contains("TestTopic"));
            Assert.AreEqual(true, messageString.Contains("fieldNameOne"));
            Assert.AreEqual(true, messageString.Contains("fieldValueOne"));
        }
Beispiel #5
0
        public void TestMessageCreate()
        {
            IDictionary <string, string> testMessage = new SortedDictionary <string, string> {
                { "fieldNameOne", "fieldValueOne" },
                { "fieldNameTwo", "fieldValueTwo" },
                { "fieldNameThree", "fieldValueThree" },
                { "fieldNameFour", "fieldValueFour" }
            };

            var messageString = MessageUtil.CreateMessage(testMessage);

            Assert.AreEqual(MessageString, messageString.Substring(0, 113));
            Assert.AreEqual(true, messageString.Contains("MSTimestamp"));
        }
Beispiel #6
0
        void ProcessTestOrder()
        {
            Connect();
            var consumer = CreateQueueConsumer(FerCommandQueue);


            var textMessage = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;

            while (textMessage != null)
            {
                var record = MessageUtil.ExtractRecord(textMessage.Text);

                PrintLine("Processing test message: ", record);

                var replyTo = textMessage.NMSReplyTo;
                if (replyTo == null)
                {
                    Console.WriteLine("Received message without a 'ReplyTo' property");
                }
                else
                {
                    Console.WriteLine("ReplyTo=" + replyTo);
                }

                var producer             = CreateQueueProducer(replyTo);
                var originalNmsMessageID = textMessage.NMSMessageId;

                var response = record;

                response["STATUS"] = "SENT";

                var textResponse = CreateTextMessage(MessageUtil.CreateMessage(response));
                //textResponse.NMSCorrelationID = replyTo;

                textResponse.Properties.SetString("JmsOriginalMessageID", originalNmsMessageID);
                producer.Send(textResponse);
                producer.Dispose();
                //Console.WriteLine("Sent response:" + textResponse);

                textMessage = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
            }
            consumer.Dispose();

            Disconnect();
        }