Exemplo n.º 1
0
        /// <summary>
        /// Sends the message to the given destination.
        /// </summary>
        public void Send(Apache.NMS.IDestination destination,
                         Apache.NMS.IMessage message)
        {
            Apache.NMS.XMS.Destination dest =
                (Apache.NMS.XMS.Destination)destination;

            Apache.NMS.XMS.Message msg = GetXMSMessage(message);
            long timeToLive            = (long)message.NMSTimeToLive.TotalMilliseconds;

            if (0 == timeToLive)
            {
                timeToLive = this.xmsMessageProducer.TimeToLive;
            }

            try
            {
                this.xmsMessageProducer.Send(
                    dest.xmsDestination,
                    msg.xmsMessage,
                    this.xmsMessageProducer.DeliveryMode,
                    this.xmsMessageProducer.Priority,
                    timeToLive);
            }
            catch (Exception ex)
            {
                ExceptionUtil.WrapAndThrowNMSException(ex);
            }
        }
Exemplo n.º 2
0
        private Apache.NMS.XMS.Message GetXMSMessage(Apache.NMS.IMessage message)
        {
            Apache.NMS.XMS.Message msg = (Apache.NMS.XMS.Message)message;

            if (this.ProducerTransformer != null)
            {
                IMessage transformed = this.ProducerTransformer(this.nmsSession, this, message);
                if (transformed != null)
                {
                    msg = (Apache.NMS.XMS.Message)transformed;
                }
            }

            return(msg);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Method DequeueNoWait
 /// </summary>
 public Apache.NMS.IMessage DequeueNoWait()
 {
     Apache.NMS.XMS.Message rc = null;
     lock (semaphore)
     {
         if (!m_bClosed && queue.Count > 0)
         {
             rc = (Apache.NMS.XMS.Message)queue.Dequeue();
             if (null != rc)
             {
                 rc.ReadOnlyBody       = true;
                 rc.ReadOnlyProperties = true;
             }
         }
     }
     return(rc);
 }
Exemplo n.º 4
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);
            }
        }