I have a iot-hub
that receives both JSON and non-json (hex) messages. These all go to my Java function app to decode. Based on the device-id
I'm calling a different decoder.
I'm trying to get the actual iothub-connection-device-id
of the message I'm receiving.
public class TranslateEndpoint {
/**
* This function will be invoked when an event is received from Event Hub.
*/
@FunctionName("TranslateEndpoint")
public void run(
@EventHubTrigger(name = "message", eventHubName = "NAME-DeviceIntegration", connection = "HostName=HOST;SharedAccessKeyName=NAME;SharedAccessKey=KEY=", consumerGroup = "$Default", cardinality = Cardinality.ONE) EventData message,
final ExecutionContext context
) {
context.getLogger().info("Java Event Hub trigger function executed.");
context.getLogger().info("Length:" + message.toString());
TranslateController temp = new TranslateController();
// Build up a list with all the data
context.getLogger().info(message.getSystemProperties().getPublisher());
context.getLogger().info(message.getSystemProperties().getPartitionKey());
context.getLogger().info(message.getSystemProperties().get("iothub-connection-device-id").toString());
}
The code above is inspired by some C# code I found. Unfortunately I get an error
Stack: java.lang.RuntimeException: Unable to invoke no-args constructor for interface com.microsoft.azure.eventhubs.EventData. Registering an InstanceCreator with Gson for this type may fix this problem.
Before I used a String
and only got my actual payload. What is the proper way of receiving system properties of my message?