示例#1
0
        public IMessageProducer CreateProducer(IDestination destination)
        {
            if (destination == null)
            {
                throw new InvalidDestinationException("Cannot create a Consumer with a Null destination");
            }
            MessageProducer producer = null;

            try
            {
                Queue queue = new Queue(destination.ToString());
                producer = DoCreateMessageProducer(queue);

                this.AddProducer(producer);
            }
            catch (Exception)
            {
                if (producer != null)
                {
                    this.RemoveProducer(producer.ProducerId);
                    producer.Close();
                }

                throw;
            }

            return(producer);
        }