コード例 #1
0
ファイル: Program.cs プロジェクト: lilongsswang/dotnetmq
        static void Main()
        {
            //Create MDSClient object to connect to DotNetMQ
            //Name of this application: Application1
            var mdsClient = new MDSClient("Application1");

            //Connect to DotNetMQ server
            mdsClient.Connect();

            Console.WriteLine("Write a text and press enter to send to Application2. Write 'exit' to stop application.");

            while (true)
            {
                //Get a message from user
                var messageText = Console.ReadLine();
                if (string.IsNullOrEmpty(messageText) || messageText == "exit")
                {
                    break;
                }

                //Create a DotNetMQ Message to send to Application2
                var message = mdsClient.CreateMessage();
                //Set destination application name
                message.DestinationApplicationName = "Application2";
                //message.DestinationServerName = "this_server2";
                //Set message data
                message.MessageData = Encoding.UTF8.GetBytes(messageText);

                //Send message
                message.Send();
            }

            //Disconnect from DotNetMQ server
            mdsClient.Disconnect();
        }
コード例 #2
0
 public MQSendClient()
 {
     ServiceName = Utils.MQConfigHelper.MQQualityHelper.ServiceName;
     IpAddress = Utils.MQConfigHelper.MQQualityHelper.Ip;
     Port = Utils.MQConfigHelper.MQQualityHelper.Port;
     client = new MDSClient(ServiceName, IpAddress, Port);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: lilongsswang/dotnetmq
        static void Main(string[] args)
        {
            var mdsClient = new MDSClient("StockServer");
            mdsClient.MessageReceived += MDSClient_MessageReceived;

            mdsClient.Connect();

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();

            mdsClient.Disconnect();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            MDSClient mdsClient = new MDSClient(Utils.MQConfigHelper.MQQualityHelper.ServiceName,
                Utils.MQConfigHelper.MQQualityHelper.Ip, Utils.MQConfigHelper.MQQualityHelper.Port);

            mdsClient.MessageReceived += new MessageReceivedHandler(mdsClient_MessageReceived);

            mdsClient.Connect();

            Console.WriteLine("按回车键退出");
            Console.ReadLine();

            mdsClient.Disconnect();
        }
コード例 #5
0
ファイル: MDSClient.cs プロジェクト: windsonxp/DotNetMQ-1
            /// <summary>
            /// Creates a new IncomingDataMessage object from a MDSDataTransferMessage object.
            /// </summary>
            /// <param name="client">Reference to the MDSClient object</param>
            /// <param name="message">MDSDataTransferMessage object to create IncomingDataMessage</param>
            public IncomingDataMessage(MDSClient client, MDSDataTransferMessage message)
            {
                _client = client;

                DestinationApplicationName = message.DestinationApplicationName;
                DestinationCommunicatorId  = message.DestinationCommunicatorId;
                DestinationServerName      = message.DestinationServerName;
                MessageData           = message.MessageData;
                MessageId             = message.MessageId;
                PassedServers         = message.PassedServers;
                RepliedMessageId      = message.RepliedMessageId;
                SourceApplicationName = message.SourceApplicationName;
                SourceCommunicatorId  = message.SourceCommunicatorId;
                SourceServerName      = message.SourceServerName;
                TransmitRule          = message.TransmitRule;
            }
コード例 #6
0
ファイル: Program.cs プロジェクト: lilongsswang/dotnetmq
        static void Main(string[] args)
        {
            //Create MDSClient object to connect to DotNetMQ
            //Name of this application: Application2
            var mdsClient = new MDSClient("Application2");

            //Register to MessageReceived event to get messages.
            mdsClient.MessageReceived += MDSClient_MessageReceived;

            //Connect to DotNetMQ server
            mdsClient.Connect();

            //Wait user to press enter to terminate application
            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();

            //Disconnect from DotNetMQ server
            mdsClient.Disconnect();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: lilongsswang/dotnetmq
        static void Main(string[] args)
        {
            Console.WriteLine("Press enter to query a stock status");
            Console.ReadLine();

            //Connect to DotNetMQ
            var mdsClient = new MDSClient("StockClient");
            mdsClient.MessageReceived += mdsClient_MessageReceived;
            mdsClient.Connect();

            //Create a stock request message
            var stockQueryMessage = new StockQueryMessage { StockCode = "S01" };
            
            //Create a MDS message
            var requestMessage = mdsClient.CreateMessage();
            requestMessage.DestinationApplicationName = "StockServer";
            requestMessage.TransmitRule = MessageTransmitRules.NonPersistent;
            requestMessage.MessageData = GeneralHelper.SerializeObject(stockQueryMessage);

            //Send message and get response
            var responseMessage = requestMessage.SendAndGetResponse();

            //Get stock query result message from response message
            var stockResult = (StockQueryResultMessage) GeneralHelper.DeserializeObject(responseMessage.MessageData);

            //Write stock query result
            Console.WriteLine("StockCode          = " + stockResult.StockCode);
            Console.WriteLine("ReservedStockCount = " + stockResult.ReservedStockCount);
            Console.WriteLine("TotalStockCount    = " + stockResult.TotalStockCount);

            //Acknowledge received message
            responseMessage.Acknowledge();

            Console.ReadLine();

            //Disconnect from DotNetMQ server.
            mdsClient.Disconnect();
        }
コード例 #8
0
ファイル: MDSClient.cs プロジェクト: windsonxp/DotNetMQ-1
 /// <summary>
 /// Creates a new OutgoingDataMessage object.
 /// </summary>
 /// <param name="client">Reference to the MDSClient object</param>
 public OutgoingDataMessage(MDSClient client)
 {
     _client = client;
 }
コード例 #9
0
ファイル: MDSClient.cs プロジェクト: yonglehou/dotnetmq
 /// <summary>
 /// Creates a new OutgoingDataMessage object.
 /// </summary>
 /// <param name="client">Reference to the MDSClient object</param>
 public OutgoingDataMessage(MDSClient client)
 {
     _client = client;
 }
コード例 #10
0
ファイル: MDSClient.cs プロジェクト: yonglehou/dotnetmq
            /// <summary>
            /// Creates a new IncomingDataMessage object from a MDSDataTransferMessage object.
            /// </summary>
            /// <param name="client">Reference to the MDSClient object</param>
            /// <param name="message">MDSDataTransferMessage object to create IncomingDataMessage</param>
            public IncomingDataMessage(MDSClient client, MDSDataTransferMessage message)
            {
                _client = client;

                DestinationApplicationName = message.DestinationApplicationName;
                DestinationCommunicatorId = message.DestinationCommunicatorId;
                DestinationServerName = message.DestinationServerName;
                MessageData = message.MessageData;
                MessageId = message.MessageId;
                PassedServers = message.PassedServers;
                RepliedMessageId = message.RepliedMessageId;
                SourceApplicationName = message.SourceApplicationName;
                SourceCommunicatorId = message.SourceCommunicatorId;
                SourceServerName = message.SourceServerName;
                TransmitRule = message.TransmitRule;
            }
コード例 #11
0
 public MQSendClient(string serviceName, string ip, int port)
 {
     client = new MDSClient(serviceName, ip, port);
 }