From 2aab522c05569aec5c04e54c53e952005647ebb3 Mon Sep 17 00:00:00 2001
From: Tsuyoshi Ushio Annotation for Kafka output bindings
+ * Place this on a parameter whose value would be written 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.
+ * Annotation for KafkaTrigger bindings
+ * Place 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:
+ *
+ * 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.
+ *
+ *
+ *
+ *
+ * {@literal @}FunctionName("kafkaInupt-Java")
+ *
+ * public String input(
+ * {@literal @}HttpTrigger(name = "request", methods = {HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS)
+ * final String message,
+ * {@literal @}KafkaOutput(name = "database", topic = "users", brokerList="broker:29092") OutputBinding
+ *
+ * @since 1.0.0
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface KafkaOutput {
/**
* The variable name used in function.json.
+ *
* @return The variable name used in function.json.
*/
String name();
@@ -36,38 +66,51 @@
String dataType() default "";
/**
- * Gets the Topic.
- * @return
+ * Defines the Topic.
+ *
+ * @return The topic name.
*/
String topic();
/**
- * Gets or sets the BrokerList.
+ * Defines the BrokerList.
+ *
+ * @return The brokerList name string.
*/
String brokerList();
/**
- * Gets or sets the Maximum transmit message size. Default: 1MB
+ * Defines the maximum transmit message size. Default: 1MB
+ *
+ * @return The maximum trnasmit message size.
*/
int maxMessageBytes() default 1000012; // Follow the kafka spec https://kafka.apache.org/documentation/
/**
- * Maximum number of messages batched in one MessageSet. default: 10000
+ * Defines the maximum number of messages batched in one MessageSet. default: 10000
+ *
+ * @return The maximum number of messages batched in one MessageSet.
*/
int batchSize() default 10000;
/**
* When set to `true`, the producer will ensure that messages are successfully produced exactly once and in the original produce order. default: false
+ *
+ * @return whether idempotence is enabled.
*/
boolean enableIdempotence() default false;
/**
* 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
+ *
+ * @return The local message timeout.
*/
int messageTimeoutMs() default 300000;
/**
* The ack timeout of the producer request in milliseconds. default: 5000
+ *
+ * @return The ack timeout of the producer request in milliseconds.
*/
int requestTimeoutMs() default 5000;
@@ -75,18 +118,24 @@
* How many times to retry sending a failing Message. **Note:** default: 2
* Retrying may cause reordering unless EnableIdempotence is set to true.
* @see #enableIdempotence()
+ *
+ * @return The number of the max retries.
*/
int maxRetries() default 2;
/**
* SASL mechanism to use for authentication.
* Default: PLAIN
+ *
+ * @return The SASL mechanism.
*/
- BrokerAuthenticationMode authenticationMode() default BrokerAuthenticationMode.NOTSET; // TODO double check if it is OK
+ BrokerAuthenticationMode authenticationMode() default BrokerAuthenticationMode.NOTSET;
/**
* SASL username with the PLAIN and SASL-SCRAM-.. mechanisms
* Default: ""
+ *
+ * @return The SASL username.
*/
String username() default "";
@@ -95,12 +144,16 @@
* Default is plaintext
*
* security.protocol in librdkafka
+ *
+ * @return The SASL password.
*/
String password() default "";
/**
* Gets or sets the security protocol used to communicate with brokers
* default is PLAINTEXT
+ *
+ * @return The protocol.
*/
BrokerProtocol protocol() default BrokerProtocol.NOTSET;
@@ -108,24 +161,32 @@
* Path to client's private key (PEM) used for authentication.
* Default ""
* ssl.key.location in librdkafka
+ *
+ * @return The ssl.key.location.
*/
String sslKeyLocation() default "";
- /**
+ /**
* Path to CA certificate file for verifying the broker's certificate.
* ssl.ca.location in librdkafka
+ *
+ * @return The ssl ca location.
*/
String sslCaLocation() default "";
/**
* Path to client's certificate.
* ssl.certificate.location in librdkafka
+ *
+ * @return The client certificate.
*/
String sslCertificateLocation() default "";
/**
* Password for client's certificate.
* ssl.key.password in librdkafka
+ *
+ * @return The password of the client certificate.
*/
String sslKeyPassword() default "";
}
diff --git a/src/main/java/com/microsoft/azure/functions/annotation/KafkaTrigger.java b/src/main/java/com/microsoft/azure/functions/annotation/KafkaTrigger.java
index c00819d..7cb3335 100644
--- a/src/main/java/com/microsoft/azure/functions/annotation/KafkaTrigger.java
+++ b/src/main/java/com/microsoft/azure/functions/annotation/KafkaTrigger.java
@@ -16,7 +16,37 @@
/**
- *
+ *
+ *
+ *
+ * {@literal @}FunctionName("KafkaTrigger-Java")
+ * public void run(
+ * {@literal @}KafkaTrigger(name = "kafkaTrigger",
+ * topic = "users",
+ * brokerList="broker:29092",
+ * consumerGroup="functions")
+ * List<Map<String, String>> kafkaEventData,
+ * final ExecutionContext context
+ * ) {
+ * context.getLogger().info(kafkaEventData);
+ * }
+ *
+ *
+ * @since 1.0.0
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@@ -29,17 +59,23 @@
String name();
/**
- * Gets the Topic.
+ * Defines the Topic.
+ *
+ * @return The topic.
*/
String topic();
/**
- * Gets or sets the BrokerList.
+ * Defines the BrokerList.
+ *
+ * @return The brokerList.
*/
String brokerList();
/**
- * Gets or sets the EventHub connection string when using KafkaOutput protocol header feature of Azure EventHubs.
+ * Defines the EventHub connection string when using KafkaOutput protocol header feature of Azure EventHubs.
+ *
+ * @return The EventHub connection string.
*/
String eventHubConnectionString() default "";
/**
@@ -47,6 +83,8 @@
* 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'
+ *
+ * @return The cardinality.
*/
Cardinality cardinality() default Cardinality.ONE;
/**
@@ -54,11 +92,13 @@
* the kafka events as an array of this type.
* Allowed values: string, binary, stream
* Default: ""
+ *
+ * @return The dataType.
*/
String dataType() default "";
/**
- * Gets or sets the consumer group.
+ * Defines the consumer group.
*/
String consumerGroup();
@@ -66,12 +106,16 @@
* SASL mechanism to use for authentication.
* Allowed values: Gssapi, Plain, ScramSha256, ScramSha512
* Default: PLAIN
+ *
+ * @return The broker authentication mode.
*/
BrokerAuthenticationMode authenticationMode() default BrokerAuthenticationMode.NOTSET;
/**
* SASL username with the PLAIN and SASL-SCRAM-.. mechanisms
* Default: ""
+ *
+ * @return The SASL username.
*/
String username() default "";
@@ -80,12 +124,16 @@
* Default: ""
*
* security.protocol in librdkafka
+ *
+ * @return The SASL password.
*/
String password() default "";
/**
- * Gets or sets the security protocol used to communicate with brokers
+ * Defines the security protocol used to communicate with brokers
* default is PLAINTEXT
+ *
+ * @return The security protocol.
*/
BrokerProtocol protocol() default BrokerProtocol.NOTSET;
@@ -93,24 +141,32 @@
* Path to client's private key (PEM) used for authentication.
* Default ""
* ssl.key.location in librdkafka
+ *
+ * @return The ssl key location.
*/
String sslKeyLocation() default "";
- /**
+ /**
* Path to CA certificate file for verifying the broker's certificate.
* ssl.ca.location in librdkafka
+ *
+ * @return The path to CA certificate file.
*/
String sslCaLocation() default "";
/**
* Path to client's certificate.
* ssl.certificate.location in librdkafka
+ *
+ * @return The ssl certificate location.
*/
String sslCertificateLocation() default "";
/**
* Password for client's certificate.
* ssl.key.password in librdkafka
+ *
+ * @return The ssl key password.
*/
String sslKeyPassword() default "";
}
From ba3f3f13403ddfbed215523c4d32b5556cf0b539 Mon Sep 17 00:00:00 2001
From: Tsuyoshi Ushio
@@ -35,7 +35,7 @@
* public String input(
* {@literal @}HttpTrigger(name = "request", methods = {HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS)
* final String message,
- * {@literal @}KafkaOutput(name = "database", topic = "users", brokerList="broker:29092") OutputBinding
From efd27fb93c5286bfb542ecb71087b598ff4fadf6 Mon Sep 17 00:00:00 2001
From: Tsuyoshi Ushio
- * Place this on a parameter whose value would be written to Kafka. The parameter type should be
+ * 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:
* Defines how Functions runtime should treat the parameter value. Possible values are: Defines how Functions runtime should treat the parameter value. Possible values are:
From 3648b89bbc764c0a18991484b6aa1bcde6a0f38a Mon Sep 17 00:00:00 2001
From: Tsuyoshi Ushio
*
* @return The dataType which will be used by the Functions runtime.
*/
diff --git a/src/main/java/com/microsoft/azure/functions/annotation/KafkaTrigger.java b/src/main/java/com/microsoft/azure/functions/annotation/KafkaTrigger.java
index fabe4d8..d998911 100644
--- a/src/main/java/com/microsoft/azure/functions/annotation/KafkaTrigger.java
+++ b/src/main/java/com/microsoft/azure/functions/annotation/KafkaTrigger.java
@@ -51,6 +51,7 @@
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface KafkaTrigger {
+
/**
* The variable name used in function code for the request or request body.
*
@@ -87,13 +88,15 @@
* @return The cardinality.
*/
Cardinality cardinality() default Cardinality.ONE;
+
/**
- * DataType for the Cardinality settings. If you set the cardinality as Cardinality.MANY, Azure Functions Host will deserialize
- * the kafka events as an array of this type.
- * Allowed values: string, binary, stream
- * Default: ""
- *
- * @return The dataType.
+ *
+ *
+ * @return The dataType which will be used by the Functions runtime.
*/
String dataType() default "";
From b098c745a87b20b5ee45bfa62d77916789821bb7 Mon Sep 17 00:00:00 2001
From: Tsuyoshi Ushio
*
*
*
*
*
*