protected virtual void Dispose(bool disposing) { if (this.isDisposed) { return; } if (disposing) { this.CloseProducer(); } this.messageProducer = null; this.session = null; this.isDisposed = true; }
public Apache.NMS.IMessageProducer CreateProducer(Apache.NMS.IDestination destination) { Apache.NMS.EMS.Destination destinationObj = (Apache.NMS.EMS.Destination)destination; try { Apache.NMS.IMessageProducer producer = EMSConvert.ToNMSMessageProducer(this, this.tibcoSession.CreateProducer(destinationObj.tibcoDestination)); ConfigureProducer(producer); return(producer); } catch (Exception ex) { ExceptionUtil.WrapAndThrowNMSException(ex); return(null); } }
private void CloseProducer() { if (this.messageProducer != null) { this.messageProducer.Close(); this.messageProducer.Dispose(); } if (this.session != null) { this.session.Dispose(); } this.messageProducer = null; this.session = null; }
private void InitializeIfReq() { if (this.session == null || this.session.IsClosed) { if (this.session != null) { this.session.Dispose(); } if (this.messageProducer != null) { this.messageProducer.Dispose(); } this.session = (Session)this.sessionProvider.GetSession(transactionalMode: false); this.messageProducer = this.session.CreateProducer(this.queue); } }
/// <summary> /// Opens a connection to the server. /// <para /> /// By default, it uses 3 system environment variables as parameters /// <para /> /// VHMSG_SERVER - This specifies the server to connect to. It can either be an ip address or domain name /// <para /> /// VHMSG_PORT - This specifies the port to connect to. /// <para /> /// VHMSG_SCOPE - A unique id used to distinguish messages sent by different modules using the same server. For example, if two users /// are using the same server, they would set different scopes so that they wouldn't receives each other's messages. /// </summary> public void OpenConnection() { string user = null; // ActiveMQConnection.DEFAULT_USER; string password = null; // ActiveMQConnection.DEFAULT_PASSWORD; string url = Apache.NMS.ActiveMQ.ConnectionFactory.DEFAULT_BROKER_URL; bool topic = true; //bool transacted = false; Apache.NMS.AcknowledgementMode ackMode = Apache.NMS.AcknowledgementMode.AutoAcknowledge; url = "tcp://" + m_host + ":" + m_port; //System.out.println("getConnection(): " + url + " " + m_scope ); Apache.NMS.ActiveMQ.ConnectionFactory connectionFactory = new Apache.NMS.ActiveMQ.ConnectionFactory(new Uri(url)); connection = connectionFactory.CreateConnection(user, password); //connection.setExceptionListener( this ); connection.Start(); //m_session = connection.CreateSession( transacted, ackMode ); m_session = connection.CreateSession(ackMode); if (topic) { m_destination = m_session.GetTopic(m_scope); } else { m_destination = m_session.GetQueue(m_scope); } m_Producer = m_session.CreateProducer(m_destination); m_Producer.DeliveryMode = Apache.NMS.MsgDeliveryMode.NonPersistent; // Persistent = false; // m_Producer.setDeliveryMode( DeliveryMode.NON_PERSISTENT ); }
private void ConfigureProducer(Apache.NMS.IMessageProducer producer) { producer.ProducerTransformer = this.ProducerTransformer; }