コード例 #1
0
    static void Main(string[] args)
    {
        BoundedBuffer boundedBuffer = new BoundedBuffer();

        MyProducer prod           = new MyProducer(boundedBuffer, 20);
        Thread     producerThread = prod.CreateProducerThread();

        MyConsumer cons           = new MyConsumer(boundedBuffer, 20);
        Thread     consumerThread = cons.CreateConsumerThread();

        producerThread.Start();
        consumerThread.Start();

        Console.ReadLine();
    }
コード例 #2
0
ファイル: Service1.cs プロジェクト: Li-Yanzhi/kafkatest
        protected override void OnStart(string[] args)
        {
            Task.Factory.StartNew(async() =>
            {
                var dir        = AppDomain.CurrentDomain.BaseDirectory;
                var myProducer = new MyProducer("10.0.0.6:9092", "MyTopic", $"{dir}\\kafka.log", $"{dir}\\app.log");
                int i          = 1;
                while (true)
                {
                    await myProducer.SendMessage(i.ToString());

                    i++;
                    await Task.Delay(5000);
                }
            });
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Li-Yanzhi/kafkatest
        static async Task Main(string[] args)
        {
            var dir        = AppDomain.CurrentDomain.BaseDirectory;
            var myProducer = new MyProducer("10.0.0.6:9092", "MyTopic", $"{dir}\\kafka.log", $"{dir}\\app.log");
            int i          = 1;

            Console.WriteLine("Sending message, please check out the log file. Press CTRL+C to exit.");
            while (true)
            {
                await myProducer.SendMessage(i.ToString());

                i++;
                await Task.Delay(5000);

                ;
            }
        }
コード例 #4
0
        public async Task GrainShouldSuccessfullyPullFromClientObject()
        {
            var myOb = new MyProducer();

            this.anchor = myOb;
            var myRef    = await((GrainFactory)GrainClient.GrainFactory).CreateObjectReference <IClientAddressableTestProducer>(myOb);
            var rendez   = GrainClient.GrainFactory.GetGrain <IClientAddressableTestRendezvousGrain>(0);
            var consumer = GrainClient.GrainFactory.GetGrain <IClientAddressableTestConsumer>(0);

            await rendez.SetProducer(myRef);

            await consumer.Setup();

            var n = await consumer.PollProducer();

            Assert.AreEqual(1, n);

            await GrainReference.DeleteObjectReference(myRef);
        }
コード例 #5
0
ファイル: ClickHub.cs プロジェクト: gilsdav/aw-kafka
 public ClickHub(MyProducer _myProducer)
 {
     this.myProducer        = _myProducer;
     this.askHistorySubject = new Subject <string>();
 }
コード例 #6
0
        public async Task GrainShouldSuccessfullyPullFromClientObject()
        {
            var myOb = new MyProducer();
            this.anchor = myOb;
            var myRef = await ((GrainFactory)GrainClient.GrainFactory).CreateObjectReference<IClientAddressableTestProducer>(myOb);
            var rendez = GrainClient.GrainFactory.GetGrain<IClientAddressableTestRendezvousGrain>(0);
            var consumer = GrainClient.GrainFactory.GetGrain<IClientAddressableTestConsumer>(0);

            await rendez.SetProducer(myRef);
            await consumer.Setup();
            var n = await consumer.PollProducer();
            Assert.AreEqual(1, n);

            await GrainReference.DeleteObjectReference(myRef);
        }