1 Star 0 Fork 1

zhouanan511/camel-spring-boot-examples2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
README.adoc 1.82 KB
一键复制 编辑 原始数据 按行查看 历史

Camel Kafka example

Introduction

An example which shows how to integrate Camel with Kafka offsetRepository(consumer) to use in order to locally store the offset of each partition of the topic

This project consists of the following examples:

  1. Producer triggers with a timer and produces messages to the configured topic partition

  2. Consumer consumes from configured topic by reading the offset value from locally stored file.

Preparing Kafka

This example requires that Kafka Server is up and running.

$ ${KAFKA}/bin/zookeeper-server-start.sh ${KAFKA}/config/zookeeper.properties
$ ${KAFKA}/bin/kafka-server-start.sh ${KAFKA}/config/server.properties

You will need to create following topics before you run the examples.

On windows run

$ ${KAFKA}/bin/kafka-topics.bat --create --zookeeper <zookeeper host ip>:<port> --replication-factor 1 --partitions 1 --topic my-topic

On linux run

$ ${KAFKA}/bin/kafka-topics.sh --create --zookeeper <zookeeper host ip>:<port> --replication-factor 1 --partitions 1 --topic my-topic

Build

You will need to compile this example first:

$ mvn compile

Run

Run the consumer first in separate shell

$ mvn spring-boot:run

camel-context.xml file has both kafka-producer and kafka-consumer routes defined to produce/consume messages to topic my-topic.

Press Ctrl-C to exit.

Configuration

You can configure the details in the file: src/main/resources/application.properties

You can enable verbose logging by adjusting the src/main/resources/log4j2.properties file as documented in the file.

Help and contributions

If you hit any problem using Camel or have some feedback, then please let us know.

We also love contributors, so get involved :-)

The Camel riders!

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhouanan511/camel-spring-boot-examples2.git
git@gitee.com:zhouanan511/camel-spring-boot-examples2.git
zhouanan511
camel-spring-boot-examples2
camel-spring-boot-examples2
camel-3.4.x

搜索帮助

0d507c66 1850385 C8b1a773 1850385