Azure / azure-functions-java-library

Contains annotations for writing Azure Functions in Java
MIT License
42 stars 42 forks source link

Unable to access PartitionContext or get PartitionId when using EventHubTrigger #138

Open jeevanthespark opened 3 years ago

jeevanthespark commented 3 years ago

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));
        }
rasavant-ms commented 3 years ago

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

anatbal commented 2 years ago

Are there any updates about this issue?

lovababu commented 2 years ago

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