网站如何进行品牌建设,网站建设找翰诺,网站建设公司选择哪家好,插件wordpressActiveMQ简单使用
JMS ActiveMQ
下载安装
https://activemq.apache.org/components/classic/download/解压缩文件。进入win64目录#xff0c;双击运行activemq.bat文件#xff0c;运行服务 将下面的网址输入到浏览器#xff0c;用户名和密码都是admin SpringBoot整合Act…ActiveMQ简单使用
JMS ActiveMQ
下载安装
https://activemq.apache.org/components/classic/download/
解压缩文件。进入win64目录双击运行activemq.bat文件运行服务 将下面的网址输入到浏览器用户名和密码都是admin SpringBoot整合ActiveMQ
导入坐标
dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-activemq/artifactId/dependency添加配置
server:port: 8080spring:activemq:broker-url: tcp://localhost:61616jms:template:default-destination: itheima实现业务类
package com.ustc.service.activemq;import com.ustc.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;Service
public class MessageServiceActivemqImpl implements MessageService {Autowiredprivate JmsMessagingTemplate messagingTemplate;Overridepublic void sendMessage(String id) {System.out.println(待发送短信的订单已经纳入处理对队列id id);messagingTemplate.convertAndSend(id);}Overridepublic String doMessge() {String id messagingTemplate.receiveAndConvert(String.class);System.out.println(已经完成短信发送服务:id id);return id;}
}