Annotation Type KafkaOutput
-
@Target(PARAMETER) @Retention(RUNTIME) public @interface KafkaOutputPlace this on a parameter whose value would be published to Kafka. The parameter type should be OutputBinding<T>, where T could be one of:
- Any native Java types such as int, String, byte[]
- Any POJO type
The following example shows a Java function that produce a message to the Kafka cluster, using event provided in the body of an HTTP Post request.
@FunctionName("kafkaInupt-Java") public String input( @HttpTrigger(name = "request", methods = {HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) final String message, @KafkaOutput(name = "event", topic = "users", brokerList="broker:29092") OutputBinding<String< output, final ExecutionContext context) { context.getLogger().info("Message:" + message); output.setValue(message); return "{ \"id\": \"" + System.currentTimeMillis() + "\", \"description\": \"" + message + "\" }"; }- Since:
- 1.4.0
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.StringbrokerListDefines the BrokerList.java.lang.StringnameThe variable name used in function.json.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 serialization default ""intbatchSizeDefines the maximum number of messages batched in one MessageSet.java.lang.StringdataTypeDefines how Functions runtime should treat the parameter value.booleanenableIdempotenceWhen set to `true`, the producer will ensure that messages are successfully produced exactly once and in the original produce order.intlingerMslinger.MS property provides the time between batches of messages being sent to cluster.intmaxMessageBytesDefines the maximum transmit message size.intmaxRetriesHow many times to retry sending a failing Message.intmessageTimeoutMsLocal message timeout.java.lang.StringpasswordSASL password with the PLAIN and SASL-SCRAM-..com.microsoft.azure.functions.BrokerProtocolprotocolGets or sets the security protocol used to communicate with brokers default is PLAINTEXTintrequestTimeoutMsThe ack timeout of the producer request in milliseconds.java.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-..
-
-
-
-
dataType
java.lang.String dataType
Defines how Functions runtime should treat the parameter value. Possible values are:
- "" or string: treat it as a string whose value is serialized from the parameter
- binary: treat it as a binary data whose value comes from for example OutputBinding<byte[]<
- Returns:
- The dataType which will be used by the Functions runtime.
- Default:
- ""
-
-
-
messageTimeoutMs
int messageTimeoutMs
Local message timeout. This value is only enforced locally and limits the time a produced message waits for successful delivery. A time of 0 is infinite. This is the maximum time used to deliver a message (including retries). Delivery error occurs when either the retry count or the message timeout are exceeded. default: 300000- Returns:
- The local message timeout.
- Default:
- 300000
-
-
-
maxRetries
int maxRetries
How many times to retry sending a failing Message. **Note:** default: 2 Retrying may cause reordering unless EnableIdempotence is set to true.- Returns:
- The number of the max retries.
- See Also:
enableIdempotence()
- Default:
- 2
-
-