Last active
December 29, 2015 17:09
-
-
Save iogbole/4d033e41a54d61f08b36 to your computer and use it in GitHub Desktop.
Azure Event Hub Pseudo code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main method | |
int send_event () { | |
SERVICE_NAMESPACE = 'ioteh-ns' | |
EVENT_HUB_NAME = 'ioteh' | |
PUBLISHER_NAME = 'dhtxx' | |
EVENT_HUB_SIGNATURE = 'change_me' | |
API_ENDPOINT = "https://#{SERVICE_NAMESPACE}.servicebus.windows.net/#{EVENT_HUB_NAME}/publishers/#{PUBLISHER_NAME}/messages" | |
// define headers | |
HTTP.Headers.ConnectionTimeout = 60 | |
HTTP.Headers.Content-Type = 'application/json' | |
HTTP.Headers.Authorization = #{EVENT_HUB_SIGNATURE} | |
//body of message | |
HTTP.body = telemetry_data | |
//Send it | |
HTTP.POST AP_ENDPOINT | |
If HTTP.RESPONSE.StatusCode == 201 | |
// successfully sent event to Azure Event Hubs | |
Else | |
// print HTTP.RESPONSE.StatusCode | |
// print HTTP.RESPONSE.Body | |
return HTTP.RESPONSE.StatusCode | |
} | |
// method | |
String telemetry_data() { | |
//this method receives telemetry data from IOT | |
// you may need to convert telemetry data to json if you're not | |
sending json format. | |
// sample data: https://gist.github.com/iogbole/8af14091e801d6352cf2 | |
return telemetry_json_format | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment