SpringBoot整合ActiveMQ:专业负责MQ20年~

简介: ACTIVEMQActiveMQ下载MQ后启动一下(Windows版本)#启动信息...jvm 1 | INFO | Listening for connections at ws://JackWen:61614?maximumConnections=1000&wireFormat.

img_84ac4c2f13646c23f2fbbb099c19848c.png
ACTIVEMQ

ActiveMQ

下载MQ后启动一下(Windows版本)

#启动信息
...
jvm 1    |  INFO | Listening for connections at ws://JackWen:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600
jvm 1    |  INFO | Connector ws started
jvm 1    |  INFO | Apache ActiveMQ 5.14.0 (localhost, ID:JackWen-3764-1535341346100-0:1) started
jvm 1    |  INFO | For help or more information please see: http://activemq.apache.org
jvm 1    |  WARN | Store limit is 102400 mb (current store usage is 4 mb). The data directory: D:\ActiveMQ\apache-activemq-5.14.0\bin\win32\..\..\data\kahadb only has 56508 mb of usable space. - resetting to maximum available disk space: 56508 mb
jvm 1    |  INFO | No Spring WebApplicationInitializer types detected on classpath
jvm 1    |  INFO | ActiveMQ WebConsole available at http://0.0.0.0:8161/
jvm 1    |  INFO | ActiveMQ Jolokia REST API available at http://0.0.0.0:8161/api/jolokia/
jvm 1    |  INFO | Initializing Spring FrameworkServlet 'dispatcher'
jvm 1    |  INFO | No Spring WebApplicationInitializer types detected on classpath
jvm 1    |  INFO | jolokia-agent: Using policy access restrictor classpath:/jolokia-access.xml
jvm 1    |  INFO | Connector vm://localhost started
jvm 1    |  WARN | Transport Connection to: tcp://127.0.0.1:4013 failed: java.net.SocketException: Connection reset

访问:http://localhost:8161/

与SpringBoot项目整合

pom.xml

<!--activeMQ-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-pool</artifactId>
        </dependency>

application.properties

#ActiveMQ
spring.activemq.broker-url=tcp://localhost:61616
img_eca85026eace8dbc57fde4108a24543c.png
mq

生产者:implements MessageCreator

/**
 * 消息生产者
 */
public class Producer implements MessageCreator {
    @Override
    public Message createMessage(Session session) throws JMSException {
        return session.createTextMessage("消息生产者创建的一条消息");
    }
}

消费者:@JmsListener(destination = "xxx")

@Component
public class Consumer {
    @JmsListener(destination = "message_LPMQ")
    public void getMessage(String message){
        System.out.println(message);
    }
}

SpringBoot启动类测试:@Autowired JmsTemplate and implements CommandLineRunner

@SpringBootApplication
public class SpringbootdemoApplication implements CommandLineRunner {
 public static void main(String[] args) {

        SpringApplication.run(SpringbootdemoApplication.class, args);
    }

    /**
     * MQ: 发送消息
     */
    @Autowired
    private JmsTemplate jmsTemplate;

  
    @Override
    public void run(String... args) throws Exception {
        jmsTemplate.send("message_LPMQ",new Producer());
    }
}
img_f34d13118e5ea41b8dfd1b9c407039c7.png
test

img_a63a6186c09c41a9cbbc01dd885311b6.png
消息中心
目录
相关文章
|
3月前
|
消息中间件 Java
SpringBoot使用ActiveMq同时支持点对点推送和发布订阅
SpringBoot使用ActiveMq同时支持点对点推送和发布订阅
14 0
|
3月前
|
消息中间件 Java Kafka
SpringBoot整合 ActiveMQ快速入门 实现点对点推送
SpringBoot整合 ActiveMQ快速入门 实现点对点推送
29 0
|
4月前
|
前端开发 Java 关系型数据库
基于Springboot实现专业认证材料管理系统
基于Springboot实现专业认证材料管理系统
|
9月前
|
消息中间件 Java
SpringBoot使用ActiveMq同时支持点对点推送和发布订阅
SpringBoot使用ActiveMq同时支持点对点推送和发布订阅
81 0
|
9月前
|
消息中间件 Java
springboot整合ActiveMQ(点对点+发布订阅)
springboot整合ActiveMQ(点对点+发布订阅)
|
6月前
考研专业课程管理系统 毕业设计 JAVA+Vue+SpringBoot+MySQL(二)
考研专业课程管理系统 毕业设计 JAVA+Vue+SpringBoot+MySQL
|
6月前
|
Java 测试技术 数据库
考研专业课程管理系统 毕业设计 JAVA+Vue+SpringBoot+MySQL(一)
考研专业课程管理系统 毕业设计 JAVA+Vue+SpringBoot+MySQL
|
9月前
|
消息中间件 Java Kafka
SpringBoot整合 ActiveMQ快速入门 实现点对点推送
SpringBoot整合 ActiveMQ快速入门 实现点对点推送
126 0
|
12月前
|
消息中间件 JavaScript 小程序
别再用 if 校验参数了,太Low!这才是专业的 SpringBoot 参数校验方式!
别再用 if 校验参数了,太Low!这才是专业的 SpringBoot 参数校验方式!
|
前端开发 Java 关系型数据库
基于Springboot实现专业认证材料管理系统
基于Springboot实现专业认证材料管理系统
基于Springboot实现专业认证材料管理系统

热门文章

最新文章