EventHubTrigger Interface

Implements

java.lang.annotation.Annotation

public interface EventHubTrigger
implements java.lang.annotation.Annotation

Place this on a parameter whose value would come from event hub, and causing the method to run when a new event is arrived. The parameter type can be one of the following:

  • Any native Java types such as int, String, byte[]
  • Nullable values using Optional
  • Any POJO type

The following example shows a Java function that logs the message body of the event hub trigger:

@FunctionName("eventHubMonitor")
 public void logEventHubMessage(
    @EventHubTrigger(name = "event", 
    eventHubName = "samples-workitems", 
    connection = "AzureEventHubConnection") String message,
     final ExecutionContext context
 ) {
     context.getLogger().info("Event hub message received: " + message);
 }

Method Summary

Modifier and Type Method and Description
abstract Cardinality cardinality()

Cardinality of the trigger input.

abstract java.lang.String connection()

Defines the app setting name that contains the Azure Eventhub connection string.

abstract java.lang.String consumerGroup()

Defines the consumer group of the event hub to which to bind.

abstract java.lang.String dataType()

Defines how Functions runtime should treat the parameter value.

abstract java.lang.String eventHubName()

Defines the name of the event hub to which to bind.

abstract java.lang.String name()

The variable name used in function.json.

Method Details

cardinality

public abstract Cardinality cardinality()

Cardinality of the trigger input. Choose 'One' if the input is a single message or 'Many' if the input is an array of messages. 'Many' is the default if unspecified

Returns:

An Cardinality value representing the Cardinality

connection

public abstract String connection()

Defines the app setting name that contains the Azure Eventhub connection string.

Returns:

The app setting name of the connection string.

consumerGroup

public abstract String consumerGroup()

Defines the consumer group of the event hub to which to bind.

Returns:

The event hub consumer group string.

dataType

public abstract String dataType()

Defines how Functions runtime should treat the parameter value. Possible values are:

  • "": get the value as a string, and try to deserialize to actual parameter type like POJO
  • string: always get the value as a string
  • binary: get the value as a binary data, and try to deserialize to actual parameter type byte[]

Returns:

The dataType which will be used by the Functions runtime.

eventHubName

public abstract String eventHubName()

Defines the name of the event hub to which to bind.

Returns:

The event hub name string.

name

public abstract String name()

The variable name used in function.json.

Returns:

The variable name used in function.json.

Applies to