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


C# Connection.SetOption方法代码示例

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


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

示例1: ConnectionSetOption

        public void ConnectionSetOption()
        {
            Dictionary<string, object> options = new Dictionary<string, object>();
            options["reconnect"] = true;

            Connection myConn = new Connection("url", options);
            myConn.SetOption("reconnect", false);

            Assert.IsFalse(myConn.IsOpen);
        }
开发者ID:irinabov,项目名称:debian-qpid-cpp,代码行数:10,代码来源:messaging.test.connection.cs

示例2: ConnectAndReceive

        public void ConnectAndReceive()
        {
            try
            {
                _sessionReceiver = new TradeConfirmationReceiver();
                /*
                   * Step 1: Preparing the connection and session
                   */
                _connection = new Connection(_brokerAddress);
                _connection.SetOption("reconnect", true);
                _connection.SetOption("reconnect_limit", 2);
                _connection.SetOption("reconnect_urls", _failBrokerAddress);

                //must set the username, a little different with Eurex's Demo code
                //the username is case sensitive
                //be carful, the .cert's frendly is empty in LCMLO_LIQSPALBB.crt
                _connection.SetOption("username", _memberName);
                _connection.SetOption("transport", "ssl");
                _connection.SetOption("sasl_mechanisms", "EXTERNAL");
                _connection.SetOption("heartbeat", 60);//unit:seconds

                _connection.Open();

                _session = _connection.CreateSession();
                /*
                 * Step 2: Create callback server and implicitly start it
                 */
                // The callback server is running and executing callbacks on a separate thread.
                _callbackServer = new CallbackServer(_session, _sessionReceiver);
                /*
                 * Step 3: Creating message consumer
                 */
                _receiver = _session.CreateReceiver(_broadcastAddress);
                _receiver.Capacity = 100;
            }
            catch (QpidException ex)
            {
                _Log.Error("Make connection to AMQP broker failed!", ex);
                throw;
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:41,代码来源:EurexProduct.cs

示例3: ConnectionSetOption

        public void ConnectionSetOption()
        {
            Dictionary<string, object> options = new Dictionary<string, object>();
            options["id"] = 987654321;
            options["name"] = "Widget";
            options["percent"] = 0.99;

            Connection myConn = new Connection("url", options);
            myConn.SetOption("name", "purple");

            Assert.IsFalse(myConn.IsOpen);
        }
开发者ID:ncdc,项目名称:qpid,代码行数:12,代码来源:messaging.test.connection.cs

示例4: RequestResponse

        private static void RequestResponse()
        {
            string brokerAddr = "amqp:ssl:chengdudev6:11234";
            string failBrokerAddr = "amqp:ssl:chengdudev6:11234";

            string memberName = "ABCFR_ABCFRALMMACC1";
            string requestAddress = "request." + memberName + "; { node: { type: topic }, create: never }";
            string replyAddress = "response/response." + memberName + ".response_queue_1; { create: receiver, node: { type: topic } }";

            string responseAddress = "response." + memberName + ".response_queue_1; {create: receiver, assert: never," +
            "node: { type: queue, x-declare: { auto-delete: true, exclusive: false, arguments: {'qpid.policy_type': ring," +
            "'qpid.max_count': 1000, 'qpid.max_size': 1000000}}, x-bindings: [{exchange: 'response', queue: 'response." +
            memberName + ".response_queue_1', key: 'response." + memberName + ".response_queue_1'}]}}";

            Connection connection = null;
            Session session;

            try
            {
                /*
                 * Step 1: Preparing the connection and session
                 */
                connection = new Connection(brokerAddr);
                connection.SetOption("reconnect", true);
                connection.SetOption("reconnect_limit", 1);
                connection.SetOption("reconnect_urls", failBrokerAddr);

                connection.SetOption("username", "ABCFR_ABCFRALMMACC1");

                connection.SetOption("transport", "ssl");
                connection.SetOption("sasl_mechanisms", "EXTERNAL");
                connection.Open();
                session = connection.CreateSession();
                /*
                 * Step 2: Creating message consumer
                 */
                Receiver receiver = session.CreateReceiver(responseAddress);
                /*
                 * Step 2: Creating message producer
                 */
                Sender sender = session.CreateSender(requestAddress);
                /*
                 * Step 3: Sending a message
                 */
                Message requestMsg = new Message("<FIXML>...</FIXML>");
                Address ra = new Address(replyAddress);
                requestMsg.ReplyTo = ra;
                sender.Send(requestMsg);

                Console.WriteLine("Request sent: {0}", requestMsg.GetContent());

                session.Sync();


                /*
                 * Step 3: Receiving a message
                 */
                Message msg = receiver.Fetch(DurationConstants.SECOND * 10);
                Console.WriteLine("RECEIVED MESSAGE:");
                Console.WriteLine("#################");
                Console.WriteLine(msg.GetContent());

                session.Acknowledge();

                connection.Close();
            }
            catch (QpidException ex)
            {
                Console.WriteLine("QpidException caught: {0}", ex.Message);
            }
            finally
            {
                if (connection != null && connection.IsOpen)
                {
                    Console.WriteLine("Closing the connection.");
                    connection.Close();
                }
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:79,代码来源:Program.cs

示例5: Send

        private static void Send()
        {
            string brokerAddr = "amqp:ssl:chengdudev6:11234";
            string failBrokerAddr = "amqp:ssl:chengdudev6:11234";

            string memberName = "ABCFR_ABCFRALMMACC1";
            string requestAddress = "request." + memberName + "; { node: { type: topic }, create: never }";
            string replyAddress = "response/response." + memberName + ".response_queue_1; { create: receiver, node: { type: topic } }";

            Connection connection = null;
            Session session;

            try
            {
                /*
                 * Step 1: Preparing the connection and session
                 */
                connection = new Connection(brokerAddr);
                connection.SetOption("reconnect", true);
                connection.SetOption("reconnect_limit", 1);
                connection.SetOption("reconnect_urls", failBrokerAddr);

                connection.SetOption("username", "ABCFR_ABCFRALMMACC1");

                connection.SetOption("transport", "ssl");
                connection.SetOption("sasl_mechanisms", "EXTERNAL");
                connection.Open();
                session = connection.CreateSession();
                /*
                 * Step 2: Creating message producer
                 */
                Sender sender = session.CreateSender(requestAddress);
                /*
                 * Step 3: Sending a message
                 */
                Message requestMsg = new Message("<FIXML>...</FIXML>");
                Address ra = new Address(replyAddress);
                requestMsg.ReplyTo = ra;
                sender.Send(requestMsg);
                Console.WriteLine("Request sent: {0}", requestMsg.GetContent());

                session.Sync();
                connection.Close();
            }
            catch (QpidException ex)
            {
                Console.WriteLine("QpidException caught: {0}", ex.Message);
            }
            finally
            {
                if (connection != null && connection.IsOpen)
                {
                    Console.WriteLine("Closing the connection.");
                    connection.Close();
                }
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:57,代码来源:Program.cs

示例6: ReceiveHelloWorld

        private static void ReceiveHelloWorld()
        {
            String broker = "chengdudev6:21234";
            string reseiverAddress = "bxu.testBinding"; //bxu.testBinging was binded to exchange "amq.topic"
            Connection connection = null;
            try
            {
                connection = new Connection(broker);
                connection.SetOption("username", "admin");
                connection.SetOption("password", "admin");
                connection.Open();

                Session session = connection.CreateSession();
                Receiver receiver = session.CreateReceiver(reseiverAddress);

                Message message = new Message();
                message = receiver.Fetch(DurationConstants.SECOND * 1);

                Console.WriteLine("{0}", message.GetContent());

                //The message should be acknowledged after its processing is finished. 
                session.Acknowledge();

                connection.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (connection != null)
                    connection.Close();
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:32,代码来源:Program.cs

示例7: SendHelloWorld

        private static void SendHelloWorld()
        {
            String broker = "chengdudev6:21234";
            String address = "amq.topic";
            Connection connection = null;
            try
            {
                connection = new Connection(broker);
                connection.SetOption("username", "admin");
                connection.SetOption("password", "admin");
                connection.Open();

                Session session = connection.CreateSession();
                Sender sender = session.CreateSender(address);
                var msg = new Message("<FIXML>........</FIXML>");
                msg.Subject = "bxu.testBinding";
                sender.Send(msg);

                //When sending the messages asynchronously, the session should be synchronized after every
                //few messages in order to make sure that the requests which were sent asynchronously were
                //delivered to the broker. 
                session.Sync();

                connection.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (connection != null)
                    connection.Close();
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:32,代码来源:Program.cs

示例8: Main

        static void Main(string[] args)
        {

            //RequestResponse();
            //return;

            //[[ The following two types of EnviromentVariable must set by manual, not here.
            //1)
            //System.Environment.SetEnvironmentVariable("QPID_SSL_CERT_STORE", "Personal", EnvironmentVariableTarget.Process);
            //System.Environment.SetEnvironmentVariable("QPID_SSL_CERT_NAME", "abcfr_abcfralmmacc1", EnvironmentVariableTarget.Process);


            //2)
            //System.Environment.SetEnvironmentVariable("QPID_LOG_ENABLE", "trace+", EnvironmentVariableTarget.Process);
            //System.Environment.SetEnvironmentVariable("QPID_SSL_CERT_FILENAME", @".\ABCFR_ABCFRALMMACC1.p12", EnvironmentVariableTarget.Process);
            //System.Environment.SetEnvironmentVariable("QPID_SSL_CERT_PASSWORD_FILE", @".\ABCFR_ABCFRALMMACC1.pwd", EnvironmentVariableTarget.Process);
            //System.Environment.SetEnvironmentVariable("QPID_SSL_CERT_NAME", "abcfr_abcfralmmacc1", EnvironmentVariableTarget.Process);
            //]]

            //string brokerAddr = args.Length > 0 ? args[0] : "amqp:ssl:192.168.34.11:11234";
            //shit, seems must use the host name
            string brokerAddr = args.Length > 0 ? args[0] : "amqp:ssl:chengdudev6:11234";
            string failBrokerAddr = args.Length > 1 ? args[1] : "amqp:ssl:chengdudev6:11234";

            string memberName = "ABCFR_ABCFRALMMACC1";
            string broadcastAddress = "broadcast." + memberName + ".TradeConfirmation; { node: { type: queue }, create: never, mode: consume, assert: always }";

            Connection connection = null;
            Session session;

            try
            {
                /*
                 * Step 1: Preparing the connection and session
                 */
                connection = new Connection(brokerAddr);
                connection.SetOption("reconnect", true);
                connection.SetOption("reconnect_limit", 2);
                connection.SetOption("reconnect_urls", failBrokerAddr);

                //shit, must set the username, a little different with Eurex's Demo code
                //shit, the username is case sensitive
                connection.SetOption("username", "ABCFR_ABCFRALMMACC1");

                connection.SetOption("transport", "ssl");
                connection.SetOption("sasl_mechanisms", "EXTERNAL");

                //connection.SetOption("heartbeat", 120);

                connection.Open();
                session = connection.CreateSession();
                /*
                 * Step 2: Create callback server and implicitly start it
                 */
                CallbackServer cbServer = new CallbackServer(session, new Listener());
                // The callback server is running and executing callbacks on a separate thread.
                /*
                 * Step 3: Creating message consumer
                 */
                Receiver receiver = session.CreateReceiver(broadcastAddress);
                receiver.Capacity = 100;

                Console.ReadLine();

                //System.Threading.Thread.Sleep(20 * 1000);   // in mS
                ///*
                // * Step 4: Stop the callback server and close receiver
                // */
                //cbServer.Close();
                //receiver.Close();
                //session.Sync();
            }
            catch (QpidException ex)
            {
                Console.WriteLine("QpidException caught: {0}", ex.Message);
                Console.WriteLine();
                Console.WriteLine("Press any key to continue!");
                Console.ReadLine();
            }
            finally
            {
                if (connection != null && connection.IsOpen)
                {
                    Console.WriteLine("Closing the connection.");
                    connection.Close();
                }
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:88,代码来源:Program.cs

示例9: SendReceiveBindingHelloWord

        private static void SendReceiveBindingHelloWord()
        {

            //or start simpe qpid on windows : 
            //cmd: qpidd --port=60302 --no-data-dir --auth=no

            String broker = "chengdudev6:21234";
            String senderAddress = "amq.topic"; // queue "bxu.testBinding" was binded to this exchange
            string reseiverAddress = "bxu.testBinding";
            Connection connection = null;
            try
            {
                connection = new Connection(broker);
                connection.SetOption("username", "admin");
                connection.SetOption("password", "admin");
                connection.Open();

                Session session = connection.CreateSession();
                Receiver receiver = session.CreateReceiver(reseiverAddress);

                Sender sender = session.CreateSender(senderAddress);
                sender.Send(new Message("<FIXML>........</FIXML>"));

                Message message = new Message();
                message = receiver.Fetch(DurationConstants.SECOND * 1);

                Console.WriteLine("{0}", message.GetContent());
                session.Acknowledge();
                connection.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (connection != null)
                    connection.Close();
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:37,代码来源:Program.cs

示例10: SendHelloWord_BR

        private static void SendHelloWord_BR()
        {

            //or start simpe qpid on windows : 
            //cmd: qpidd --port=60302 --no-data-dir --auth=no

            String broker = "chengdudev6:21234";
            string memberName = "ABCFR_ABCFRALMMACC1";
            string broadcastAddress = "broadcast." + memberName + ".TradeConfirmation; { node: { type: queue }, create: never, mode: consume, assert: always }";
            //string broadcastAddress = "request.ABCFR_ABCFRALMMACC1";//"bxu.testBinding";//"amq.direct";//"broadcast";
            Connection connection = null;
            try
            {
                connection = new Connection(broker);
                connection.SetOption("username", "admin");
                connection.SetOption("password", "admin");
                connection.Open();

                Session session = connection.CreateSession();

                Sender sender = session.CreateSender(broadcastAddress);
                sender.Send(new Message("<FIXML>........</FIXML>"));

                session.Sync();
                connection.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (connection != null)
                    connection.Close();
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:33,代码来源:Program.cs

示例11: SendHelloWord_SSL_BR

        private static void SendHelloWord_SSL_BR()
        {

            //or start simpe qpid on windows : 
            //cmd: qpidd --port=60302 --no-data-dir --auth=no

            String broker = "amqp:ssl:chengdudev6:11234";
            string memberName = "ABCFR_ABCFRALMMACC1";
            string broadcastAddress = "broadcast." + memberName + ".TradeConfirmation; { node: { type: queue }, create: never, mode: consume, assert: always }";
            Connection connection = null;
            try
            {
                connection = new Connection(broker);
                connection.SetOption("username", "ABCFR_ABCFRALMMACC1");

                connection.SetOption("transport", "ssl");
                connection.SetOption("sasl_mechanisms", "EXTERNAL");
                connection.Open();

                Session session = connection.CreateSession();

                Sender sender = session.CreateSender(broadcastAddress);
                sender.Send(new Message("<FIXML>........</FIXML>"));

                session.Sync();
                connection.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (connection != null)
                    connection.Close();
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:34,代码来源:Program.cs

示例12: SendReceiveHelloWord_SSL

        private static void SendReceiveHelloWord_SSL()
        {

            //or start simpe qpid on windows : 
            //cmd: qpidd --port=60302 --no-data-dir --auth=no

            String broker = "amqp:ssl:chengdudev6:11234";
            String address = "amq.topic"; // queue "bxu.testBinding" was binded to this exchange
            Connection connection = null;
            try
            {
                connection = new Connection(broker);
                connection.SetOption("username", "ABCFR_ABCFRALMMACC1");

                connection.SetOption("transport", "ssl");
                connection.SetOption("sasl_mechanisms", "EXTERNAL");
                connection.Open();

                Session session = connection.CreateSession();
                Receiver receiver = session.CreateReceiver(address);

                Sender sender = session.CreateSender(address);
                sender.Send(new Message("<FIXML>........</FIXML>"));

                Message message = new Message();
                message = receiver.Fetch(DurationConstants.SECOND * 1);

                Console.WriteLine("{0}", message.GetContent());
                session.Acknowledge();
                connection.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (connection != null)
                    connection.Close();
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:38,代码来源:Program.cs


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