Esempio n. 1
0
        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();
                }
            }
        }
Esempio n. 2
0
        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();
                }
            }
        }
Esempio n. 3
0
        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();
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Set INI file option on the remote server
 /// </summary>
 /// <param name="packageName">Name of package and group</param>
 /// <param name="variableName">Variable name</param>
 /// <param name="value">Value to set</param>
 public void SetOption(string packageName, string variableName, string value)
 {
     if (Connection != null)
     {
         Connection.SetOption(packageName, variableName, value);
     }
 }
Esempio n. 5
0
        public MyFormAppSession(String host)
        {
            credentialManager = new MyFormAppCredentialManager();
            string proto       = null;
            string envNameTccs = null;

            if (host.StartsWith("http"))
            {
                proto = SoaConstants.HTTP;
            }
            else if (host.StartsWith("tccs"))
            {
                proto = SoaConstants.TCCS;
                int envNameStart = host.IndexOf('/') + 2;
                envNameTccs = host.Substring(envNameStart, host.Length - envNameStart);
            }

            connection = new Connection(host, new System.Net.CookieCollection(), credentialManager, SoaConstants.REST, proto, false);

            if (proto == SoaConstants.TCCS)
            {
                connection.SetOption(Connection.TCCS_ENV_NAME, envNameTccs);
            }

            connection.ExceptionHandler = new MyFormAppExceptionHandler();
            connection.ModelManager.AddPartialErrorListener(new MyFormAppPartialErrorListener());
            connection.ModelManager.AddModelEventListener(new MyFormAppModelEventListener());

            Connection.AddRequestListener(new MyFormAppRequestListener());
        }
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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();
                }
            }
        }
Esempio n. 9
0
        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();
                }
            }
        }
Esempio n. 10
0
        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();
                }
            }
        }
Esempio n. 11
0
        /**
         * Create an instance of the Session with a connection to the specified
         * server.
         *
         * Add implementations of the ExceptionHandler, PartialErrorListener,
         * ChangeListener, and DeleteListeners.
         *
         * @param host      Address of the host to connect to, http://serverName:port/tc
         */
        public Session(String host)
        {
            // Create an instance of the CredentialManager, this is used
            // by the SOA Framework to get the user's credentials when
            // challanged by the server (sesioin timeout on the web tier).
            credentialManager = new AppXCredentialManager();
            string proto       = null;
            string envNameTccs = null;

            if (host.StartsWith("http"))
            {
                proto = SoaConstants.HTTP;
            }
            else if (host.StartsWith("tccs"))
            {
                proto = SoaConstants.TCCS;
                int envNameStart = host.IndexOf('/') + 2;
                envNameTccs = host.Substring(envNameStart, host.Length - envNameStart);
            }

            // Create the Connection object, no contact is made with the server
            // until a service request is made
            connection = new Connection(host, new System.Net.CookieCollection(), credentialManager, SoaConstants.REST, proto, false);
            if (proto == SoaConstants.TCCS)
            {
                connection.SetOption(Connection.TCCS_ENV_NAME, envNameTccs);
            }


            // Add an ExceptionHandler to the Connection, this will handle any
            // InternalServerException, communication errors, xml marshalling errors
            // .etc
            connection.ExceptionHandler = new AppXExceptionHandler();

            // While the above ExceptionHandler is required, all of the following
            // Listeners are optional. Client application can add as many or as few Listeners
            // of each type that they want.

            // Add a Partial Error Listener, this will be notified when ever a
            // a service returns partial errors.
            connection.ModelManager.AddPartialErrorListener(new AppXPartialErrorListener());

            // Add a Change and Delete Listener, this will be notified when ever a
            // a service returns model objects that have been updated or deleted.
            connection.ModelManager.AddModelEventListener(new AppXModelEventListener());

            // Add a Request Listener, this will be notified before and after each
            // service request is sent to the server.
            Connection.AddRequestListener(new AppXRequestListener());
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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();
                }
            }
        }
Esempio n. 14
0
        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;
            }
        }
Esempio n. 15
0
        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;
            }
        }
Esempio n. 16
0
        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();
                }
            }
        }
Esempio n. 17
0
        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();
            }
        }
Esempio n. 18
0
        static int Main(string[] args)
        {
            string[] loggerOptions = { "", "--log-enable", "info+", "--log-to-stdout", "on", "--log-time", "on", "--log-level", "on" };
            Logger   logger        = new Logger();

            logger.Configure(loggerOptions);

            string brokerAddr        = "amqp:ssl:ecag-fixml-simu1.deutsche-boerse.com:10170";
            string connectionOptions = "{  }";

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

            Connection connection = null;
            Session    session;

            try
            {
                /*
                 * Step: Preparing the connection and session
                 */
                connection = new Connection(brokerAddr, connectionOptions);
                connection.SetOption("heartbeat", "30");
                connection.SetOption("sasl_mechanisms", "EXTERNAL");
                connection.Open();

                session = connection.CreateSession();

                Console.WriteLine("-I- Connection opened, session created");

                /*
                 * Step: Creating message consumer
                 */
                Receiver receiver = session.CreateReceiver(responseAddress);
                receiver.Capacity = 100;

                Sender sender = session.CreateSender(requestAddress);
                sender.Capacity = 100;

                Console.WriteLine("-I- Receiver and sender created ");

                /*
                 * Step: Send request message
                 */
                Message requestMsg = new Message("<FIXML>...</FIXML>");
                requestMsg.ReplyTo = new Address(replyAddress);
                sender.Send(requestMsg);

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

                /*
                 * Step: Receive response message
                 */
                Message msg = receiver.Fetch(DurationConstants.SECOND * 100);
                Console.WriteLine("-I- Response message received with content: {0}", msg.GetContent());

                /*
                 * Step: Stop the callback server and close receiver
                 */
                receiver.Close();
                sender.Close();
                session.Close();
            }
            catch (QpidException ex)
            {
                Console.WriteLine("-E- QpidException caught: {0}", ex.Message);
                return(1);
            }
            finally
            {
                if (connection != null && connection.IsOpen)
                {
                    Console.WriteLine("-I- Closing the connection.");
                    connection.Close();
                }
            }
            return(0);
        }
Esempio n. 19
0
        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();
            }
        }
Esempio n. 20
0
        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();
                }
            }
        }
Esempio n. 21
0
        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();
            }
        }
Esempio n. 22
0
        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();
                }
            }
        }
Esempio n. 23
0
        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();
            }
        }
Esempio n. 24
0
        static int Main(string[] args)
        {
            string[] loggerOptions = { "", "--log-enable", "info+", "--log-to-stdout", "on", "--log-time", "on", "--log-level", "on" };
            Logger   logger        = new Logger();

            logger.Configure(loggerOptions);

            string brokerAddr        = "amqp:ssl:ecag-fixml-simu1.deutsche-boerse.com:10170";
            string connectionOptions = "{ protocol: amqp1.0 }";

            string replyAddress    = "response/response.CBKFR_TESTCALMMACC1; { node: { type: topic }, assert: never, create: never }";
            string requestAddress  = "request.CBKFR_TESTCALMMACC1; { node: { type: topic }, assert: never, create: never }";
            string responseAddress = "response.CBKFR_TESTCALMMACC1; {create: never, assert: never, node: { type: queue } }";

            Connection connection = null;
            Session    session;

            try
            {
                /*
                 * Step: Preparing the connection and session
                 */
                connection = new Connection(brokerAddr, connectionOptions);
                connection.SetOption("sasl_mechanisms", "EXTERNAL");
                connection.Open();

                session = connection.CreateSession();

                Console.WriteLine("-I- Connection opened, session created");

                /*
                 * Step: Creating message consumer
                 */
                Receiver receiver = session.CreateReceiver(responseAddress);
                receiver.Capacity = 100;

                Sender sender = session.CreateSender(requestAddress);
                sender.Capacity = 100;

                Console.WriteLine("-I- Receiver and sender created ");

                /*
                 * Step: Send request message
                 */
                Message requestMsg = new Message("<FIXML>...</FIXML>");
                requestMsg.ReplyTo = new Address(replyAddress);
                sender.Send(requestMsg);

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

                /*
                 * Step: Receive response message
                 */
                Message msg = receiver.Fetch(DurationConstants.SECOND * 100);
                Console.WriteLine("-I- Response message received with content: {0}", msg.GetContent());

                /*
                 * Step: Stop the callback server and close receiver
                 */
                receiver.Close();
                sender.Close();
                session.Close();
            }
            catch (QpidException ex)
            {
                Console.WriteLine("-E- QpidException caught: {0}", ex.Message);
                return(1);
            }
            finally
            {
                if (connection != null && connection.IsOpen)
                {
                    Console.WriteLine("-I- Closing the connection.");
                    connection.Close();
                }
            }
            return(0);
        }
Esempio n. 25
0
        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);
        }
Esempio n. 26
0
        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();
                }
            }
        }
Esempio n. 27
0
        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();
            }
        }
Esempio n. 28
0
        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();
                }
            }
        }
Esempio n. 29
0
        static int Main(string[] args)
        {
            string[] loggerOptions = { "", "--log-enable", "info+", "--log-to-stdout", "on", "--log-time", "on", "--log-level", "on" };
            Logger   logger        = new Logger();

            logger.Configure(loggerOptions);

            string brokerAddr        = "amqp:ssl:ecag-fixml-simu1.deutsche-boerse.com:10170";
            string connectionOptions = "{ protocol: amqp1.0}";

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

            Connection connection = null;
            Session    session;

            try
            {
                /*
                 * Step 1: Preparing the connection and session
                 */
                connection = new Connection(brokerAddr, connectionOptions);
                connection.SetOption("sasl_mechanisms", "EXTERNAL");
                connection.Open();

                session = connection.CreateSession();

                Console.WriteLine("-I- Connection opened, session created");

                /*
                 * Step 2: Create callback server and implicitly start it
                 */
                // The callback server is running and executing callbacks on a separate thread.
                SessionReceiver.CallbackServer cbServer = new SessionReceiver.CallbackServer(session, new Listener());

                /*
                 * Step 3: Creating message consumer
                 */
                Receiver receiver = session.CreateReceiver(broadcastAddress);
                Console.WriteLine("-I- Receiver created ");
                receiver.Capacity = 100;
                System.Threading.Thread.Sleep(100 * 1000);   // in mS


                /*
                 * Step 4: Stop the callback server and close receiver
                 */
                receiver.Close();
                cbServer.Close();
                session.Close();
            }
            catch (QpidException ex)
            {
                Console.WriteLine("-E- QpidException caught: {0}", ex.Message);
                return(1);
            }
            finally
            {
                if (connection != null && connection.IsOpen)
                {
                    Console.WriteLine("-I- Closing the connection.");
                    connection.Close();
                }
            }
            return(0);
        }
Esempio n. 30
0
        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();
            }
        }