public void Send()

in src/main/csharp/MessageProducer.cs [140:210]


        public void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
        {
            if(null == destination)
            {
                // See if this producer was created without a destination.
                if(null == info.Destination)
                {
                    throw new NotSupportedException();
                }

                // The producer was created with a destination, but an invalid destination
                // was specified.
                throw new Apache.NMS.InvalidDestinationException();
            }

            Destination dest = null;

            if(destination == this.info.Destination)
            {
                dest = destination as Destination;
            }
            else if(info.Destination == null)
            {
                dest = Destination.Transform(destination);
            }
            else
            {
                throw new NotSupportedException("This producer can only send messages to: " + this.info.Destination.PhysicalName);
            }

            if(this.producerTransformer != null)
            {
                IMessage transformed = this.producerTransformer(this.session, this, message);
                if(transformed != null)
                {
                    message = transformed;
                }
            }

            Message stompMessage = this.messageTransformation.TransformMessage<Message>(message);

            stompMessage.ProducerId = info.ProducerId;
            stompMessage.FromDestination = dest;
            stompMessage.NMSDeliveryMode = deliveryMode;
            stompMessage.NMSPriority = priority;

            // Always set the message Id regardless of the disable flag.
            MessageId id = new MessageId();
            id.ProducerId = info.ProducerId;
            id.ProducerSequenceId = Interlocked.Increment(ref this.producerSequenceId);
            stompMessage.MessageId = id;

            if(!disableMessageTimestamp)
            {
                stompMessage.NMSTimestamp = DateTime.UtcNow;
            }

            if(timeToLive != TimeSpan.Zero)
            {
                stompMessage.NMSTimeToLive = timeToLive;
            }

            lock(closedLock)
            {
                if(closed)
                {
                    throw new ConnectionClosedException();
                }
                session.DoSend(stompMessage, this, this.RequestTimeout);
            }
        }