Esempio n. 1
0
        public static bool SendMessage <T>(string queuename, string Namespace, List <T> objects, out string errorMessage)
        {
            errorMessage = String.Empty;
            MSMQUtils MSMQ = new MSMQUtils();

            // Trying to open the queue
            MessageQueue queue = MSMQ.OpenOrCreatePrivateQueue(queuename, Namespace);

            // Sanit check
            if (queue == null)
            {
                errorMessage = String.Format("Error to Open or Create {0} Queue", queuename);
                return(false);
            }

            try
            {
                // Iterate over all objects
                foreach (T obj in objects)
                {
                    string serializedObj = Utils.Compress(JsonConvert.SerializeObject(obj));
                    queue.Send(serializedObj);
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                return(false);
            }

            queue.Dispose();

            return(true);
        }
Esempio n. 2
0
        public static InputConfig GetContentConfigurationQueue(string configurationQueueName)
        {
            MSMQUtils MSMQ = new MSMQUtils();

            // Read Private Queue
            object obj = MSMQ.ReadPrivateQueue(configurationQueueName, timeoutInMinutes: 1, persist: true);

            // Decompress string to json format
            string json = Utils.Decompress((string)obj);

            // Deserialize
            InputConfig config = JsonConvert.DeserializeObject <InputConfig>(json);

            return(config);
        }