当前位置: 首页>>代码示例>>C#>>正文


C# IConnection.Start方法代码示例

本文整理汇总了C#中IConnection.Start方法的典型用法代码示例。如果您正苦于以下问题:C# IConnection.Start方法的具体用法?C# IConnection.Start怎么用?C# IConnection.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConnection的用法示例。


在下文中一共展示了IConnection.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public override void Init()
        {
            base.Init();
            _producers = new LinkedList<IMessageProducer>();
            _consumers = new Hashtable();

            XmlNode nmsNode = this.DestinationDefinition.PropertiesXml.SelectSingleNode("nms");
            _nmsSettings = new NMSSettings(nmsNode);
            if (_nmsSettings != null)
            {
                ConnectionFactory connectionFactory = new ConnectionFactory(_nmsSettings.URI);

                log.Debug(string.Format("NMSAdapter Connected to URI {0}", _nmsSettings.URI));

                _connection = connectionFactory.CreateConnection();
                _connection.Start();
                _session = _connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge);

                if (_nmsSettings.DESTINATION_TYPE.StartsWith(NMSSettings.QueueDestination))
                {
                    _destination = new ActiveMQQueue(_nmsSettings.Destination);
                    log.Debug(string.Format("NMSAdapter Connected to Queue {0}", _nmsSettings.Destination));
                }
                else if (_nmsSettings.DESTINATION_TYPE.StartsWith(NMSSettings.TopicDestination))
                {
                    _destination = new ActiveMQTopic(_nmsSettings.Destination);
                    log.Debug(string.Format("NMSAdapter Connected to Topic {0}", _nmsSettings.Destination));
                }
                else
                {
                    log.Debug(string.Format("Unknown Destination Type {0}", _nmsSettings.DESTINATION_TYPE));
                }
            }
        }
开发者ID:DarkActive,项目名称:daFluorineFx,代码行数:34,代码来源:NMSAdapter.cs

示例2: SetUp

        public override void SetUp()
        {
            base.SetUp();

            connection = CreateConnection();
            connection.Start();
        }
开发者ID:ThorTech,项目名称:apache-nms,代码行数:7,代码来源:IndividualAckTest.cs

示例3: Queue

        public Queue(MsgDeliveryMode mode = MsgDeliveryMode.NonPersistent)
        {
            Uri msgQueue = new Uri("activemq:tcp://localhost:61616");

            _factory = new ConnectionFactory(msgQueue);
            try
            {
                _connection = _factory.CreateConnection();
            }
            catch (NMSConnectionException ex)
            {
                Log.FatalException("Error connecting to MQ server", ex);
                throw;
            }
            // TODO check _connection for null
            _connection.RequestTimeout = TimeSpan.FromSeconds(60);
            Session = _connection.CreateSession();

            // TODO need to find out if queue exists.
            // It creates a new queue if it doesn't exist.
            _destination = Session.GetDestination("queue://TwitterSearchStream");
            _consumer = Session.CreateConsumer(_destination);

            _producer = Session.CreateProducer(_destination);
            _producer.RequestTimeout = TimeSpan.FromSeconds(60);
            _producer.DeliveryMode = mode;

            _connection.Start();

            _connection.ExceptionListener += _connection_ExceptionListener;
            _connection.ConnectionInterruptedListener += _connection_ConnectionInterruptedListener;
        }
开发者ID:cfmayer,项目名称:Toketee,代码行数:32,代码来源:Queue.cs

示例4: Connecting

        protected bool Connecting()
        {
            if (mqConn != null)
            {
                return true;
            }

            // 尝试连接是否成功(不断开自动重连)
            if (!TryConnect())
            {
                return false;
            }

            // 实际连接,断开会自动重连
            string address = GetAddress();
            try
            {
                IConnectionFactory factory = new ConnectionFactory(address);
                mqConn = factory.CreateConnection();
                mqConn.Start();
                mqSession = mqConn.CreateSession(AcknowledgementMode.AutoAcknowledge);
                return true;
            }
            catch (Exception ex)
            {
                ex.ToString();
                return false;
            }
        }
开发者ID:xumingxsh,项目名称:HiCSMQ,代码行数:29,代码来源:HiMQBase.cs

示例5: UpdateConnection

        // Verbindung zum  Messaging-Server aktualisieren
        public void UpdateConnection()
        {
            try
            {
                // eventuell früher belegte Ressourcen freigeben
                CleanupResources();

                // Verbindung / Session / MessageProducer und -Consumer instanziieren
                if (connectionFactory == null)
                {
                    Console.WriteLine(brokerURL);
                    connectionFactory = new ConnectionFactory(brokerURL);
                }
                connection = connectionFactory.CreateConnection();
                session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
                messageProducer = session.CreateProducer(new ActiveMQTopic(topicName));

                // Thread zum Empfang eingehender Nachrichten starten
                connection.Start();

                Console.WriteLine("Connection geändert, Broker-URL ist " + brokerURL);
            }
            catch (Exception e)
            {
                Console.WriteLine("*** EXCEPTION in updateConnection(): " + e.Message);
            }
        }
开发者ID:TLandmann,项目名称:Bachelor-HSRM-Medieninformatik,代码行数:28,代码来源:Producer.cs

示例6: OpenWireConsumer

        /// <summary>
        /// 消息消费构造器
        /// </summary>
        /// <param name="brokerUri">地址</param>
        /// <param name="username">用户名</param>
        /// <param name="psw">密码</param>
        /// <param name="clientId">客户端标识 兼做队列接收目的地</param>
        /// <param name="isClient">true 客户端;false 服务端</param>
        public OpenWireConsumer(string brokerUri, string username, string psw, string clientId,bool isClient)
        {
            NMSConnectionFactory _factory = new NMSConnectionFactory(brokerUri, clientId);
            _connection = _factory.CreateConnection(username, psw);
            _connection.Start();
            _session = _connection.CreateSession(AcknowledgementMode.AutoAcknowledge);

            if (isClient)
            {
                _qReceiveDest = _session.GetDestination(clientId, DestinationType.TemporaryQueue);
            }
            else
            {
                _qReceiveDest = _session.GetQueue(clientId);
            }

            _messageConsumer = _session.CreateConsumer(_qReceiveDest);
            _messageConsumer.Listener += (message) =>
            {
                if (Listener != null)
                {
                    Listener(message);
                }
            };
        }
开发者ID:OldApple,项目名称:MQProxy,代码行数:33,代码来源:OpenWireMiddleware.cs

示例7: SetUp

 public void SetUp()
 {
     connectionFactory = new ConnectionFactory("tcp://localhost:61616", GetType().Name);
     connection = connectionFactory.CreateConnection();
     connection.Start();
     session = connection.CreateSession();
 }
开发者ID:cityindex-attic,项目名称:RTD-Subscription-Engine,代码行数:7,代码来源:ActiveMQIntegrationTests.cs

示例8: SetUp

        public override void SetUp()
        {
            base.SetUp();
			
            startedConnection = CreateConnection(null);
            startedConnection.Start();
            stoppedConnection = CreateConnection(null);
        }
开发者ID:Redi0,项目名称:meijing-ui,代码行数:8,代码来源:ConnectionTest.cs

示例9: Connect

        public void Connect()
        {
            while (!ableToSendEvents) {
                Uri connecturi = null;
                //if (textBoxSIPIPAddress.Text.StartsWith("ssl://"))
                //{
                Console.WriteLine ("Trying to connect to ActiveMQ broker ");
                //	connecturi = new Uri("activemq:" + textBoxSIPIPAddress.Text + ":" + textBoxSIPPort.Text + "?transport.ClientCertSubject=E%[email protected], CN%3DCommunication Tool"); // Connect to the ActiveMQ broker
                //}
                //else
                //{
                //log4.Debug(name + ": Trying to connect to ActiveMQ broker via non-secure connection");
                connecturi = new Uri ("activemq:tcp://localhost:61616"); // Connect to the ActiveMQ broker
                //}
                //Console.WriteLine("activeMQ::About to connect to " + connecturi);

                try {

                    // NOTE: ensure the nmsprovider-activemq.config file exists in the executable folder.
                    IConnectionFactory factory = new ConnectionFactory (connecturi);

                    // Create a new connection and session for publishing events
                    activeMQConnection = factory.CreateConnection ();
                    activeMQSession = activeMQConnection.CreateSession ();

                    IDestination destination = SessionUtil.GetDestination (activeMQSession, "topic://SIFTEO");
                    //Console.WriteLine("activeMQ::Using destination: " + destination);

                    // Create the producer
                    activeMQProducer = activeMQSession.CreateProducer (destination);
                    activeMQProducer.DeliveryMode = MsgDeliveryMode.Persistent;
                    destination = SessionUtil.GetDestination (activeMQSession, "topic://XVR.CCC");
                    activeMQConsumer = activeMQSession.CreateConsumer (destination);
                    //activeMQConsumer.Listener += new MessageListener(OnCCCMessage);

                    // Start the connection so that messages will be processed
                    activeMQConnection.Start ();
                    //activeMQProducer.Persistent = true;

                    // Enable the sending of events
                    //log4.Debug(name + ": ActiveMQ connected on topics XVR.CCC and XVR.SDK");
                    ableToSendEvents = true;

                } catch (Exception exp) {
                    // Report the problem in the output.log (Program Files (x86)\E-Semble\XVR 2012\XVR 2012\XVR_Data\output_log.txt)
                    //Console.WriteLine("*** AN ACTIVE MQ ERROR OCCURED: " + exp.ToString() + " ***");
                    //log4.Error(name + ": Error connecting to ActiveMQ broker: " + exp.Message);
                    //log4.Error((exp.InnerException != null) ? exp.InnerException.StackTrace : "");

                    Console.WriteLine (exp.Message);
                }
                System.Threading.Thread.Sleep (1000);
            }
        }
开发者ID:rooch84,项目名称:TangibleInvestigator,代码行数:54,代码来源:AMQConnector.cs

示例10: Master

        public Master(IUserService service)
        {
            DownloadUsers = new DownloadUsers(service);

            Factory = new NMSConnectionFactory("tcp://localhost:61616");
            Connection = Factory.CreateConnection();
            Connection.Start();
            Session = Connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
            Destination = SessionUtil.GetDestination(Session, "Users");
            Receiver = Session.CreateConsumer(Destination);
        }
开发者ID:KiraTanaka,项目名称:VK,代码行数:11,代码来源:Master.cs

示例11: Configure

        /// <summary>
        /// Configurate the Connection
        /// </summary>
        /// <param name="destination">Destionation</param>
        private void Configure(string destination)
        {
            Destination dest = new Destination(destination);

            Uri connectionUri = new Uri(dest.Host);
            factory = new Apache.NMS.ActiveMQ.ConnectionFactory(connectionUri);
            connection = factory.CreateConnection();
            session = connection.CreateSession();
            connection.Start();
            this.destination = session.GetDestination(dest.Queue);
        }
开发者ID:Mercynary,项目名称:loom-csharp,代码行数:15,代码来源:JMSPort.cs

示例12: Configure

        private void Configure(string destination)
        {
            Destination dest = new Destination(destination);

            Uri connectionUri = new Uri(dest.Host);
            _factory = new NMSConnectionFactory(connectionUri);
            _connection = _factory.CreateConnection();
            _session = _connection.CreateSession();
            _connection.Start();
            _destination = _session.GetDestination(dest.Queue);
        }
开发者ID:frenzqse,项目名称:loom-csharp-visualstudio,代码行数:11,代码来源:JMSPort.cs

示例13: UnparsedQueueManager

    public UnparsedQueueManager(SystemConfig config)
    {
        Uri connecturi = new Uri(config.ACTIVEMQ_URI);
        IConnectionFactory factory = NMSConnectionFactory.CreateConnectionFactory(connecturi);
        connection = factory.CreateConnection();
        session = connection.CreateSession();

        connection.Start();
        IDestination destination = SessionUtil.GetDestination(session, config.UNPARSED_QUEUE);
        producer = session.CreateProducer(destination);
    }
开发者ID:arunappulal,项目名称:all,代码行数:11,代码来源:unparsed_queue_manager.cs

示例14: SetUp

        public override void SetUp()
        {
            base.SetUp();

            connection = CreateConnection();
            connection.Start();

            Session session = connection.CreateSession() as Session;
            IQueue queue = session.GetQueue(destinationName);
            session.DeleteDestination(queue);
        }
开发者ID:Redi0,项目名称:meijing-ui,代码行数:11,代码来源:RollbackRedeliveryTest.cs

示例15: SetUp

        public void SetUp()
        {
            connectionFactory = new ConnectionFactory(BROKER, CLIENT_ID);
            connection = connectionFactory.CreateConnection();
            connection.Start();
            session = connection.CreateSession();

            subscriber = new TopicSubscriber(session, TOPIC_NAME);
            subscriber.Start(CONSUMER_ID);
            subscriber.OnMessageReceived +=
                message => Console.WriteLine("Recieving message=>{0}", message);
        }
开发者ID:samwa,项目名称:mremoted,代码行数:12,代码来源:NMSTopicTests.cs


注:本文中的IConnection.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。