public void InitForm()
        {
            try
            {

                factory = new ConnectionFactory(connectUri);
                connection = factory.CreateConnection("sempra.ops.gs.service", "sempra");
                connection.ExceptionListener += new ExceptionListener(OnException);
                connection.Start();

                session = connection.CreateSession();
                
                //destination = SessionUtil.GetDestination(session, "topic://sempra.ops.opsTracking.summary.update" + MAX_INACTIVITY_DURATION);

                //This is the process that registers the subscriber on the server
                //consumer = session.CreateConsumer(destination);
                ////////////////////////////////////////

                //producer = session.CreateProducer(destination);
                //consumer.Listener += new MessageListener(OnMessage);
                
                topicSubscriber = new TopicSubscriber(session, TOPIC_NAME);
                topicSubscriber.OnMessageReceived += new MessageListener(OnMessage);
                topicSubscriber.Start(CONSUMER_ID);

                ////////////////////////////////////////
                //_connectionFactory = new ConnectionFactory(_connectUri, CLIENT_ID);
                //_connection = _connectionFactory.CreateConnection(Properties.Settings.Default.MessageServerUserId, Properties.Settings.Default.MessageServerPassword);
                //_connection.ExceptionListener += new ExceptionListener(OnException);
                //_connection.Start();
                //_session = _connection.CreateSession();
                //_session = _connection.CreateSession(AcknowledgementMode.AutoAcknowledge);

                //_topicSubscriber = new TopicSubscriber(_session, TOPIC_NAME);
                //_topicSubscriber.Start(CONSUMER_ID);
                //_topicSubscriber.OnMessageReceived += new MessageListener(OnMessage);
            }
            catch (Exception error)
            {
                MessageBox.Show("Error:" + error.Message);
            }
        }
Exemple #2
0
        public void InitForm()
        {
            try
            {
                factory    = new ConnectionFactory(connectUri);
                connection = factory.CreateConnection("sempra.ops.gs.service", "sempra");
                connection.ExceptionListener += new ExceptionListener(OnException);
                connection.Start();

                session = connection.CreateSession();

                //destination = SessionUtil.GetDestination(session, "topic://sempra.ops.opsTracking.summary.update" + MAX_INACTIVITY_DURATION);

                //This is the process that registers the subscriber on the server
                //consumer = session.CreateConsumer(destination);
                ////////////////////////////////////////

                //producer = session.CreateProducer(destination);
                //consumer.Listener += new MessageListener(OnMessage);

                topicSubscriber = new TopicSubscriber(session, TOPIC_NAME);
                topicSubscriber.OnMessageReceived += new MessageListener(OnMessage);
                topicSubscriber.Start(CONSUMER_ID);

                ////////////////////////////////////////
                //_connectionFactory = new ConnectionFactory(_connectUri, CLIENT_ID);
                //_connection = _connectionFactory.CreateConnection(Properties.Settings.Default.MessageServerUserId, Properties.Settings.Default.MessageServerPassword);
                //_connection.ExceptionListener += new ExceptionListener(OnException);
                //_connection.Start();
                //_session = _connection.CreateSession();
                //_session = _connection.CreateSession(AcknowledgementMode.AutoAcknowledge);

                //_topicSubscriber = new TopicSubscriber(_session, TOPIC_NAME);
                //_topicSubscriber.Start(CONSUMER_ID);
                //_topicSubscriber.OnMessageReceived += new MessageListener(OnMessage);
            }
            catch (Exception error)
            {
                MessageBox.Show("Error:" + error.Message);
            }
        }