public CompletableFuture apply()

in java/showcase/src/main/java/org/apache/flink/statefun/playground/java/showcase/part3/egresses/EgressShowcaseFn.java [67:88]


  public CompletableFuture<Void> apply(Context context, Message message) {
    // there is a specific builder for messages to be sent to a Kafka egress ...
    context.send(
        KafkaEgressMessage.forEgress(KAFKA_EGRESS_TYPENAME)
            .withTopic("my-kafka-topic")
            .withUtf8Key("my-key")
            .withUtf8Value("hello world!")
            .build());

    // ... and also one for messages targeted at Kinesis egresses.
    context.send(
        KinesisEgressMessage.forEgress(KINESIS_EGRESS_TYPENAME)
            .withStream("my-kinesis-stream")
            .withUtf8PartitionKey("my-partition-key")
            .withUtf8ExplicitHashKey("my-explicit-hash-key")
            .withUtf8Value("hello world again!")
            .build());

    // likewise to messaging, writing to egresses are function side-effects that are non-blocking
    // and will be collected once the invocation returns.
    return context.done();
  }