activemq spring客户端
发表于:2025-02-23 作者:千家信息网编辑
千家信息网最后更新 2025年02月23日,一、dependency 5.15.4 4.8 5.0.7.RELEASE
千家信息网最后更新 2025年02月23日activemq spring客户端
一、dependency
5.15.4 4.8 5.0.7.RELEASE org.apache.activemq activemq-client ${activemq.version} org.apache.activemq activemq-spring ${activemq.version} org.apache.activemq activemq-pool ${activemq.version} org.apache.activemq activemq-broker ${activemq.version} org.apache.xbean xbean-spring ${xbean-spring.version} org.springframework spring-jms ${spring-jms.version} org.springframework spring-core org.springframework spring-beans org.springframework spring-context org.springframework spring-context-support org.apache.commons commons-pool2 org.slf4j slf4j-log4j12 org.apache.logging.log4j log4j-core
二、activemq.properties
active.config.brokerURL=failover:(tcp://localhost:61617,tcp://localhost:61618,tcp://localhost:61619)active.config.username=adminactive.config.password=admin123active.destination.queue.name=queue.test01active.destination.topic.name=topic.test01
三、spring-activemq-producer.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
${active.config.brokerURL}
${active.config.username}
${active.config.password}
四、spring-activemq-consumer.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
${active.config.brokerURL}
${active.config.username}
${active.config.password}
五、相关业务实现类
producer相关类:
import org.springframework.jms.core.JmsTemplate;
import javax.jms.Destination;
public abstract class AbstractActivemqProducer {
private JmsTemplate jmsTemplate;
private Destination destination;
public AbstractActivemqProducer(JmsTemplate jmsTemplate, Destination destination) {
this.jmsTemplate = jmsTemplate;
this.destination = destination;
}
public void send(String msg){
jmsTemplate.convertAndSend(destination, msg);
}
}
public class QueueActivemqProducer extends AbstractActivemqProducer {
public QueueActivemqProducer(JmsTemplate jmsTemplate, Destination destination) {
super(jmsTemplate, destination);
}
}
public class TopicActivemqProducer extends AbstractActivemqProducer {
public TopicActivemqProducer(JmsTemplate jmsTemplate, Destination destination) {
super(jmsTemplate, destination);
}
}
customer相关类:
public class CustomerMsgListener implements MessageListener { private BusinessHandler businessHandler; public CustomerMsgListener(BusinessHandler businessHandler) { this.businessHandler = businessHandler; } @Override public void onMessage(Message message) { try { if (message instanceof TextMessage) { businessHandler.handle(((TextMessage) message).getText() ); } if (message instanceof MapMessage) { MapMessage mapMessage = (MapMessage) message; businessHandler.handle(mapMessage.getString("key01") ); businessHandler.handle(mapMessage.getString("key02") ); } } catch (JMSException e) { e.printStackTrace(); } }}public interface BusinessHandler { void handle(String msg);}public class QueueHandler implements BusinessHandler { @Override public void handle(String msg) { System.out.println("msg = [" + msg + "]"); }}
六、测试
public class XmlActivemqTest { public static void main(String[] args) { customerXml(); } public static void producerXml(){ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath*:spring-activemq-producer.xml"); AbstractActivemqProducer queueActivemqProducer = context.getBean(QueueActivemqProducer.class); queueActivemqProducer.send("this is a test"); } public static void customerXml(){ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath*:spring-activemq-customer.xml"); }}
参考地址:
http://activemq.apache.org/spring-support.html
http://docs.spring.io/spring/docs/2.5.x/reference/jms.html#jms-mdp
时间
最大
业务
倍数
地址
参考
延迟
测试
客户
客户端
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
汽车合格证信息多久传到数据库
群星进服务器显示连接
服务器的硬盘能装机吗
高校网络安全科职责
计算机网络技术转专业
mac http服务器
网站服务器安全软件下载
互联网科技热评
泰国公益广告软件开发
软件开发中se的职位描述
java 数据库锁
怎么用自己的整合包开服务器
网络安全活动主题班会小结
运营商网络安全必要性
数据库就业领域
端游泰拉瑞亚服务器端口
被黑影响服务器吗
淄博市网络安全协会
网络安全法只能在国内使用
新时代网络安全做我做起
软件开发变更控制
服务器运维时显示请先配置客户端
无法解决数据库报错
教师软件开发课题立项题目
基岩版中文服务器推荐
软件开发中se的职位描述
亿图怎样添加数据库
博彩软件开发平台
qq服务器连接产品
守护儿童网络安全