コード例 #1
0
ファイル: Consumer.cs プロジェクト: jjzhang166/zbus-api
        public static void Main(string[] args)
        {
            SingleBrokerConfig config = new SingleBrokerConfig();

            config.brokerAddress = "127.0.0.1:15555";
            Broker broker = new SingleBroker(config);


            Consumer c = new Consumer(broker, "MyMQ");

            while (true)
            {
                Message msg = c.Recv(30000);
                if (msg == null)
                {
                    continue;
                }

                System.Console.WriteLine(msg);
            }

            c.Dispose();
            broker.Dispose();
            Console.ReadKey();
        }
コード例 #2
0
ファイル: Service.cs プロジェクト: jjzhang166/zbus-api
        public static void Main(string[] args)
        {
            SingleBrokerConfig config = new SingleBrokerConfig();

            config.brokerAddress = "127.0.0.1:15555";
            Broker broker = new SingleBroker(config);

            ServiceConfig serviceConfig = new ServiceConfig(broker);

            serviceConfig.mq             = "MyService";
            serviceConfig.serviceHandler = new MyServiceHandler();

            Service service = new Service(serviceConfig);

            service.Start();
        }
コード例 #3
0
ファイル: Producer.cs プロジェクト: jjzhang166/zbus-api
        public static void Main(string[] args)
        {
            SingleBrokerConfig config = new SingleBrokerConfig();

            config.brokerAddress = "127.0.0.1:15555";
            Broker broker = new SingleBroker(config);

            Producer producer = new Producer(broker, "MyMQ", MessageMode.MQ);

            producer.CreateMQ();

            Message msg = new Message();

            msg.SetBody("hello world from C# {0}", DateTime.Now);
            msg = producer.Send(msg, 10000);

            broker.Dispose();
            Console.ReadKey();
        }
コード例 #4
0
        public static void Main_Caller(string[] args)
        {
            SingleBrokerConfig config = new SingleBrokerConfig();

            config.brokerAddress = "127.0.0.1:15555";
            Broker broker = new SingleBroker(config);


            Caller c = new Caller(broker, "MyService");

            for (int i = 0; i < 1; i++)
            {
                Message msg = new Message();
                msg.SetBody("hello from C#");
                Message res = c.Invoke(msg, 2500);
                Console.WriteLine(res);
            }

            broker.Dispose();
            Console.ReadKey();
        }
コード例 #5
0
ファイル: Rpc.cs プロジェクト: jjzhang166/zbus-api
        public static void Main(string[] args)
        {
            SingleBrokerConfig brokerConfig = new SingleBrokerConfig();

            brokerConfig.brokerAddress = "127.0.0.1:15555";
            Broker broker = new SingleBroker(brokerConfig);

            RpcConfig config = new RpcConfig();

            config.mq     = "MyRpc";
            config.broker = broker;

            Rpc rpc = new Rpc(config);

            for (int i = 0; i < 100; i++)
            {
                object res = rpc.Invoke("stringArray");
                System.Console.WriteLine(res);
            }
            broker.Dispose();

            System.Console.ReadKey();
        }