public override Dictionary<string, string> handle(Message message)
        {
            Random rnd = new Random();
            int accept = rnd.Next(0, 9);

            if (accept > 6)
            {
                Console.WriteLine("ExampleHandler1 handling message {0}: {1}",
                    message.CorrelationId, message.Body);
                Thread.Sleep(rnd.Next(0, 5));
                Console.WriteLine("Return");
                message.ack();
                Dictionary<string, string> response = new Dictionary<string, string>();

                response.Add("message", String.Format("This is a Account Handler  response to " +
                   "message {0}", message.CorrelationId));
                return response;
            }
            else
            {
                Console.WriteLine("Got no time for the message, will delay");
                message.ack();
                message.delay();
                return new Dictionary<string, string>() { { "", "" } };

            }
        }
        public override Dictionary<string, string> handle(Message message)
        {
            Console.WriteLine("PortalMessageHandler handling message {0}: {1}",
                    message.CorrelationId, message.Body);
                message.ack();
                Dictionary<string, string> response = new Dictionary<string, string>();

                response.Add("message", String.Format("This is a Account Handler  response to " +
                   "message {0}", message.CorrelationId));
                return response;
        }
 public virtual Dictionary<string, string> handle(Message msg)
 {
     /*
     Over ride this method to handle messages
     @param message: A Message object
     @return: Depending on the request, this return value will be returned
     to the client
     */
     Dictionary<string, string> response = new Dictionary<string, string>();
     response.Add("", "");
     return response;
 }
        public override Dictionary<string, string> handle(Message message)
        {
            Console.WriteLine("AccountHandler handling message {0}: {1}",
                message.CorrelationId, message.Body);
            message.ack();
            // add data to it's corresponding table
            RootObject individual_data = JsonConvert.DeserializeObject<RootObject>(message.Body);
            //insert data in local database
            insert_data(individual_data);
            Dictionary<string, string> response = new Dictionary<string, string>();

            response.Add("message", String.Format("This is Individual Handler  response to " +
               "message {0}", message.CorrelationId));
            return response;
        }
 public Message reply(string content, string message_type="response")
 {
     if (!this.received)
     throw new MessageException("Can only reply to received " +
                            "messages");
     if (Convert.ToBoolean(this.acked) && this.replyTo!="" && this.replyTo!=null)
     {
     Message msg = new Message(channel, exchange, this.replyTo, content,
         redelivered, deliveryTag);
     msg.send();
     return msg;
     }
     else
     {
     if (this.replyTo!="" )
         throw new MessageException("Cannot reply to message. A reply was " +
                                "requested but the message was not " +
                                "acknowledged.");
     else
         throw new MessageException("Cannot reply to message. The " +
                                "message did not include a reply-to " +
                               "property");
     }
 }
 public static Message createFromChannel(IModel channel, bool redelivered, ulong deliveryTag, 
     string routingKey, IBasicProperties prop, byte[] body, IModel delayChannel=null, string delayQueue=null)
 {
     string bodystr = Encoding.UTF8.GetString(body);
     AmqpTimestamp ts = prop.Timestamp;
     string messageType = prop.Type;
     Message msg = new Message(channel, "", routingKey, bodystr,
         redelivered, deliveryTag, prop, delayChannel, delayQueue);
     msg.received = true;
     DateTime dtDateTime = new DateTime(1970,1,1,0,0,0,0,System.DateTimeKind.Utc);
     msg.sent = dtDateTime.AddSeconds( ts.UnixTime ).ToLocalTime();
     return msg;
 }
 public void publish(string message)
 {
     /*
     Publishes a message to configured exchanges with the configured routing
     key
     @param message: The message to be published
     */
     Console.WriteLine(message);
     foreach (KeyValuePair<string, string> exchange in exchanges)
     {
     Message msg = new Message(channel, exchange.Key, exchange.Value,
         message, false, 0);
     msg.send();
     }
 }