Annotation Type KafkaTrigger
-
@Target(PARAMETER) @Retention(RUNTIME) public @interface KafkaTriggerPlace this on a parameter whose value would come from Kafka, and causing the method to run when Kafka event is consumed. The parameter type can be one of the following:
- Any native Java types such as int, String, byte[]
- Nullable values using Optional<T>
- Any POJO type, currently supported only for Cardinality.One
The following example shows a Java function that is invoked when messages are consumed with the specified topic, brokerList, and consumerGroup on a Kafka cluster.
@FunctionName("KafkaTrigger-Java") public void run( @KafkaTrigger(name = "kafkaTrigger", topic = "users", brokerList="broker:29092", consumerGroup="functions") List<Map<String, String>> kafkaEventData, final ExecutionContext context ) { context.getLogger().info(kafkaEventData); }- Since:
- 1.4.0
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.StringbrokerListDefines the BrokerList.java.lang.StringconsumerGroupDefines the consumer group.java.lang.StringnameThe variable name used in function code for the request or request body.java.lang.StringtopicDefines the Topic.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description com.microsoft.azure.functions.BrokerAuthenticationModeauthenticationModeSASL mechanism to use for authentication.java.lang.StringavroSchemaAvro schema for generic record deserialization default ""CardinalitycardinalityCardinality of the trigger input.java.lang.StringdataTypeDefines how Functions runtime should treat the parameter value.java.lang.StringeventHubConnectionStringDefines the EventHub connection string when using KafkaOutput protocol header feature of Azure EventHubs.intlagThresholdjava.lang.StringpasswordSASL password with the PLAIN and SASL-SCRAM-..com.microsoft.azure.functions.BrokerProtocolprotocolDefines the security protocol used to communicate with brokers default is NOTSETjava.lang.StringschemaRegistryPasswordPassword for the Avro Schema Registry default ""java.lang.StringschemaRegistryUrlURL for the Avro Schema Registry default ""java.lang.StringschemaRegistryUsernameUsername for the Avro Schema Registry default ""java.lang.StringsslCaLocationPath to CA certificate file for verifying the broker's certificate.java.lang.StringsslCertificateLocationPath to client's certificate.java.lang.StringsslKeyLocationPath to client's private key (PEM) used for authentication.java.lang.StringsslKeyPasswordPassword for client's certificate.java.lang.StringusernameSASL username with the PLAIN and SASL-SCRAM-..
-
-
-
-
cardinality
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. If you choose 'Many', please set a dataType. Default: 'One'- Returns:
- The cardinality.
- Default:
- com.microsoft.azure.functions.annotation.Cardinality.ONE
-
-
-
dataType
java.lang.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.
- Default:
- ""
-
-
-
authenticationMode
com.microsoft.azure.functions.BrokerAuthenticationMode authenticationMode
SASL mechanism to use for authentication. Allowed values: Gssapi, Plain, ScramSha256, ScramSha512 Default: NOTSET- Returns:
- The broker authentication mode.
- Default:
- com.microsoft.azure.functions.BrokerAuthenticationMode.NOTSET
-
-