heanbian-kafka

Heanbian kafka component.

License

License

GroupId

GroupId

com.heanbian.block
ArtifactId

ArtifactId

heanbian-kafka
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

heanbian-kafka
Heanbian kafka component.
Project Organization

Project Organization

Heanbian

Download heanbian-kafka

How to add to project

<!-- https://jarcasting.com/artifacts/com.heanbian.block/heanbian-kafka/ -->
<dependency>
    <groupId>com.heanbian.block</groupId>
    <artifactId>heanbian-kafka</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.heanbian.block/heanbian-kafka/
implementation 'com.heanbian.block:heanbian-kafka:1.0.1'
// https://jarcasting.com/artifacts/com.heanbian.block/heanbian-kafka/
implementation ("com.heanbian.block:heanbian-kafka:1.0.1")
'com.heanbian.block:heanbian-kafka:jar:1.0.1'
<dependency org="com.heanbian.block" name="heanbian-kafka" rev="1.0.1">
  <artifact name="heanbian-kafka" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.heanbian.block', module='heanbian-kafka', version='1.0.1')
)
libraryDependencies += "com.heanbian.block" % "heanbian-kafka" % "1.0.1"
[com.heanbian.block/heanbian-kafka "1.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.apache.kafka : kafka-clients jar 2.7.0
org.springframework : spring-context jar 5.3.4
com.fasterxml.jackson.core : jackson-databind jar 2.12.1

Project Modules

There are no modules declared in this project.

heanbian-kafka-client

前提条件

JDK11+

pom.xml

具体版本,可以上Maven中央仓库查询

<dependency>
	<groupId>com.heanbian.block</groupId>
	<artifactId>heanbian-kafka</artifactId>
	<version>1.0.2</version>
</dependency>

使用示例

配置 application.yml

kafka.servers:: 192.168.1.101:2181,192.168.1.102:2181,192.168.1.103:2181

Spring Boot 启动类添加注解:

@EnableKafkaClient

Java代码片段:

//生产者
@Autowired
private DefaultKafkaProducer defaultKafkaProducer;

//消费者
@Component
public class TestConsumer {

	@kafkaListener(topic = "test")
	public void consumer(String data) {
		// TODO

	}
	
	@kafkaListener(topic = "test-1")
	public void consumer(Test test) {
		// TODO

	}

}

说明:适用于 Spring Boot 2.x 项目。

Versions

Version
1.0.1
1.0.0