private MessageQueue openMessageQueue(Destination dest) { MessageQueue rc=null; try { if (!MessageQueue.Exists(dest.Path)) { // create the new message queue and make it transactional rc = MessageQueue.Create(dest.Path, session.Transacted); this.destination.Path = rc.Path; } else { rc = new MessageQueue(dest.Path); this.destination.Path = rc.Path; if( !rc.CanWrite ) { throw new NMSSecurityException("Do not have write access to: " + dest); } } } catch( Exception e ) { if( rc!=null ) { rc.Dispose(); } throw new NMSException(e.Message+": "+dest, e); } return rc; }
public MessageProducer(Session session, Destination destination) { this.session = session; this.destination = destination; MessageConverter = session.MessageConverter; if (destination != null) { messageQueue = openMessageQueue(destination); } }