コード例 #1
0
ファイル: Controller.cs プロジェクト: CorinaUngur/FVMS
        internal void sendMessage(Dictionary <string, object> message, string Queue)
        {
            var messageBytes = JSONManipulator.getSendingJason(message);

            channel.BasicPublish(exchange: "",
                                 routingKey: Queue,
                                 basicProperties: null,
                                 body: messageBytes);
        }
コード例 #2
0
ファイル: Controller.cs プロジェクト: CorinaUngur/FVMS
        internal Dictionary <string, object> ConsumeOneMessage(string Queue)
        {
            QueueingBasicConsumer fileConsumer = new QueueingBasicConsumer(channel);

            channel.BasicConsume(queue: Queue,
                                 noAck: true,
                                 consumer: fileConsumer);
            var ea = (BasicDeliverEventArgs)fileConsumer.Queue.Dequeue();

            return(JSONManipulator.getResponseDictionary(ea.Body));
        }
コード例 #3
0
ファイル: Controller.cs プロジェクト: CorinaUngur/FVMS
        public Dictionary <String, Object> getResponse(String corrId)
        {
            var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue();

            if (ea.BasicProperties.CorrelationId == corrId)
            {
                return(JSONManipulator.getResponseDictionary(ea.Body));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
ファイル: Controller.cs プロジェクト: CorinaUngur/FVMS
        public void sendMessage(Dictionary <String, Object> dictMessage, String queue, string corrId)
        {
            var props = channel.CreateBasicProperties();

            props.ReplyTo       = replyQueueName;
            props.CorrelationId = corrId;
            dictMessage.Add("uid", LoggedUser.uid);
            var messageBytes = JSONManipulator.getSendingJason(dictMessage);

            channel.BasicPublish(exchange: "",
                                 routingKey: queue,
                                 basicProperties: props,
                                 body: messageBytes);
        }
コード例 #5
0
ファイル: Controller.cs プロジェクト: CorinaUngur/FVMS
        public void consumeFile(string Queue, int noOfBlocks, string hash, File file)
        {
            QueueingBasicConsumer fileConsumer = new QueueingBasicConsumer(channel);

            channel.BasicConsume(queue: Queue,
                                 noAck: true,
                                 consumer: fileConsumer);
            for (int i = 0; i < noOfBlocks; i++)
            {
                var ea = (BasicDeliverEventArgs)fileConsumer.Queue.Dequeue();
                Dictionary <string, object> blockInfo = JSONManipulator.getResponseDictionary(ea.Body);
                object content;
                blockInfo.TryGetValue("fileBlock", out content);

                file.appendContent(ObjectToByteArray(content));
            }
            if (file.checkContent(hash))
            {
                //Do something here
                file.createFileWatcherOnFile();
            }
        }