I have tested the code at my end and it is working as expected. I will suggest you to stream the logs by navigating to you function app --> Monitor --> Logs.
If you have enabled application insights then the exception/logs should be logged in it. There might be some delay with the data of application insights.
Java code:
public class Function {
@FunctionName("ehprocessor")
public void eventHubProcessor(
@EventHubTrigger(name = "message", eventHubName = "maktest",connection = "EventHubConnectionString") List<String> messages,
final ExecutionContext context )
{
context.getLogger().info("Java EventHub trigger processed a request.");
context.getLogger().info(messages.toString());
}
}
If you are testing locally then make sure you have AzureWebJobsStorage and EventHubConnectionString define in your local.settings.json with the connection string value. If you are running in the azure function the same setting should be defined in your application setting of function app else it will give 500 error or runtime exception.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=storageaccountname;AccountKey=yourkey;EndpointSuffix=core.windows.net",
"EventHubConnectionString":"Endpoint=sb://xxxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yourkey",
"FUNCTIONS_WORKER_RUNTIME": "java"
}
}
As you have defined it as List<String> so the input should event should be a list of an array. If any other input is provided JSON, string, etc, then you will receive a Serialization exception.
["this is test1","this is test2"]