Exemple #1
0
        private Procucer(string customerId, string address)
        {
            instance = this;
            //创建工厂
            IConnectionFactory _factory = new ConnectionFactory("tcp://127.0.0.1:61616/");

            try
            {
                //创建连接
                IConnection _connection = _factory.CreateConnection();
                {
                    //创建会话
                    ISession session = _connection.CreateSession();
                    {
                        //创建一个主题
                        IDestination destination = new Apache.NMS.ActiveMQ.Commands.ActiveMQTopic("topic");

                        //创建生产者
                        producer = session.CreateProducer(destination);

                        Console.WriteLine("Please enter any key to continue! ");
                        //  Console.ReadKey();
                        Console.WriteLine("Sending: ");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            //Console.ReadLine();
        }
Exemple #2
0
 public static Procucer GetInstance(string customerId = "", string address = "tcp://127.0.0.1:61616/")
 {
     if (instance == null)
     {
         instance = new Procucer(customerId, address);
     }
     return(instance);
 }