@Target(value=PARAMETER) @Retention(value=RUNTIME) public @interface KafkaOutput
Place this on a parameter whose value would be published to Kafka. The parameter type should be OutputBinding<T>, where T could be one of:
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 + "\" }";
}
| Modifier and Type | Required Element and Description |
|---|---|
String |
brokerList
Defines the BrokerList.
|
String |
name
The variable name used in function.json.
|
String |
topic
Defines the Topic.
|
| Modifier and Type | Optional Element and Description |
|---|---|
com.microsoft.azure.functions.BrokerAuthenticationMode |
authenticationMode
SASL mechanism to use for authentication.
|
String |
avroSchema
Avro schema for generic record serialization
default ""
|
int |
batchSize
Defines the maximum number of messages batched in one MessageSet.
|
String |
dataType
Defines how Functions runtime should treat the parameter value.
|
boolean |
enableIdempotence
When set to `true`, the producer will ensure that messages are successfully produced exactly once and in the original produce order.
|
int |
lingerMs
linger.MS property provides the time between batches of messages
being sent to cluster.
|
int |
maxMessageBytes
Defines the maximum transmit message size.
|
int |
maxRetries
How many times to retry sending a failing Message.
|
int |
messageTimeoutMs
Local message timeout.
|
String |
password
SASL password with the PLAIN and SASL-SCRAM-..
|
com.microsoft.azure.functions.BrokerProtocol |
protocol
Gets or sets the security protocol used to communicate with brokers
default is PLAINTEXT
|
int |
requestTimeoutMs
The ack timeout of the producer request in milliseconds.
|
String |
schemaRegistryPassword
Password for the Avro Schema Registry
default ""
|
String |
schemaRegistryUrl
URL for the Avro Schema Registry
default ""
|
String |
schemaRegistryUsername
Username for the Avro Schema Registry
default ""
|
String |
sslCaLocation
Path to CA certificate file for verifying the broker's certificate.
|
String |
sslCertificateLocation
Path to client's certificate.
|
String |
sslKeyLocation
Path to client's private key (PEM) used for authentication.
|
String |
sslKeyPassword
Password for client's certificate.
|
String |
username
SASL username with the PLAIN and SASL-SCRAM-..
|
public abstract String name
public abstract String topic
public abstract String brokerList
public abstract String dataType
Defines how Functions runtime should treat the parameter value. Possible values are:
public abstract int maxMessageBytes
public abstract int batchSize
public abstract boolean enableIdempotence
public abstract int messageTimeoutMs
public abstract int requestTimeoutMs
public abstract int maxRetries
enableIdempotence()public abstract com.microsoft.azure.functions.BrokerAuthenticationMode authenticationMode
public abstract String username
public abstract String password
public abstract com.microsoft.azure.functions.BrokerProtocol protocol
public abstract String sslKeyLocation
public abstract String sslCaLocation
public abstract String sslCertificateLocation
public abstract String sslKeyPassword
public abstract int lingerMs
public abstract String avroSchema
public abstract String schemaRegistryUrl
public abstract String schemaRegistryUsername
public abstract String schemaRegistryPassword
Copyright © 2023. All rights reserved.