Springboot整合RabbitMQ
一、搭建父工程和生产者子模块和消费者子模块
1、搭建父工程
添加依赖如下:
org.springframework.boot spring-boot-starter-parent 2.1.5.RELEASE org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test
2、添加生产者子模块
我们选择基于Spring-Rabbit去操作RabbitMQ。使用 spring-boot-starter-amqp会自动添加spring-rabbit依赖,如下:
org.springframework.boot spring-boot-starter-amqp org.springframework.boot spring-boot-starter-logging
3、添加消费者子模块
添加依赖
org.springframework.boot spring-boot-starter-amqp org.springframework.boot spring-boot-starter-logging
搭建完成后效果如下:
二、生产者
1、创建启动类
@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class); } }
2、创建application.yml
server: port: 44000 spring: application: name: test‐rabbitmq‐producer rabbitmq: host: 127.0.0.1 port: 5672 username: guest password: guest virtual-host: /
3、定义RabbitConfig类,配置Exchange、Queue、及绑定交换机。
本例配置Topic交换机。
import org.springframework.amqp.core.*; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @author zhouwenhao * @date 2022/3/26 * @dec 描述 */ @Configuration public class RabbitmqConfig { public static final String QUEUE_INFORM_EMAIL = "queue_inform_email"; public static final String QUEUE_INFORM_SMS = "queue_inform_sms"; public static final String EXCHANGE_TOPICS_INFORM="exchange_topics_inform"; /** * 交换机配置 * ExchangeBuilder提供了fanout、direct、topic、header交换机类型的配置 * @return the exchange */ @Bean(EXCHANGE_TOPICS_INFORM) public Exchange EXCHANGE_TOPICS_INFORM() { //durable(true)持久化,消息队列重启后交换机仍然存在 return ExchangeBuilder.topicExchange(EXCHANGE_TOPICS_INFORM).durable(true).build(); } //声明队列 @Bean(QUEUE_INFORM_SMS) public Queue QUEUE_INFORM_SMS() { Queue queue = new Queue(QUEUE_INFORM_SMS); return queue; } //声明队列 @Bean(QUEUE_INFORM_EMAIL) public Queue QUEUE_INFORM_EMAIL() { Queue queue = new Queue(QUEUE_INFORM_EMAIL); return queue; } /** channel.queueBind(INFORM_QUEUE_SMS,"inform_exchange_topic","inform.#.sms.#"); * 绑定队列到交换机 . * * @param queue the queue * @param exchange the exchange * @return the binding */ @Bean public Binding BINDING_QUEUE_INFORM_SMS(@Qualifier(QUEUE_INFORM_SMS) Queue queue, @Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange) { return BindingBuilder.bind(queue).to(exchange).with("inform.#.sms.#").noargs(); } @Bean public Binding BINDING_QUEUE_INFORM_EMAIL(@Qualifier(QUEUE_INFORM_EMAIL) Queue queue, @Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange) { return BindingBuilder.bind(queue).to(exchange).with("inform.#.email.#").noargs(); } }
4、在测试类中发送消息
使用RabbitTemplate发送消息
import com.zwh.config.RabbitmqConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest @RunWith(SpringRunner.class) public class Producer05_topics_springboot { @Autowired RabbitTemplate rabbitTemplate; @Test public void testSendByTopics(){ for (int i=0;i<5;i++){ String message = "sms email inform to user"+i; rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM,"inform.sms.email",message); System.out.println("Send Message is:'" + message + "'"); } } }
三、消费者
1、创建启动类
@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class); } }
2、编写配置文件
server: port: 44001 spring: application: name: test‐rabbitmq‐consumer rabbitmq: host: 127.0.0.1 port: 5672 username: guest password: guest virtual-host: /
3、定义RabbitConfig类,配置Exchange、Queue、及绑定交换机。
import org.springframework.amqp.core.*; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @author zhouwenhao * @date 2022/3/26 * @dec 描述 */ @Configuration public class RabbitmqConfig { public static final String QUEUE_INFORM_EMAIL = "queue_inform_email"; public static final String QUEUE_INFORM_SMS = "queue_inform_sms"; public static final String EXCHANGE_TOPICS_INFORM="exchange_topics_inform"; /** * 交换机配置 * ExchangeBuilder提供了fanout、direct、topic、header交换机类型的配置 * @return the exchange */ @Bean(EXCHANGE_TOPICS_INFORM) public Exchange EXCHANGE_TOPICS_INFORM() { //durable(true)持久化,消息队列重启后交换机仍然存在 return ExchangeBuilder.topicExchange(EXCHANGE_TOPICS_INFORM).durable(true).build(); } //声明队列 @Bean(QUEUE_INFORM_SMS) public Queue QUEUE_INFORM_SMS() { Queue queue = new Queue(QUEUE_INFORM_SMS); return queue; } //声明队列 @Bean(QUEUE_INFORM_EMAIL) public Queue QUEUE_INFORM_EMAIL() { Queue queue = new Queue(QUEUE_INFORM_EMAIL); return queue; } /** channel.queueBind(INFORM_QUEUE_SMS,"inform_exchange_topic","inform.#.sms.#"); * 绑定队列到交换机 . * * @param queue the queue * @param exchange the exchange * @return the binding */ @Bean public Binding BINDING_QUEUE_INFORM_SMS(@Qualifier(QUEUE_INFORM_SMS) Queue queue, @Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange) { return BindingBuilder.bind(queue).to(exchange).with("inform.#.sms.#").noargs(); } @Bean public Binding BINDING_QUEUE_INFORM_EMAIL(@Qualifier(QUEUE_INFORM_EMAIL) Queue queue, @Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange) { return BindingBuilder.bind(queue).to(exchange).with("inform.#.email.#").noargs(); } }
4、使用@RabbitListener注解监听队列
import com.rabbitmq.client.Channel; import com.zwh.config.RabbitmqConfig; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component; @Component public class ReceiveHandler { //监听email队列 @RabbitListener(queues = {RabbitmqConfig.QUEUE_INFORM_EMAIL}) public void receive_email(String msg,Message message,Channel channel){ System.out.println(msg); } //监听sms队列 @RabbitListener(queues = {RabbitmqConfig.QUEUE_INFORM_SMS}) public void receive_sms(String msg,Message message,Channel channel){ System.out.println(msg); } }
效果如下:
四、测试
启动生产者工程,发送消息,结果报错如下:
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.5.RELEASE) 2022-03-26 17:35:34.775 INFO 15236 --- [ main] com.zwh.Producer05_topics_springboot : Starting Producer05_topics_springboot on LAPTOP-JRI45NVC with PID 15236 (started by miracle in D:\project\prism\myProject\springboot_parent\rabbitmq_producer) 2022-03-26 17:35:34.776 INFO 15236 --- [ main] com.zwh.Producer05_topics_springboot : No active profile set, falling back to default profiles: default 2022-03-26 17:35:36.042 INFO 15236 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2022-03-26 17:35:36.811 INFO 15236 --- [ main] com.zwh.Producer05_topics_springboot : Started Producer05_topics_springboot in 2.328 seconds (JVM running for 2.934) 2022-03-26 17:35:36.949 INFO 15236 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [127.0.0.1:5672] 2022-03-26 17:35:36.986 INFO 15236 --- [ main] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory#6d4a65c6:0/SimpleConnection@31edeac [delegate=amqp://guest@127.0.0.1:5672/, localPort= 56434] 2022-03-26 17:35:37.004 ERROR 15236 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'exchange_topics_inform' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10) 2022-03-26 17:35:38.022 ERROR 15236 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method (reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'exchange_topics_inform' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10) 2022-03-26 17:35:40.041 ERROR 15236 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method (reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'exchange_topics_inform' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10) 2022-03-26 17:35:44.056 ERROR 15236 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method (reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'exchange_topics_inform' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10) 2022-03-26 17:35:49.076 ERROR 15236 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method (reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'exchange_topics_inform' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10) org.springframework.amqp.AmqpIOException: java.io.IOException at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) at org.springframework.amqp.rabbit.connection.RabbitAccessor.convertRabbitAccessException(RabbitAccessor.java:116) at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2100) at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2047) at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2027) at org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(RabbitAdmin.java:591) at org.springframework.amqp.rabbit.core.RabbitAdmin.lambda$null$10(RabbitAdmin.java:520) at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:287) at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:164) at org.springframework.amqp.rabbit.core.RabbitAdmin.lambda$afterPropertiesSet$11(RabbitAdmin.java:519) at org.springframework.amqp.rabbit.connection.CompositeConnectionListener.onCreate(CompositeConnectionListener.java:36) at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:706) at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:214) at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2073) at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2047) at org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:994) at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:1060) at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:1053) at com.zwh.Producer05_topics_springboot.testSendByTopics(Producer05_topics_springboot.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) Caused by: java.io.IOException at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:126) at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:122) at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:144) at com.rabbitmq.client.impl.ChannelN.exchangeDeclare(ChannelN.java:777) at com.rabbitmq.client.impl.ChannelN.exchangeDeclare(ChannelN.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:1140) at com.sun.proxy.$Proxy79.exchangeDeclare(Unknown Source) at org.springframework.amqp.rabbit.core.RabbitAdmin.declareExchanges(RabbitAdmin.java:689) at org.springframework.amqp.rabbit.core.RabbitAdmin.lambda$initialize$12(RabbitAdmin.java:592) at org.springframework.amqp.rabbit.core.RabbitTemplate.invokeAction(RabbitTemplate.java:2135) at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2094) ... 46 more Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method (reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'exchange_topics_inform' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10) at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:494) at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:288) at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:138) ... 58 more Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method (reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'exchange_topics_inform' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10) at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:516) at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:346) at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:178) at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:111) at com.rabbitmq.client.impl.AMQConnection.readFrame(AMQConnection.java:670) at com.rabbitmq.client.impl.AMQConnection.access$300(AMQConnection.java:48) at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:597) at java.lang.Thread.run(Thread.java:748) 2022-03-26 17:35:49.100 INFO 15236 --- [ Thread-2] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' Process finished with exit code -1
后来发现mq中已经存在一个同名的交换机,我们先删除,再发消息,结果如下:
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.5.RELEASE) 2022-03-26 18:01:58.627 INFO 15816 --- [ main] com.zwh.Producer05_topics_springboot : Starting Producer05_topics_springboot on LAPTOP-JRI45NVC with PID 15816 (started by miracle in D:\project\prism\myProject\springboot_parent\rabbitmq_producer) 2022-03-26 18:01:58.628 INFO 15816 --- [ main] com.zwh.Producer05_topics_springboot : No active profile set, falling back to default profiles: default 2022-03-26 18:01:59.691 INFO 15816 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2022-03-26 18:02:00.398 INFO 15816 --- [ main] com.zwh.Producer05_topics_springboot : Started Producer05_topics_springboot in 1.995 seconds (JVM running for 2.56) 2022-03-26 18:02:00.515 INFO 15816 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [127.0.0.1:5672] 2022-03-26 18:02:00.549 INFO 15816 --- [ main] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory#4d8126f:0/SimpleConnection@73545b80 [delegate=amqp://guest@127.0.0.1:5672/, localPort= 57343] Send Message is:'sms email inform to user0' Send Message is:'sms email inform to user1' Send Message is:'sms email inform to user2' Send Message is:'sms email inform to user3' Send Message is:'sms email inform to user4' 2022-03-26 18:02:00.584 INFO 15816 --- [ Thread-2] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' Process finished with exit code 0
此时交换机如下:
点击交换机,看到该交换机绑定两个队列
查看队列
启动消费工程,结果如下:
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.5.RELEASE) 2022-03-26 18:08:54.349 INFO 5680 --- [ main] com.zwh.Application : Starting Application on LAPTOP-JRI45NVC with PID 5680 (D:\project\prism\myProject\springboot_parent\rabbitmq_consumer\target\classes started by miracle in D:\project\prism\myProject\springboot_parent) 2022-03-26 18:08:54.351 INFO 5680 --- [ main] com.zwh.Application : No active profile set, falling back to default profiles: default 2022-03-26 18:08:54.934 INFO 5680 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 44001 (http) 2022-03-26 18:08:54.946 INFO 5680 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-03-26 18:08:54.946 INFO 5680 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.19] 2022-03-26 18:08:54.999 INFO 5680 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-03-26 18:08:54.999 INFO 5680 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 628 ms 2022-03-26 18:08:55.124 INFO 5680 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2022-03-26 18:08:55.300 INFO 5680 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [127.0.0.1:5672] 2022-03-26 18:08:55.318 INFO 5680 --- [ main] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory#40620d8e:0/SimpleConnection@41aaedaa [delegate=amqp://guest@127.0.0.1:5672/, localPort= 57478] sms email inform to user0 sms email inform to user0 sms email inform to user1 sms email inform to user1 sms email inform to user2 sms email inform to user2 sms email inform to user3 sms email inform to user3 sms email inform to user4 sms email inform to user4 2022-03-26 18:08:55.376 INFO 5680 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 44001 (http) with context path '' 2022-03-26 18:08:55.379 INFO 5680 --- [ main] com.zwh.Application : Started Application in 1.276 seconds (JVM running for 2.107)