DoStartTransaction() private method

Ensures that a transaction is started
private DoStartTransaction ( ) : void
return void
Ejemplo n.º 1
0
        protected void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive, bool specifiedTimeToLive)
        {
            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();
            }

            ActiveMQMessage activeMessage = (ActiveMQMessage)message;

            if (!disableMessageID)
            {
                MessageId id = new MessageId();
                id.ProducerId           = info.ProducerId;
                id.ProducerSequenceId   = Interlocked.Increment(ref messageCounter);
                activeMessage.MessageId = id;
            }

            activeMessage.ProducerId      = info.ProducerId;
            activeMessage.FromDestination = destination;
            activeMessage.NMSDeliveryMode = deliveryMode;
            activeMessage.NMSPriority     = priority;

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

            if (specifiedTimeToLive)
            {
                activeMessage.NMSTimeToLive = timeToLive;
            }

            lock (closedLock)
            {
                if (closed)
                {
                    throw new ConnectionClosedException();
                }

                if (session.Transacted)
                {
                    session.DoStartTransaction();
                    activeMessage.TransactionId = session.TransactionContext.TransactionId;
                }

                session.DoSend(activeMessage, this.RequestTimeout);
            }
        }
Ejemplo n.º 2
0
        protected virtual MessageAck CreateMessageAck(Message message)
        {
            MessageAck ack = new MessageAck();

            ack.AckType        = (int)AckType.ConsumedAck;
            ack.ConsumerId     = info.ConsumerId;
            ack.Destination    = message.Destination;
            ack.FirstMessageId = message.MessageId;
            ack.LastMessageId  = message.MessageId;
            ack.MessageCount   = 1;

            if (session.Transacted)
            {
                session.DoStartTransaction();
                ack.TransactionId = session.TransactionContext.TransactionId;
                session.TransactionContext.AddSynchronization(
                    new MessageConsumerSynchronization(this, message));
            }
            return(ack);
        }
Ejemplo n.º 3
0
        protected void Send(IDestination destination, IMessage message, bool persistent, byte priority, TimeSpan timeToLive, bool specifiedTimeToLive)
        {
            CheckClosed();
            ActiveMQMessage activeMessage = (ActiveMQMessage)message;

            if (!disableMessageID)
            {
                MessageId id = new MessageId();
                id.ProducerId = info.ProducerId;
                lock (this)
                {
                    id.ProducerSequenceId = ++messageCounter;
                }

                activeMessage.MessageId = id;
            }

            activeMessage.ProducerId      = info.ProducerId;
            activeMessage.FromDestination = destination;
            activeMessage.NMSPersistent   = persistent;
            activeMessage.NMSPriority     = priority;

            if (session.Transacted)
            {
                session.DoStartTransaction();
                activeMessage.TransactionId = session.TransactionContext.TransactionId;
            }

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

            if (specifiedTimeToLive)
            {
                activeMessage.NMSTimeToLive = timeToLive;
            }

            session.DoSend(activeMessage, this.RequestTimeout);
        }