Exemplo n.º 1
0
        public void TestRoundRobin()
        {
            string tp1_serviceBusConnectionString = "Endpoint=sb://hk-hack-hub-ns.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=JhDUJn307X1JEoPZb4aw0ZxYRz9cOdp4ZbnWS/Gm2Lc=;TransportType=Amqp";
            string connectionString = tp1_serviceBusConnectionString;
            SBMessagingFactoryWithConnectionString cst = new SBMessagingFactoryWithConnectionString(connectionString);

            ServiceBus.ConnectionPool.ConnectionPool <MessagingFactory> sbp = new ServiceBus.ConnectionPool.ConnectionPool <MessagingFactory>(cst, 10);
            sbp.Initialize();
            MessagingFactory mf1 = sbp.GetNext();
            MessagingFactory mf2 = sbp.GetNext();

            Assert.AreNotEqual(mf1, null);
            Assert.AreNotEqual(mf2, null);
            Assert.AreNotEqual(mf1.GetHashCode(), mf2.GetHashCode());
        }
Exemplo n.º 2
0
        public void TestMethod1()
        {
            dynamic factorySettings = new ServiceBus.ConnectionPool.DynamicDictionary();

            factorySettings.ConnectionString = "your_connection_string";
            SBMessagingFactoryWithConnectionString fws = new SBMessagingFactoryWithConnectionString(factorySettings.ConnectionString);
            ConnectionPool <MessagingFactory>      sbp = new ConnectionPool <MessagingFactory>(fws, 10);

            sbp.Initialize();
            MessagingFactory mf1 = sbp.GetNext();
            EventHubClient   ehc = mf1.CreateEventHubClient("your_eventhub_name");
            EventData        ed  = new EventData(Encoding.UTF8.GetBytes("Hello"));

            try
            {
                ehc.Send(ed);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
0
        public void TestConnectionStringProviderWithQueue()
        {
            string serviceBusConnectionString = "Endpoint=sb://hk-hack-hub-ns.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=JhDUJn307X1JEoPZb4aw0ZxYRz9cOdp4ZbnWS/Gm2Lc=";
            string queueName        = "myqueue";
            string connectionString = serviceBusConnectionString;
            SBMessagingFactoryWithConnectionString cst = new SBMessagingFactoryWithConnectionString(connectionString);

            ServiceBus.ConnectionPool.ConnectionPool <MessagingFactory> sbp = new ServiceBus.ConnectionPool.ConnectionPool <MessagingFactory>(cst, 10);
            sbp.Initialize();
            MessagingFactory mf1 = sbp.GetNext();

            string          testMsg = "Hello";
            BrokeredMessage bm      = new BrokeredMessage(testMsg);
            QueueClient     qc      = mf1.CreateQueueClient(queueName);

            qc.Send(bm);
            BrokeredMessage bmr = qc.Receive();

            string receivedMsg = bmr.GetBody <string>();

            Assert.Equals(testMsg, receivedMsg);
        }