Beispiel #1
0
        private void HandleXmsMessage(IBM.XMS.IMessage xmsMessage)
        {
            Apache.NMS.IMessage message = XMSConvert.ToNMSMessage(xmsMessage);

            if (message != null)
            {
                if (this.ConsumerTransformer != null)
                {
                    IMessage newMessage = ConsumerTransformer(this.nmsSession, this, message);

                    if (newMessage != null)
                    {
                        message = newMessage;
                    }
                }

                if (Listener != null)
                {
                    try
                    {
                        Listener(message);
                    }
                    catch (Exception ex)
                    {
                        Apache.NMS.Tracer.Debug("Error handling message: " + ex.Message);
                    }
                }
                else
                {
                    this.dispatcher.Enqueue(message);
                }
            }
        }
Beispiel #2
0
 public Apache.NMS.ITopic GetTopic(string name)
 {
     try
     {
         return(XMSConvert.ToNMSTopic(this.xmsSession.CreateTopic(name)));
     }
     catch (Exception ex)
     {
         ExceptionUtil.WrapAndThrowNMSException(ex);
         return(null);
     }
 }
Beispiel #3
0
 public Apache.NMS.IQueue GetQueue(string name)
 {
     try
     {
         return(XMSConvert.ToNMSQueue(this.xmsSession.CreateQueue(name)));
     }
     catch (Exception ex)
     {
         ExceptionUtil.WrapAndThrowNMSException(ex);
         return(null);
     }
 }
Beispiel #4
0
 public Apache.NMS.IStreamMessage CreateStreamMessage()
 {
     try
     {
         return(XMSConvert.ToNMSStreamMessage(
                    this.xmsSession.CreateStreamMessage()));
     }
     catch (Exception ex)
     {
         ExceptionUtil.WrapAndThrowNMSException(ex);
         return(null);
     }
 }
Beispiel #5
0
 public Apache.NMS.ITextMessage CreateTextMessage(string text)
 {
     try
     {
         return(XMSConvert.ToNMSTextMessage(
                    this.xmsSession.CreateTextMessage(text)));
     }
     catch (Exception ex)
     {
         ExceptionUtil.WrapAndThrowNMSException(ex);
         return(null);
     }
 }
Beispiel #6
0
 public Apache.NMS.ITemporaryTopic CreateTemporaryTopic()
 {
     try
     {
         return(XMSConvert.ToNMSTemporaryTopic(
                    this.xmsSession.CreateTemporaryTopic()));
     }
     catch (Exception ex)
     {
         ExceptionUtil.WrapAndThrowNMSException(ex);
         return(null);
     }
 }
Beispiel #7
0
 public Apache.NMS.IObjectMessage CreateObjectMessage(Object body)
 {
     try
     {
         IBM.XMS.IObjectMessage xmsObjectMessage =
             this.xmsSession.CreateObjectMessage();
         xmsObjectMessage.Object = body;
         return(XMSConvert.ToNMSObjectMessage(xmsObjectMessage));
     }
     catch (Exception ex)
     {
         ExceptionUtil.WrapAndThrowNMSException(ex);
         return(null);
     }
 }
Beispiel #8
0
        public IQueueBrowser CreateBrowser(IQueue queue, string selector)
        {
            Apache.NMS.XMS.Queue queueObj = (Apache.NMS.XMS.Queue)queue;

            try
            {
                return(XMSConvert.ToNMSQueueBrowser(this.xmsSession.CreateBrowser(
                                                        queueObj.xmsDestination, selector)));
            }
            catch (Exception ex)
            {
                ExceptionUtil.WrapAndThrowNMSException(ex);
                return(null);
            }
        }
Beispiel #9
0
 /// <summary>
 /// Creates a new session to work on this connection
 /// </summary>
 public Apache.NMS.ISession CreateSession(
     Apache.NMS.AcknowledgementMode mode)
 {
     try
     {
         bool isTransacted =
             (mode == Apache.NMS.AcknowledgementMode.Transactional);
         return(XMSConvert.ToNMSSession(
                    this.xmsConnection.CreateSession(
                        isTransacted, XMSConvert.ToAcknowledgeMode(mode))));
     }
     catch (Exception ex)
     {
         ExceptionUtil.WrapAndThrowNMSException(ex);
         return(null);
     }
 }
Beispiel #10
0
        /// <summary>
        /// Sends the message to the default destination with the explicit QoS
        /// configuration.
        /// </summary>
        public void Send(Apache.NMS.IMessage message,
                         MsgDeliveryMode deliveryMode, MsgPriority priority,
                         TimeSpan timeToLive)
        {
            Apache.NMS.XMS.Message msg = GetXMSMessage(message);

            try
            {
                this.xmsMessageProducer.Send(
                    msg.xmsMessage,
                    XMSConvert.ToJMSDeliveryMode(deliveryMode),
                    (int)priority,
                    (long)timeToLive.TotalMilliseconds);
            }
            catch (Exception ex)
            {
                ExceptionUtil.WrapAndThrowNMSException(ex);
            }
        }
Beispiel #11
0
        public Apache.NMS.IMessageConsumer CreateConsumer(
            Apache.NMS.IDestination destination, string selector)
        {
            Apache.NMS.XMS.Destination destinationObj =
                (Apache.NMS.XMS.Destination)destination;

            try
            {
                Apache.NMS.IMessageConsumer consumer =
                    XMSConvert.ToNMSMessageConsumer(this,
                                                    this.xmsSession.CreateConsumer(
                                                        destinationObj.xmsDestination, selector));
                ConfigureConsumer(consumer);
                return(consumer);
            }
            catch (Exception ex)
            {
                ExceptionUtil.WrapAndThrowNMSException(ex);
                return(null);
            }
        }
Beispiel #12
0
        public Apache.NMS.IMessageProducer CreateProducer(
            Apache.NMS.IDestination destination)
        {
            Apache.NMS.XMS.Destination destinationObj =
                (Apache.NMS.XMS.Destination)destination;

            try
            {
                Apache.NMS.IMessageProducer producer =
                    XMSConvert.ToNMSMessageProducer(this,
                                                    this.xmsSession.CreateProducer(
                                                        destinationObj.xmsDestination));
                ConfigureProducer(producer);
                return(producer);
            }
            catch (Exception ex)
            {
                ExceptionUtil.WrapAndThrowNMSException(ex);
                return(null);
            }
        }
Beispiel #13
0
        public Apache.NMS.IMessageConsumer CreateDurableConsumer(
            Apache.NMS.ITopic destination, string name, string selector,
            bool noLocal)
        {
            Apache.NMS.XMS.Topic topicObj = (Apache.NMS.XMS.Topic)destination;

            try
            {
                Apache.NMS.IMessageConsumer consumer =
                    XMSConvert.ToNMSMessageConsumer(this,
                                                    this.xmsSession.CreateDurableSubscriber(
                                                        topicObj.xmsDestination, name, selector, noLocal));
                ConfigureConsumer(consumer);
                return(consumer);
            }
            catch (Exception ex)
            {
                ExceptionUtil.WrapAndThrowNMSException(ex);
                return(null);
            }
        }