Beispiel #1
0
        private Org.Apache.Qpid.Messaging.Session qpidSession = null; // Don't create until Start()

        public Session(Connection connection, int sessionId, AcknowledgementMode acknowledgementMode)
        {
            this.connection = connection;
            this.acknowledgementMode = acknowledgementMode;
            MessageConverter = connection.MessageConverter;
            id = sessionId;
            if (this.acknowledgementMode == AcknowledgementMode.Transactional)
            {
                // TODO: transactions
                throw new NotSupportedException("Transactions are not supported by Qpid/Amqp");
            }
            if (connection.IsStarted)
            {
                this.Start();
            }
            connection.AddSession(this);
        }
        /// <summary>
        /// Creates a new connection to Qpid/Amqp.
        /// </summary>
        public IConnection CreateConnection(string userName, string password)
        {
            Connection connection = new Connection();

            connection.RedeliveryPolicy = this.redeliveryPolicy.Clone() as IRedeliveryPolicy;
            //connection.ConsumerTransformer = this.consumerTransformer; // TODO:
            //connection.ProducerTransformer = this.producerTransformer; // TODO:
            connection.BrokerUri = this.BrokerUri;
            connection.ClientId = this.clientID;
            connection.ConnectionProperties = this.properties;

            if (!String.IsNullOrEmpty(userName))
            {
                connection.SetConnectionProperty(Connection.USERNAME_OPTION, userName);
            }
            if (!String.IsNullOrEmpty(password))
            {
                connection.SetConnectionProperty(Connection.PASSWORD_OPTION, password);
            }

            IConnection ReturnValue = null;
            ReturnValue = connection;

            return ReturnValue;
        }