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

企业网站的建设要注意什么狼雨seo网站

企业网站的建设要注意什么,狼雨seo网站,镇江久一信息技术有限公司,番禺人才网体能测试通告前言:只有消费者部分,没有记录生产者部分 结构图 配置类 可以xml配置,也可以配置类,二者可以相互转化。两种bean注入的方式。 import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; import org.spring…

前言:只有消费者部分,没有记录生产者部分

结构图

在这里插入图片描述

配置类

可以xml配置,也可以配置类,二者可以相互转化。两种bean注入的方式。


import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.MessageListenerContainer;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class DbDataQueueConsumeConfig {@Value("${rabbitmq.host}")private String host;@Value("${rabbitmq.port:5672}")
//    @Value("#{new Integer('${rabbitmq.port}')}")private Integer port;@Value("${rabbitmq.username}")private String username;@Value("${rabbitmq.password}")private String password;@Value("${rabbitmq.virtual-host}")private String virtualHost;@Value("${rabbitmq.queue}")private String queueName;/*** 配置连接工厂*/@Bean(name = "rabbitConnectionFactory")public ConnectionFactory connectionFactory() {CachingConnectionFactory connectionFactory = new CachingConnectionFactory();connectionFactory.setHost(host);connectionFactory.setPort(port);connectionFactory.setUsername(username);connectionFactory.setPassword(password);connectionFactory.setVirtualHost(virtualHost);return connectionFactory;}/*** 配置 RabbitTemplate,用于发送消息*/@Beanpublic RabbitTemplate rabbitTemplate(@Qualifier("rabbitConnectionFactory") ConnectionFactory connectionFactory) {RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);rabbitTemplate.setMessageConverter(jsonMessageConverter());return rabbitTemplate;}@Beanpublic Jackson2JsonMessageConverter jsonMessageConverter() {return new Jackson2JsonMessageConverter();}/*** 配置消息监听容器*/@Beanpublic MessageListenerContainer messageListenerContainer(ConnectionFactory connectionFactory, BdDataQueueListener bdDataQueueListener) {SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();container.setConnectionFactory(connectionFactory);container.setQueueNames(queueName);container.setMessageListener(new MessageListenerAdapter(bdDataQueueListener));return container;}}

配置文件中配置好rabbitmq服务的地址

rabbitmq.host=xxx.xxx.xxx.xxx
rabbitmq.port=3011
rabbitmq.username=username
rabbitmq.password=password
rabbitmq.virtual-host=/xxx
rabbitmq.queue=queuename

消费者

@Component
public class BdDataQueueListener implements MessageListener {@Overridepublic void onMessage(Message message) {try {// 这里写业务逻辑} catch (Exception e) {}}}

重要部分都在上面。其余的不在放出来。

参考文章

文章1

文章2

http://www.15wanjia.com/news/48240.html

相关文章:

  • 网站建设属于哪种职位seo研究中心道一老师
  • 网站建设账务处理属于什么费用山东百度推广
  • 动态网站开发多少钱seo目标关键词优化
  • 外贸 网站推广计划企业文化的重要性
  • 在线教育类网站模板品牌营销策略
  • 权威的锦州网站建设品牌推广与传播方案
  • 上海疫情发布会seo查询软件
  • 装修房子的效果图 三室二厅二卫沈阳网站关键字优化
  • 网络培训的网站建设实时军事热点
  • 威县建设局网站市场调研报告ppt
  • 中国网站建设排名百度seo排名优化如何
  • 黔东南手机网站建设做百度推广需要什么条件
  • 国务院办公厅关于网站建设要求手机优化助手下载
  • html企业网站源码下载黑帽seo是什么
  • wordpress导航条seo全称英文怎么说
  • 网站跳出率因素怎么设置自己的网站
  • 一对一直播网站开发线下推广方式都有哪些
  • 推荐做问卷的网站百度账号官网
  • 网站建设 生产如何创建网站教程
  • 我有网站 怎么做淘宝推广西安分类信息seo公司
  • 邯郸网站建设新媒体营销案例
  • 做的好的新闻网站百度竞价推广开户价格
  • 养殖场网站源码免费宣传平台
  • 北京著名网站建设公司合肥seo优化排名公司
  • 如何在社交网站上做视频推广方案百度竞价和优化的区别
  • 网站建设制作包括哪些自己动手建立个人网站
  • 毕业论文代做网站可信吗搜索引擎优化通常要注意的问题有
  • 济南哪有做网站的自媒体培训
  • 广州网站seo招聘网站推广优化招聘
  • 做风水网站赚钱吗关键词优化 搜索引擎