コード例 #1
0
ファイル: Program.cs プロジェクト: doveyyang/2018Study
        static void Main(string[] args)
        {
            try
            {
                #region
                //{
                //    AdvisoryExample ex = new AdvisoryExample();

                //    // ex.EnumerateQueues();
                //    //ex.EnumerateTopics();
                //    ex.EnumerateDestinations();

                //    ex.ShutDown();
                //}
                //{
                //    ActiveMQTest test = new ActiveMQTest();
                //    test.Show();

                //}

                //http://blog.csdn.net/peterpan_hai/article/details/52354913

                #endregion

                var producer = new ActiveMQProducer();
                producer.BrokerUri = @"tcp://127.0.0.1:61616/";
                producer.UserName  = "******";
                producer.Password  = "******";
                //consumer.QueueName = "Queue_1";
                //consumer.MQMode = MQMode.Queue;
                producer.QueueName = "Topic_1";
                producer.MQMode    = MQMode.Topic;

                Console.WriteLine("打开ActiveMQ中...");
                producer.Open();
                Console.WriteLine("打开ActiveMQ完成.");
                var message = new BaseMessage()
                {
                    //初始化业务数据对象...
                    Opeation = "IN",
                    Result   = "Success"
                };
                //发送到队列, Put对象类必须使用[Serializable]注解属性
                producer.Put(message);
                Console.WriteLine("Send: " + message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var producer = new ActiveMQProducer();

            producer.BrokerUri = @"tcp://192.168.13.88:61616/";
            producer.UserName  = "******";
            producer.Password  = "******";
            producer.QueueName = "TestQueueName";
            producer.MQMode    = MQMode.Queue;

            producer.Open();
            var message = new DataCenterMessage()
            {
                customerid = "123", result = true
            };

            //发送到队列, Put对象类必须使用[Serializable]注解属性
            producer.Put(message);
        }
コード例 #3
0
        public static void TestProducer(string jsonData)
        {
            #region 发布
            var producer = new ActiveMQProducer();
            producer.BrokerUri = @"tcp://192.168.39.92:61616/";
            //producer.UserName = "******";
            //producer.Password = "******";
            producer.QueueName = "TestQueueName";
            producer.MQMode    = MQMode.Queue;

            //var message = new DataCenterMessage()
            //{
            //    ID = 1,
            //    OrderNumber = "2"
            //};
            producer.Open();
            producer.Put(jsonData);
            producer.Close();
            #endregion
        }