Esempio n. 1
0
        private void Timer_Tick(ThreadPoolTimer timer)
        {
            var temperature = TemperatureSensorConfig.GetSensorMeasurement();
            var windspeed = WindspeedSensorConfig.GetSensorMeasurement();
            var barometricPressure = BarometricPressureSensorConfig.GetSensorMeasurement();

            var connectionParams = new ConnectionParameters(ConnectionConfig.ServiceBusNamespace,
                ConnectionConfig.EventHubName,
                ConnectionConfig.PolicyName,
                ConnectionConfig.PolicyKey,
                ConnectionConfig.PublisherName,
                ConnectionConfig.TokenTimeToLive);

            var amqpSender = new AmqpSender(connectionParams);

            Debug.WriteLine("Sending temperature to event hub via AMQP");
            var temperatureResult = amqpSender.Send(temperature);
            Debug.WriteLine(string.Format("Temperature sent via AMQP ({0}).", temperatureResult.ToString()));

            Debug.WriteLine("Sending wind speed to event hub via AMQP ");
            var windspeedResult = amqpSender.Send(windspeed);
            Debug.WriteLine(string.Format("Wind speed sent via AMQP ({0}).", windspeedResult.ToString()));

            Debug.WriteLine("Sending barometric pressure to event hub via AMQP ");
            var barometricPressureResult = amqpSender.Send(barometricPressure);
            Debug.WriteLine(string.Format("Barometric pressure sent via AMQP ({0}).", barometricPressureResult.ToString()));
        }
Esempio n. 2
0
        public void SendTest()
        {
            var measurement = MeasurementTestConfig.GetSensorMeasurement();

            var connectionParameters = new ConnectionParameters(ConnectionTestParameters.ServiceBusNamespace,
                ConnectionTestParameters.EventHubName,
                ConnectionTestParameters.PolicyName,
                ConnectionTestParameters.PolicyKey,
                ConnectionTestParameters.PublisherName,
                ConnectionTestParameters.TokenTimeToLive);

            var amqpSender = new AmqpSender(connectionParameters);

            var result = amqpSender.Send(measurement);

            Assert.AreEqual(SendResult.Success, result);
        }