-
Notifications
You must be signed in to change notification settings - Fork 33
/
ConsumeMessageFromKafka.java
28 lines (23 loc) · 1.1 KB
/
ConsumeMessageFromKafka.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.function;
import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.annotation.FunctionName;
import com.microsoft.azure.functions.dapr.annotation.DaprBindingTrigger;
public class ConsumeMessageFromKafka {
/**
* The function is triggered by Kafka messages in the Kafka instance referenced by
* the Kafka binding configured under components/kafka-bindings.yaml
* Can be used as an alternative for the node-app in the Dapr Bindings sample
* found at https://github.com/dapr/quickstarts/tree/master/bindings/nodeapp
*/
@FunctionName("ConsumeMessageFromKafka")
public String run(
@DaprBindingTrigger(
bindingName = "%KafkaBindingName%")
String triggerData,
final ExecutionContext context) {
context.getLogger().info("'Java function processed a ConsumeMessageFromKafka request from the Dapr Runtime.'");
context.getLogger().info("Hello from Kafka!");
context.getLogger().info(String.format("Triggered data: %s", triggerData));
return triggerData;
}
}