springboot 简单使用 activemq 接收消息

1.在pom.xml 加入配置文件

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>

2.编辑代码

import org.springframework.jms.annotation.JmsListener;

@Component
public class BpmReceiver {

    @Resource
    JdbcTemplate jdbcTemplate;
    
    @JmsListener(destination = "oa")
        public void  receivedMessage(String message){
        }
}

这个消息message 是从队列读取的消息。

@JmsListener(destination = "oa")

这个 destination  表示队列名称。

3.编辑配置文件

spring:
  activemq: 
    broker-url: tcp://localhost:62222

这样程序就可以从指定的队列读取消息了。

 

猜你喜欢

转载自www.cnblogs.com/yg_zhang/p/10605186.html