Пример #1
0
        public static IMessage CreateFrom(Apache.NMS.IMessage queueMessage, ISession session)
        {
            if (queueMessage == null)
            {
                return(null);
            }

            Apache.NMS.ITextMessage textMessage = queueMessage as Apache.NMS.ITextMessage;

            if (textMessage == null)
            {
                throw new ArgumentException(string.Format("Unsupported message type provided: \"{0}\"", queueMessage.GetType().FullName));
            }

            Message message = new Message();

            message.queueMessage    = queueMessage;
            message.Text            = textMessage.Text;
            message.Id              = textMessage.GetId();
            message.Type            = textMessage.GetMessageType();
            message.SentDate        = textMessage.GetSentDate();
            message.TryIndex        = textMessage.GetTryIndex();
            message.DeliveryTimeout = textMessage.GetDeliveryDelay();
            message.session         = session;

            return(message);
        }
Пример #2
0
        private bool DoSend(Apache.NMS.ITextMessage textMessage, out Exception exception)
        {
            exception = null;

            try
            {
                this.InitializeIfReq();
                this.messageProducer.Send(textMessage);
                this.queueingTransportLogger.LogMessageWasSent(textMessage.GetId(), textMessage.GetMessageType(), textMessage.GetTryIndex(), textMessage.GetSentDate(), textMessage.GetDeliveryDelay(), textMessage.Text);
            }
            catch (Apache.NMS.NMSConnectionException exc)
            {
                exception = new QueueingException("Cannot send a message due to connection problems", exc);
            }
            catch (Apache.NMS.ActiveMQ.ConnectionClosedException exc)
            {
                exception = new QueueingException("Cannot send the message due to connection problem", exc);
            }
            catch (Apache.NMS.ActiveMQ.BrokerException exc)
            {
                exception = new QueueingException(string.Format("Broker exception happened while sending the message: {0}\r\n", textMessage.Text), exc);
            }
            catch (Apache.NMS.NMSException exc)
            {
                exception = new QueueingException(string.Format("Cannot send the message with text: {0}\r\n", textMessage.Text), exc);
            }

            return(exception == null);
        }
Пример #3
0
        protected void LogMessageReceived(Apache.NMS.IMessage message)
        {
            Apache.NMS.ITextMessage textMessage = message as Apache.NMS.ITextMessage;

            if (textMessage != null)
            {
                this.logger.LogMessageWasReceived(textMessage.GetId(), textMessage.GetMessageType(), textMessage.GetTryIndex(), textMessage.GetSentDate(), textMessage.GetDeliveryDelay(), textMessage.Text);
            }
        }