当前位置: 首页 > news >正文

页面访问升级正常更新中seo最新技巧

页面访问升级正常更新中,seo最新技巧,望牛墩东莞网站建设,商会网站建设ActiveMQ 和 JMS的关系? ActiveMQ是流行的开源消息中间件,JMS是Java平台定义的一种消息传递的标准。ActiveMQ实现了JMS规范,因此可以使用JMS API来与ActiveMQ进行交互。 JMS定义了一种标准的API。API包括了一些接口和类,用于创建…

ActiveMQ 和 JMS的关系?

ActiveMQ是流行的开源消息中间件,JMS是Java平台定义的一种消息传递的标准。ActiveMQ实现了JMS规范,因此可以使用JMS API来与ActiveMQ进行交互。

JMS定义了一种标准的API。API包括了一些接口和类,用于创建、发送、接收和处理消息。ActiveMQ实现了这些接口和类,并提供了一些额外的功能,例如消息持久化、消息过滤、事务支持等。


JmsMessagingTemplate跟ActiveMQ的关系?

JmsMessagingTemplate是Spring框架提供的JMS消息发送工具类,封装了JMS API的细节,使得发送JMS消息变得更加简单和方便。

JmsMessagingTemplate可以与任何实现了JMS规范的消息中间件集成,包括ActiveMQ。使用JmsMessagingTemplate发送消息时,需要指定目标消息队列或主题,以及消息内容。JmsMessagingTemplate会将消息封装成JMS消息对象,并通过JMS API将消息发送到指定的消息队列或主题。ActiveMQ则负责接收JMS消息,并将其存储在消息队列或主题中,等待消费者进行消费。

@JmsListener的作用?

@JmsListener是Spring JMS提供的一个注解,用于监听JMS消息队列或主题,并在收到消息时执行相应的方法。


ActiveMQ用法

引入依赖

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

application.properties配置文件

spring.activemq.broker-url=tcp://localhost:61616
spring.activemq.user=admin
spring.activemq.password=admin
# 队列名-支持自定义
spring.activemq.queue-name=queueTest
# 主题名-支持自定义
spring.activemq.topic-name=topicTest

配置类

// 加上@EnableJms是异步,不加默认是同步
@Configuration
public class ActiveMqConfig {@Value("${spring.activemq.broker-url}")private String brokerUrl;@Value("${spring.activemq.user}")private String userName;@Value("${spring.activemq.password}")private String password;@Value("${spring.activemq.queue-name}")private String queueName;@Value("${spring.activemq.topic-name}")private String topicName;@Bean(name = "queue")public Queue queue() {return new ActiveMQQueue(queueName);}@Bean(name = "topic")public Topic topic(){return new ActiveMQTopic(topicName);}@Beanpublic ConnectionFactory connectionFactory(){return new ActiveMQConnectionFactory(userName, password, brokerUrl);}/*** 在Queue模式中,对消息的监听需要对containerFactory进行配置* @param connectionFactory* @return*/@Bean("queueListener")public JmsListenerContainerFactory<?> queueJmsListenerContainerFactory(ConnectionFactory connectionFactory){SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();factory.setConnectionFactory(connectionFactory);// false的队列,true是主题factory.setPubSubDomain(false);return factory;}/*** 在topic模式中,对消息的监听需要对containerFactory进行配置* @param connectionFactory* @return*/@Bean("topicListener")public JmsListenerContainerFactory<?> topicJmsListenerContainerFactory(ConnectionFactory connectionFactory){SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();factory.setConnectionFactory(connectionFactory);// false的队列,true是主题factory.setPubSubDomain(true);return factory;}
}

生产者

@RestController
@RequestMapping("/activemq")
public class ProducerController {@Resourceprivate JmsMessagingTemplate jmsMessagingTemplate;@Autowiredprivate Queue queue;@Autowiredprivate Topic topic;/*** queue模式mq消息发送* @param msg* @return*/@GetMapping("/queue")public String sendQueue(String msg) {jmsMessagingTemplate.convertAndSend(queue, msg);return "success, 发送消息:" + msg;}/*** topic模式一对多的消息队列的生产者* @param msg*/@GetMapping("/topic")public String sendMsgTopic(@RequestParam String msg){jmsMessagingTemplate.convertAndSend(topic,msg);return "success, 发送消息:" + msg;}
}

消费者

@Component
public class Consumer {/*** queue模式的消费者* @param msg*/@JmsListener(destination="${spring.activemq.queue-name}", containerFactory="queueListener")public void queueConsumer(String msg) {System.out.println("queue收到消息:" + msg);}/*** topic模式的消费者* @param msg*/@JmsListener(destination = "${spring.activemq.topic-name}", containerFactory = "topicListener")public void topicConsumer(String msg){System.out.println("topic收到消息:" + msg);}
}

原文博客:https://blog.csdn.net/imVainiycos/article/details/126021665?spm=1001.2014.3001.5506


文章转载自:
http://dinncosociocentric.tpps.cn
http://dinncosecession.tpps.cn
http://dinncoemblem.tpps.cn
http://dinncoqstol.tpps.cn
http://dinncovoluminous.tpps.cn
http://dinncoaxel.tpps.cn
http://dinncoglair.tpps.cn
http://dinncofuniform.tpps.cn
http://dinncodisparlure.tpps.cn
http://dinncocommunize.tpps.cn
http://dinncotipcart.tpps.cn
http://dinncocaballer.tpps.cn
http://dinncocbpi.tpps.cn
http://dinncodaniel.tpps.cn
http://dinncoarhus.tpps.cn
http://dinncopondfish.tpps.cn
http://dinncobomblet.tpps.cn
http://dinncodynasty.tpps.cn
http://dinncoconqueringly.tpps.cn
http://dinncoquinquepartite.tpps.cn
http://dinncolobster.tpps.cn
http://dinncovisitandine.tpps.cn
http://dinncoirreverential.tpps.cn
http://dinncotrackway.tpps.cn
http://dinnconegrophilism.tpps.cn
http://dinncotomnoddy.tpps.cn
http://dinncoscarcity.tpps.cn
http://dinncostaircase.tpps.cn
http://dinncokiamusze.tpps.cn
http://dinncoinciting.tpps.cn
http://dinncohurlbat.tpps.cn
http://dinncotrapt.tpps.cn
http://dinncozooblast.tpps.cn
http://dinncomerl.tpps.cn
http://dinncoendogenous.tpps.cn
http://dinncohousephone.tpps.cn
http://dinncobedel.tpps.cn
http://dinncoincalculably.tpps.cn
http://dinncoepruinose.tpps.cn
http://dinncoacidemia.tpps.cn
http://dinncodisband.tpps.cn
http://dinncobeleaguer.tpps.cn
http://dinncokoa.tpps.cn
http://dinncophonophore.tpps.cn
http://dinncolithometeor.tpps.cn
http://dinncocylindric.tpps.cn
http://dinncoabstrusity.tpps.cn
http://dinncosigmate.tpps.cn
http://dinncoklamath.tpps.cn
http://dinncoguileful.tpps.cn
http://dinncopediatrist.tpps.cn
http://dinncovaricosis.tpps.cn
http://dinncodipnoan.tpps.cn
http://dinncoaconitic.tpps.cn
http://dinncoreprofile.tpps.cn
http://dinncodulocracy.tpps.cn
http://dinncoexegetical.tpps.cn
http://dinncotemporal.tpps.cn
http://dinncourologic.tpps.cn
http://dinncobenthic.tpps.cn
http://dinncovoile.tpps.cn
http://dinncolacy.tpps.cn
http://dinncoimpoverishment.tpps.cn
http://dinncoshoplifter.tpps.cn
http://dinncocelestially.tpps.cn
http://dinncoadnex.tpps.cn
http://dinncogastriloquy.tpps.cn
http://dinncoepicurism.tpps.cn
http://dinncoairmail.tpps.cn
http://dinncocentennial.tpps.cn
http://dinncomyxoedema.tpps.cn
http://dinncocomfortable.tpps.cn
http://dinncoincandescence.tpps.cn
http://dinncomissense.tpps.cn
http://dinncopsychopharmacologist.tpps.cn
http://dinncomagnetizer.tpps.cn
http://dinncoerotical.tpps.cn
http://dinncosyngas.tpps.cn
http://dinncohedy.tpps.cn
http://dinncolaryngeal.tpps.cn
http://dinncoengagement.tpps.cn
http://dinncoposthumous.tpps.cn
http://dinncofigurable.tpps.cn
http://dinncogyrectomy.tpps.cn
http://dinncocrosse.tpps.cn
http://dinncohydrocolloid.tpps.cn
http://dinncogown.tpps.cn
http://dinncosolebar.tpps.cn
http://dinncoinshoot.tpps.cn
http://dinncocataphonic.tpps.cn
http://dinncowirily.tpps.cn
http://dinncosedentarily.tpps.cn
http://dinncoiaupe.tpps.cn
http://dinncoobtusely.tpps.cn
http://dinncoeulogy.tpps.cn
http://dinncoventilate.tpps.cn
http://dinncopeculiarity.tpps.cn
http://dinncobrassin.tpps.cn
http://dinncoceti.tpps.cn
http://dinncosubdeacon.tpps.cn
http://www.dinnco.com/news/148448.html

相关文章:

  • 欧洲男女做受视频网站seo 网站优化推广排名教程
  • 企业商务网站建设论文太原网站快速排名提升
  • 天津网站制作机玩法部国外免费源码共享网站
  • 长沙企业建站系统北京网络seo经理
  • 做婚纱网站的目的灰色项目推广渠道
  • 包头网站建设优化关键词的作用
  • 做实验教学视频的网站营销页面设计
  • 用手机搭建自己的网站公司推广方法有哪些
  • 做网站 需求怎么写做一个网站需要多少钱
  • 公司销售网站怎么做湖南好搜公司seo
  • 做MAD生肉网站福州seo
  • 做图表的网站google商店
  • 做贸易的网站杭州seo教程
  • 用记事本做电影介绍的网站广州aso优化
  • 个人域名可以做公司网站么网站排名优化软件有哪些
  • 企业档案网站建设搜索引擎营销的原理是什么
  • 网站开发应聘信息seo优化自学
  • wordpress申请子站邢台市seo服务
  • wordpress如何解压seo外链工具源码
  • 网站的公关和广告活动怎么做seo建站平台哪家好
  • 做网站完整视频网站域名综合查询
  • phpmyadmin 备份 wordpressseo推广百度百科
  • 网站建设公司发展规划网络营销案例ppt
  • wordpress如何自动采集网站图片深圳网站制作哪家好
  • 网络推广怎么能做好seoyoon
  • 网站建设的规划创建网站需要多少资金
  • 深圳网站建站建设seo实战培训学校
  • 浙江平台网站建设找哪家站长之家查询网站
  • 网站建设流程时间表2021最近最火的关键词
  • web网站开发的特点广州网络推广选择