Connecting as a subscriber
Streaming API uses the HTTP/1.1 request-response model and the Apache Kafka protocol. Subscribers may connect to their subscriptions through the following process:
-
Subscriber gets their authorization token from the Itron Identity Service (IIS). For more information, see Authentication.
-
Subscriber gets a list of available subscriptions with the following request:
GET data-subscribers/{{SubscriberId}}/subscriptions
That returns the response:
Copy[
{
"subscriptionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"tenantId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"tenantShortCode": "COOKPOWER",
"dataProductId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"dataProductName": "Batch Transformer Load Stats",
"startDate": "2023-09-21T22:27:55.397Z",
"endDate": "2023-09-21T22:27:55.397Z",
"feeds": [
{
"feedType": "Kafka",
"dataType": "Read",
"connectionString": "Endpoint=sb://eh-usw-dpss-prod-mx.servicebus.windows.net/;SharedAccessKeyName=Read;SharedAccessKey=[redacted];EntityPath=dpss-ac25094c-8dbc-41c9-af50-9314da569ed5-DIDCData",
"consumerGroup": "ac25094a-8dbe-41c9-af50-9314da569ed5-DIDCData"
},
{
"feedType": "Kafka",
"dataType": "Exception",
"connectionString": "Endpoint=sb://eh-usw-dpss-prod-mx.servicebus.windows.net/;SharedAccessKeyName=Read;SharedAccessKey=[redacted];EntityPath=dpss-ac25094c-8dbc-41c9-af50-9314da569ed5-Exception",
"consumerGroup": "ac25094a-8dbe-41c9-af50-9314da569ed5-Exception"
}
]
}
] -
Get associated Kafka topics and credentials using their token with the following URI:
Copy/dpss/api/v1/data-subscribers/{{dataSubscriberId}}/subscriptions/{{subscriptionId}}/accessUri
That returns the response:
Copy[
{
"dataType": "DIDCData",
"transportType": "KafkaTopic",
"kafkaUri": "Endpoint=sb://eh-usw-dpss-test2-1.servicebus.windows.net/;SharedAccessKeyName=Read;SharedAccessKey=td1tt8VgIeDSRV8xAwcoiZH54N7FhUIWY+AEhJNN4v4=;EntityPath=dpss-fe9ff404-6955-4bbf-83c2-0e4abf281b4a-DIDCData",
"kafkaTopic": "dpss-fe9ff404-6955-4bbf-83c2-0e4abf281b4a-DIDCData",
"kafkaConsumerGroup": "fe9ff404-6955-4bbf-83c2-0e4abf281b4a-DIDCData"
},
{
"dataType": "Exception",
"transportType": "KafkaTopic",
"kafkaUri": "Endpoint=sb://eh-usw-dpss-test2-1.servicebus.windows.net/;SharedAccessKeyName=Read;SharedAccessKey=y3s8roQxdhBcL686Kq3MfcncIo8vIlE0r+AEhPv5fL0=;EntityPath=dpss-fe9ff404-6955-4bbf-83c2-0e4abf281b4a-Exception",
"kafkaTopic": "dpss-fe9ff404-6955-4bbf-83c2-0e4abf281b4a-Exception",
"kafkaConsumerGroup": "fe9ff404-6955-4bbf-83c2-0e4abf281b4a-Exception"
}
] -
Subscriber subscribes to the specific Kafka topic of interest.
To consume the data that our API publishes to a kafka topic, you need to subscribe to that topic using a kafka consumer. A kafka consumer is an application that reads messages from one or more topics and processes them according to your logic. You can use any kafka client library that supports the kafka protocol, but Itron recommends using the confluent libraries because they are well-tested, documented, and optimized for performance and reliability. You can find the confluent Kafka .net client at https://docs.confluent.io/clients-confluent-kafka-dotnet/current/overview.html.