Java EventHubTrigger not working

N Senthil 1 Reputation point
2020-08-03T18:55:49.137+00:00

I am facing a situation with Java EventHub Trigger. I created one using VS Code and pointed to the Event Hub namespace that I had previously created. I see that the connection string is applied correctly. After deploying this function app I send a batch of messages to the event hub. I can see that the messages are received in Azure monitor dashboard. But the trigger is not triggered. When I monitor the trigger function the access count shows zero. What may be wrong in my Java eventhub trigger?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,570 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
591 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Krish G 2,331 Reputation points
    2020-08-04T16:58:50.16+00:00

    @N Senthil , I suspect the possible cause of your issue is when the event is received, there might be a deserialization error:

    Exception while executing function: Functions.EventHubExample. Microsoft.Azure.WebJobs.Host: Exception binding parameter message. Microsoft.Azure.WebJobs.Host: Binding parameters to complex objects (such as Object) uses Json.NET serialization.

    1. Bind the parameter type as string instead of Object to get the raw values and avoid JSON deserialization, or
    2. Change the queue payload to be valid json. The JSON parser failed: Unexpected character encountered while parsing value: H. Path , line 0, position 0.

    Since dataType is not specified in the EventHubTrigger parameter, it is assuming that the message to be json format and trying to deserialize which fails if it is not. Adding dataType = string in the EventHubTrigger arguments like below fixed the issue since your example has List of string as input. Or if the message is in json format and input is pojo, setting datatype is not required which is the default. You can read more about that here.

    @EventHubTrigger(name = "message", eventHubName = "nallatrgrfn-evthub", connection = "nallatrgrfnns_RootManageSharedAccessKey_EVENTHUB", consumerGroup = "$Default", cardinality = Cardinality.MANY, dataType = "string") List<String> message,  
    
    1 person found this answer helpful.