Beispiel #1
0
        public void Send(string _text)
        {
            if (producer == null)
            {
                throw new Exception("This connector not configured for sending");
            }
            IMessage message = null;

            if (useZipFlag)
            {
                message = session.CreateBytesMessage(MSMQAdapter.CompressString(_text));
            }
            else
            {
                message = session.CreateTextMessage(_text);
            }
            message.NMSPersistent = true;
            message.NMSTimeToLive = TimeSpan.MaxValue;
            producer.Send(message);
        }
Beispiel #2
0
        private string ReceiveMessage(bool _noWait)
        {
            IMessage message = null;

            if (_noWait)
            {
                message = consumer.ReceiveNoWait();
                if (message == null)
                {
                    return(null);
                }
            }
            else
            {
                message = consumer.Receive();
            }

            if (useZipFlag)
            {
                return(MSMQAdapter.DecompressString(((IBytesMessage)message).Content));
            }
            else if (message is ITextMessage)
            {
                return(((ITextMessage)message).Text);
            }
            else if (message is IBytesMessage)
            {
                byte[] buf   = ((IBytesMessage)message).Content;
                char[] chars = System.Text.UTF8Encoding.UTF8.GetChars(buf);
                return(new String(chars));
            }
            else
            {
                return(message.ToString());
            }
        }