コード例 #1
0
        public void BasicTests()
        {
            Client c = new Client(_projectId, _token);
            Queue q = c.queue("test-queue");

            ClearQueue(q);
            // clear_queue
            q.push("hello world!");
            Message msg = q.get();
            Assert.IsNotNull(msg.Id);
            Assert.IsNotNull(msg.Body);

            q.deleteMessage(msg.Id);
            msg = q.get();
            Assert.IsNull(msg);

            q.push("hello world 2!");

            msg = q.get();
            Assert.IsNotNull(msg);

            q.deleteMessage(msg.Id);

            msg = q.get();
            Assert.IsNull(msg);
        }
コード例 #2
0
        public void BasicTests()
        {
            var c = new Client(_credentials);
            var q = c.Queue("test-queue");

            ClearQueue(q);
            // clear_queue
            q.Enqueue("hello world!");
            var msg = q.Dequeue();
            Assert.IsNotNull(msg.Id);
            Assert.IsNotNull(msg.Body);

            q.Delete(msg.Id);
            msg = q.Dequeue();
            Assert.IsNull(msg);

            q.Enqueue("hello world 2!");

            msg = q.Dequeue();
            Assert.IsNotNull(msg);

            q.Delete(msg.Id);

            msg = q.Dequeue();
            Assert.IsNull(msg);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // run the exe
            // pesho
            // kiro
            // rerun the exe
            // kiro
            // pesho
            Console.WriteLine("Enter your chanel name: ");
            string senderChanelName = Console.ReadLine();

            Console.WriteLine("Enter chanel name for the user you want to chat with: ");
            string receiverChanelName = Console.ReadLine();

            Client client = new Client("520f6b22cd2e16000d00000c", "oC7j96AKY9NcuPfVpLOnZm-zTzU");
            Queue receiverChanel = client.queue(receiverChanelName);
            Queue senderChanel = client.queue(senderChanelName);

            Communicate communication = new Communicate(senderChanel, receiverChanel, senderChanelName);

            Thread sender = new Thread(new ThreadStart(communication.SendMessage));
            Thread receiver = new Thread(new ThreadStart(communication.GetMessage));

            sender.Start();
            receiver.Start();
        }
コード例 #4
0
ファイル: Spikes.cs プロジェクト: slieser/sandbox2
        public static void Main() {
            var credentials = CredentialsRepository.LoadFrom("appchatten.iron.io.credentials.txt", Assembly.GetExecutingAssembly());
            var client = new Client(credentials);
            var queue = client.Queue("spike");

            var producer = new Thread(() => {
                while(true) {
                    var s = Console.ReadLine();
                    if (s == "exit") {
                        return;
                    }
                    queue.Enqueue(s);
                }
            });

            var consumer = new Thread(() => {
                while(true) {
                    var message = queue.Dequeue();
                    if (message != null) {
                        Console.WriteLine(message.Body);
                        queue.Delete(message);
                    }
                    else {
                        Thread.Sleep(100);
                    }
                }
            });

            producer.Start();
            consumer.Start();

            Thread.Sleep(60000);
        }
コード例 #5
0
        public void Run()
        {
            var sut = new Client(CredentialsRepository.LoadFrom("ironmq.credentials.txt"));
            Console.WriteLine("1");

            var q = sut.Queue("monotest");
            Console.WriteLine("2");

            q.Enqueue("test");
            Console.WriteLine("3");
        }
コード例 #6
0
ファイル: Calculator.cs プロジェクト: appharbor/IronMQ-Sample
        public Calculator()
        {
            TaskScheduler.UnobservedTaskException += (sender, e) =>
            {
                e.SetObserved();
            };

            var _projectId = ConfigurationManager.AppSettings["IRON_MQ_PROJECT_ID"];
            var _token = ConfigurationManager.AppSettings["IRON_MQ_TOKEN"];

            _client = new Client(_projectId, _token);
        }
コード例 #7
0
        public void BulkGetTest()
        {
            var c = new Client(_credentials);
            var q = c.Queue("test-queue");
            ClearQueue(q);

            var messages = Enumerable.Range(0, 10).Select(i => i.ToString()).ToArray();
            const long timeout = 0;
            q.Enqueue(messages, timeout);

            var actual = q.Dequeue(100);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Count > 1);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: ralfw/iron_mq_dotnet
        static void Main(string[] args)
        {
            const string QUEUE_NAME = "batch_exercise";

            var cli = new Client(CredentialsRepository.LoadFrom("ironmq.credentials.txt"));
            var q = cli.Queue(QUEUE_NAME);

            q.Enqueue("hello " + DateTime.Now);
            var msg = q.Dequeue();

            Console.WriteLine(msg.Body);

            q.Delete(msg);
        }
コード例 #9
0
        static void Main(string[] args)
        {
            Client client = new Client("520f706527c7200005000001", "JySHBhogfvbKpQ8I5CkUFoY-FnI");

            Queue queue = client.queue("ChatQueue");

            Console.WriteLine("You can start entering messages:");

            while (true)
            {
                string msg = Console.ReadLine();
                queue.push(msg);
                Console.WriteLine("Message sent to IronMQ server.");
            }
        }
コード例 #10
0
 static void Main(string[] args)
 {
     Client client = new Client(
     "520f706527c7200005000001",
     "JySHBhogfvbKpQ8I5CkUFoY-FnI");
     Queue queue = client.queue("ChatQueue");
     Console.WriteLine("Listening for new messages from IronMQ server:");
     while (true)
     {
         Message msg = queue.get();
         if (msg != null)
         {
             Console.WriteLine(msg.Body);
             queue.deleteMessage(msg);
         }
         Thread.Sleep(100);
     }
 }
コード例 #11
0
        public static void Main()
        {
            var client = new Client("564a0cd24aa03100090000c3", "d9eQI5ueHbRdjXLdsr8r");
            var queue = client.queue("Last messages");

            Console.WriteLine("Listening for messages:");

            while (true)
            {
                var message = queue.get();
                if (message == null)
                {
                    continue;
                }

                Console.WriteLine(message.Body);
                queue.deleteMessage(message);
            }
        }
コード例 #12
0
        public static void Main()
        {
            Client client = new Client(
                "564191224aa03100070000c9",
                "SI9mlvuSEQqy6o7W5vip4SFNfx0");
            Queue queue = client.queue("Today's demo");

            Console.WriteLine("Listening for new messages from IronMQ server:");
            while (true)
            {
                Message msg = queue.get();
                if (msg != null)
                {
                    Console.WriteLine(msg.Body);
                    queue.deleteMessage(msg);
                }

                Thread.Sleep(100);
            }
        }
コード例 #13
0
ファイル: Receiver.cs プロジェクト: Gerya/TelerikAcademy
        static void Main(string[] args)
        {

            var projectId = ConfigurationManager.AppSettings["IRON_MQ_PROJECT_ID"];
            var token = ConfigurationManager.AppSettings["IRON_MQ_TOKEN"];
            var client = new Client(projectId, token);
            Queue queue = client.queue("simpleChat");
            Console.WriteLine("Listening for new messages from IronMQ server:");
                while (true)
                {
                    Message queueMsg = queue.get();

                    if (queueMsg != null)
                    {
                        ChatMsg msg = Newtonsoft.Json.JsonConvert.DeserializeObject<AppHarborIronMQ.Model.ChatMsg>(queueMsg.Body);
                        Console.WriteLine("New message from {0} : {1}", msg.Sender, msg.Text);
                        queue.deleteMessage(queueMsg);
                    }
                    Thread.Sleep(100);
                }
        }
コード例 #14
0
ファイル: Sender.cs プロジェクト: Gerya/TelerikAcademy
        static void Main(string[] args)
        {
            var projectId = ConfigurationManager.AppSettings["IRON_MQ_PROJECT_ID"];
            var token = ConfigurationManager.AppSettings["IRON_MQ_TOKEN"];
            var client = new Client(projectId, token);
            Queue queue = client.queue("simpleChat");
            Console.WriteLine("Please enter your name");
            string name = Console.ReadLine();
            Console.WriteLine("Send messages for IronMQ server:");
            while (true)
            {
                string text = Console.ReadLine();
                ChatMsg newMsg = new ChatMsg()
                {
                    Text = text,
                    Sender = name
                };

                queue.push(JsonConvert.SerializeObject(newMsg));
                Console.WriteLine("Message sent to the IronMQ server.");
            }
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: Cecosam/Csharp-Projects
 static void Main(string[] args)
 {
     Client client = new Client(
     "520a43c24ce3460009000006",
     "TWlNAHfIkmuTc-WPS32NeC9tm6c");
     Queue queue = client.queue("StanChatQueue");
     Console.WriteLine("Listening for new messages from IronMQ server:");
     while (true)
     {
         Message msg = queue.get();
         if (msg != null)
         {
             Console.WriteLine(msg.Body);
             queue.deleteMessage(msg);
         }
         if (Console.KeyAvailable)
         {
             string typedMsg = Console.ReadLine();
             queue.push(typedMsg);
         }
         Thread.Sleep(100);
     }
 }
コード例 #16
0
 public IronMQOperations(string queueName, Token credentials)
 {
     _client = new Client(credentials.Key, credentials.Secret, proto:"http", port:80);
     _queue = _client.Queue(queueName);
 }
コード例 #17
0
        public void BasicTests()
        {
            Client c = new Client(_projectId, _token);
            Queue q = c.queue("test-queue");

            ClearQueue(q);
            // clear_queue
            q.push("hello world!");
            Message msg = q.get();
            Assert.IsNotNull( msg.Id );
            Assert.IsNotNull( msg.Body );
            //queue = @client.queues.get(:name=>@client.queue_name)
            //total_messages = queue.total_messages
            //res = @client.messages.post("hello world!")
            //p res
            //assert res["id"]
            //assert res.id
            //assert res.msg

            //queue = @client.queues.get(:name=>@client.queue_name)
            //assert queue.size == 1
            //assert queue.total_messages == (total_messages+1)

               // msg = q.get();
             //   Assert.IsNotNull( msg.Id );
            //res = @client.messages.get()
            //p res
            //assert res["id"]
            //assert res.id

            q.deleteMessage( msg.Id );
            msg = q.get();
            Assert.IsNull( msg );
            //res = @client.messages.delete(res["id"])
            //p res
            //puts "shouldn't be any more"
            //res = @client.messages.get()
            //p res
            //assert res.nil?

            //queue = @client.queues.get(:name=>@client.queue_name)
            //assert queue.size == 0

            q.push("hello world 2!");
            //res = @client.messages.post("hello world 2!")
            //p res

            msg = q.get();
            Assert.IsNotNull(msg);
            //msg = @client.messages.get()
            //p msg
            //assert msg

            q.deleteMessage(msg.Id);
            //res = msg.delete
            //p res

            msg = q.get();
            Assert.IsNull(msg);
            //puts "shouldn't be any more"
            //res = @client.messages.get()
            //p res
            //assert res.nil?
        }
コード例 #18
0
ファイル: Queue.cs プロジェクト: AlexYurov/iron_mq_dotnet
 public Queue(Client client, string name)
 {
     this.client = client;
     this.name = name;
 }
コード例 #19
0
        public void BulkPushTest()
        {
            Client c = new Client(_projectId, _token);
            Queue q = c.queue("test-queue");

            ClearQueue(q);
            var messages = Enumerable.Range(0, 10).Select(i => i.ToString()).ToArray();
            long timeout = 0;
            q.push(messages, timeout);

            for (int i = 0; i < 10; i++)
            {
                var msg = q.get();
                Assert.IsNotNull(msg);
            }
            // Assumption is that if we queued up 1000 and we got back 1000 then it worked fine.
            // Note: this does not verify we got back the same messages
        }
コード例 #20
0
        public void BulkPushTest()
        {
            var c = new Client(_credentials);
            var q = c.Queue("test-queue");

            ClearQueue(q);
            var messages = Enumerable.Range(0, 10).Select(i => i.ToString()).ToArray();
            const long timeout = 0;
            q.Enqueue(messages, timeout);

            for (var i = 0; i < 10; i++)
            {
                var msg = q.Dequeue();
                Assert.IsNotNull(msg);
            }
            // Assumption is that if we queued up 1000 and we got back 1000 then it worked fine.
            // Note: this does not verify we got back the same messages
        }
コード例 #21
0
 public void ClearEmptyQueueTest()
 {
     Client c = new Client(_projectId, _token);
     Queue q = c.queue("test-queue");
     ClearQueue(q);
     // At this point the queue should be empty
     q.clear();
 }
コード例 #22
0
        public void ClearQueueTest()
        {
            Client c = new Client(_projectId, _token);
            Queue q = c.queue("test-queue");
            ClearQueue(q);

            var messageBody = "This is a test of the emergency broadcasting system... Please stand by...";
            q.push(messageBody);
            q.clear();

            var msg = q.get();
            Assert.IsNull(msg);
        }
コード例 #23
0
        public void TestMethod1()
        {
            var c = new Client(_credentials);
            var q = c.Queue("test-queue");
            ClearQueue(q);

            var body = "Hello, IronMQ!";
            q.Enqueue(body);

            var msg = q.Dequeue();
            Assert.IsTrue(string.Compare(body, msg.Body) == 0);
            q.Delete(msg);
        }
コード例 #24
0
        public void ClearQueueTest()
        {
            var c = new Client(_credentials);
            var q = c.Queue("test-queue");
            ClearQueue(q);

            const string messageBody = "This is a test of the emergency broadcasting system... Please stand by...";
            q.Enqueue(messageBody);
            q.Clear();

            var msg = q.Dequeue();
            Assert.IsNull(msg);
        }
コード例 #25
0
 public void ClearEmptyQueueTest()
 {
     var c = new Client(_credentials);
     var q = c.Queue("test-queue");
     ClearQueue(q);
     // At this point the queue should be empty
     q.Clear();
 }
コード例 #26
0
        public void TestMethod1()
        {
            Client c = new Client(_projectId, _token);
            Queue q = c.queue("test-queue");
            ClearQueue(q);

            string body = "Hello, IronMQ!";
            q.push(body);

            Message msg = q.get();
            Assert.IsTrue(string.Compare(body, msg.Body) == 0);
            q.deleteMessage(msg);
        }
コード例 #27
0
        public void BulkGetTest()
        {
            Client c = new Client(_projectId, _token);
            Queue q = c.queue("test-queue");
            ClearQueue(q);

            var messages = Enumerable.Range(0, 10).Select(i => i.ToString()).ToArray();
            long timeout = 0;
            q.push(messages, timeout);

            var actual = q.get(100);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Count > 1);
        }