-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(kafka-example): add example for schema with with examples in ya…
…ml format
- Loading branch information
Showing
5 changed files
with
145 additions
and
3 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...e/src/main/java/io/github/stavshamir/springwolf/example/kafka/consumers/YamlConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.kafka.consumers; | ||
|
||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncListener; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncMessage; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncOperation; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.KafkaAsyncOperationBinding; | ||
import io.github.stavshamir.springwolf.example.kafka.dtos.YamlPayloadDto; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.kafka.annotation.KafkaListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class YamlConsumer { | ||
|
||
@AsyncListener( | ||
operation = | ||
@AsyncOperation( | ||
channelName = "yaml-topic", | ||
description = "Showcases a xml based message", | ||
message = @AsyncMessage(contentType = "application/yaml"))) | ||
@KafkaAsyncOperationBinding | ||
@KafkaListener(topics = "yaml-topic") | ||
public void receiveExamplePayload(YamlPayloadDto payload) { | ||
log.info("Received new message in example-queue: {}", payload.toString()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...mple/src/main/java/io/github/stavshamir/springwolf/example/kafka/dtos/YamlPayloadDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.kafka.dtos; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class YamlPayloadDto { | ||
|
||
private String someString; | ||
|
||
private long someLong; | ||
|
||
private ExampleEnum someEnum; | ||
|
||
public enum ExampleEnum { | ||
FOO1, | ||
FOO2, | ||
FOO3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters