Azure/azure-functions-java-library

Unable to access PartitionContext or get PartitionId when using EventHubTrigger

jeevanthespark opened this issue · 3 comments

While using EventHubTrigger, unable to access PartitionContext. Also I am not finding any other way to access the partition Id.
Please find below the code. On trying to get PartitionContext using @BindingName, partitionContext object is null.

@FunctionName("EhbExample")
    @StorageAccount("AzureWebJobsStorage")
    public void run(
            @EventHubTrigger(name = "msg", cardinality = Cardinality.MANY, eventHubName = "%SourceEHName%", connection = "SourceEHConnString", consumerGroup = "%SourceEHConsumerGrp%") List<String> eventData,
            final ExecutionContext context, @BindingName("SystemPropertiesArray") SystemProperty[] systemProperties,
            @BindingName("PartitionContext") PartitionContext partitionContext ) {
        Logger log = context.getLogger();
        log.info("Triggered Function App");
        
        log.info("Partition Id: " + partitionContext.getPartitionId());
  
        for (int i=0;i<eventData.size();i++) {
            log.info("Sequence Number: " + systemProperties[i].SequenceNumber);
            log.info("Event: "+eventData.get(i));
        }

PartitionId is useful to check for duplicate messages across the Event Hub. Would be good to have this accessible in the Java runtime as well

Are there any updates about this issue?

Any update on this request? Upgraded libraries to latest available still same issue, PartitionContext object is null.