提交 bbfe7ec1 编写于 作者: 武汉红喜's avatar 武汉红喜

optimise

上级 dbc1b906
......@@ -20,18 +20,6 @@
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package org.hongxi.whatsmars.kafka;
/**
* Created by shenhongxi on 2018/12/12.
*/
public class KafkaTests {
}
......@@ -6,6 +6,9 @@ import org.apache.rocketmq.spring.starter.core.RocketMQListener;
import org.apache.rocketmq.spring.starter.enums.ConsumeMode;
import org.springframework.stereotype.Service;
/**
* 顺序消息消费失败,默认不重试(本人修改点)
*/
@Slf4j
@Service
@RocketMQMessageListener(topic = "test-topic-4", consumerGroup = "my-consumer_test-topic-4",
......
......@@ -7,6 +7,9 @@ import org.apache.rocketmq.spring.starter.core.RocketMQListener;
import org.apache.rocketmq.spring.starter.enums.ConsumeMode;
import org.springframework.stereotype.Service;
/**
* 配置重试次数(本人修改点) reconsumeTimes
*/
@Slf4j
@Service
@RocketMQMessageListener(topic = "test-topic-4", consumerGroup = "my-consumer_test-topic-5",
......
package org.hongxi.whatsmars.rocketmq.boot.producer;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.starter.core.RocketMQTemplate;
import org.apache.rocketmq.spring.starter.enums.MessageDelayLevel;
import org.hongxi.whatsmars.rocketmq.boot.OrderPaidEvent;
......@@ -11,6 +14,7 @@ import org.springframework.messaging.support.MessageBuilder;
import java.math.BigDecimal;
@Slf4j
@SpringBootApplication
public class ProducerApplication implements CommandLineRunner {
@Autowired
......@@ -31,7 +35,19 @@ public class ProducerApplication implements CommandLineRunner {
rocketMQTemplate.send("test-topic-1", MessageBuilder.withPayload("Hello, World! I'm from spring message").build());
rocketMQTemplate.convertAndSend("test-topic-2", new OrderPaidEvent("T_001", new BigDecimal("88.00")));
rocketMQTemplate.sendDelayed("test-topic-1", MessageBuilder.withPayload("I'm delayed message").build(), MessageDelayLevel.TIME_1M);
rocketMQTemplate.sendOneWay("test-topic-1", MessageBuilder.withPayload("I'm one way message").build());
rocketMQTemplate.syncSendOrderly("test-topic-4", MessageBuilder.withPayload("I'm order message").build(), "1234");
rocketMQTemplate.asyncSend("test-topic-1", MessageBuilder.withPayload("I'm async message").build(), new SendCallback() {
@Override
public void onSuccess(SendResult sendResult) {
log.info("async: {}", sendResult);
}
@Override
public void onException(Throwable e) {
log.error(e.getMessage(), e);
}
});
System.out.println("send finished!");
// rocketMQTemplate.destroy(); // notes: once rocketMQTemplate be destroyed, you can not send any message again with this rocketMQTemplate
......
[kafka原理与特性](https://blog.csdn.net/javahongxi/article/details/85109383)
\ No newline at end of file
#!bin/sh
\ No newline at end of file
......@@ -49,28 +49,5 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly:package</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>release</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/conf</directory>
<outputDirectory>/conf</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.basedir}/start.sh</source>
<outputDirectory>/</outputDirectory>
</file>
<file>
<source>${project.basedir}/down.sh</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>lib</outputDirectory><!-- 将scope为runtime的依赖包打包到lib目录下。 -->
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
\ No newline at end of file
......@@ -15,7 +15,7 @@
<property name="cnName" value="火星" />
</bean>
<!-- 线程池 -->
<!-- 线程池建议用这个,不建议用Executes (队列长度或线程数不可控) -->
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor" >
<!-- 核心线程数 -->
<property name="corePoolSize" value="10" />
......
#!bin/sh
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册