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

大连做网站哪里好7个经典软文营销案例

大连做网站哪里好,7个经典软文营销案例,wordpress主页显示,昆明网站建设时间文章目录一、简单对象1. 依赖2. 生产者3. 消费者4. 配置文件5. spring版本二、复杂对象2.1. 生产者2.2. 消费者一、简单对象 1. 依赖 !--spring整合rabbitmq--dependencygroupIdorg.springframework.amqp/groupIdartifactIdspring-ra… 文章目录一、简单对象1. 依赖2. 生产者3. 消费者4. 配置文件5. spring版本二、复杂对象2.1. 生产者2.2. 消费者一、简单对象 1. 依赖 !--spring整合rabbitmq--dependencygroupIdorg.springframework.amqp/groupIdartifactIdspring-rabbit/artifactIdversion2.0.1.RELEASE/version/dependency注maven方式这一个依赖即可如果是非maven项目需要引入5个jar如下 推荐使用mavne方式简单非Maven项目先用maven把以来下载本地仓库复制到非maven的项目中即可。 2. 生产者 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:rabbithttp://www.springframework.org/schema/rabbitxsi:schemaLocationhttp://www.springframework.org/schema/rabbithttp://www.springframework.org/schema/rabbit/spring-rabbit-2.0.xsdhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.1.xsd!--生产者者配置如下--!-- 定义RabbitMQ的连接工厂 --rabbit:connection-factory idconnectionFactoryhost${rabbitmq.host}port${rabbitmq.port}username${rabbitmq.username}password${rabbitmq.password}virtual-host${rabbitmq.vhost}connection-timeout${rabbitmq.conTimeout}publisher-confirms${rabbitmq.publisher-confirms}publisher-returns${rabbitmq.publisher-returns}/!-- 管理消息队列 --rabbit:admin connection-factoryconnectionFactory/!--此处为配置文件方式 管控台配置模式需要注释 默认模式管控台 Start--!-- 定义一个队列或者多个队列 自动声明--rabbit:queue nameQueue-1 auto-declaretrue durabletrue/rabbit:topic-exchange nameexchange-1rabbit:bindings!-- 可绑定多个队列发送的时候指定key进行发送 --rabbit:binding queueQueue-1 patternws.tjqb//rabbit:bindings/rabbit:topic-exchange!--此处为配置文件方式 管控台配置模式需要注释 默认模式管控台 End--!-- 定义交换机 自动声明--rabbit:topic-exchange nameexchange-1auto-declaretrue durabletrue/!-- 5. 配置消息对象json转换类 --bean idjsonMessageConverter classorg.springframework.amqp.support.converter.Jackson2JsonMessageConverter /!-- 定义MQ消息模板1. id 定义消息模板ID2.connection-factory 把定义的连接工厂放到消息模板中3.confirm-callback confirm确认机制4.return-callback return确认机制5.mandatory #有2种状态设置为 true 后 消费者在消息没有被路由到合适队列情况下会被return监听而不会自动删除设置为 false 后 消费者在消息没有被路由到合适队列情况下会自动删除--rabbit:template idrabbitTemplateconnection-factoryconnectionFactoryexchangeexchange-1confirm-callbackconfirmCallBackListenerreturn-callbackreturnCallBackListenermandatorytruemessage-converterjsonMessageConverter/ /beanspackage com.gblfy.order.controller;import com.gblfy.order.pojo.FisCallingTrace; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.support.CorrelationData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.UUID;RestController public class Send {public static final String EXCHANGE exchange-1;AutowiredRabbitTemplate rabbitTemplate;RequestMapping(/test)public String test() {String uuidStr UUID.randomUUID().toString();CorrelationData correlationId new CorrelationData(uuidStr);// 发送消息MapString, String map new HashMap();map.put(email, 550731230qq.com);rabbitTemplate.convertAndSend(EXCHANGE, ws.tjqb, map, correlationId);return success;}3. 消费者 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:rabbithttp://www.springframework.org/schema/rabbitxsi:schemaLocationhttp://www.springframework.org/schema/rabbithttp://www.springframework.org/schema/rabbit/spring-rabbit-2.0.xsdhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.1.xsd!--消费者配置如下--!-- 定义RabbitMQ的连接工厂 --rabbit:connection-factory idconnectionFactoryhost${rabbitmq.host} port${rabbitmq.port} username${rabbitmq.username}password${rabbitmq.password} virtual-host${rabbitmq.vhost}connection-timeout${rabbitmq.conTimeout}publisher-confirms${rabbitmq.publisher-confirms}publisher-returns${rabbitmq.publisher-returns}/!-- 管理消息队列 --rabbit:admin connection-factoryconnectionFactory/!-- 声明多个消费者对象 --bean idemailMessageListener classcom.gblfy.order.mqhandler.EmailMessageListener/!-- 监听队列1. connectionFactory 连接工厂2. manual 手动签收3. ref 消费者监听--rabbit:listener-container connection-factoryconnectionFactoryacknowledgemanualconcurrency${rabbitmq.concurrency}max-concurrency${rabbitmq.max-concurrency}rabbit:listener refemailMessageListener methodonMessage queue-namesQueue-1//rabbit:listener-container /beans package com.gblfy.order.mqhandler;import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.amqp.core.Message; import org.springframework.amqp.core.MessageListener;import java.io.IOException; Component public class EmailMessageListener implements MessageListener {private static final ObjectMapper MAPPER new ObjectMapper();Overridepublic void onMessage(Message message) {try {JsonNode jsonNode MAPPER.readTree(message.getBody());String email jsonNode.get(email).asText();System.out.println(获取队列中消息 email);} catch (IOException e) {e.printStackTrace();}} }4. 配置文件 #RabbitMQ 连接信息 #IP地址 rabbitmq.host192.168.0.114 #端口 rabbitmq.port5672 #用户名 rabbitmq.usernamefis #密码 rabbitmq.passwordncl1234 #虚拟主机 rabbitmq.vhost/app/fisMQ #连接超时时间 rabbitmq.conTimeout15000 #发送确认 对应RabbitTemplate.ConfirmCallback接口 #消息发送成功 有2个重要参数 # ack 状态为true correlationId 全局唯一ID用于标识每一支队列 rabbitmq.publisher-confirmstrue #发送失败回退对应RabbitTemplate.ReturnCallback接口 rabbitmq.publisher-returnstrue #默认消费者数量 rabbitmq.concurrency10 #最大消费者数量 rabbitmq.max-concurrency20 5. spring版本 目前适配的spring版本4.2.3.RELEASE 二、复杂对象 声明配置文件不变 2.1. 生产者 package com.gblfy.order.controller;import com.gblfy.order.pojo.FisCallingTrace; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.support.CorrelationData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.UUID;RestController public class Send {public static final String EXCHANGE exchange-1;AutowiredRabbitTemplate rabbitTemplate;RequestMapping(/test)public String test() {FisCallingTrace f getFisCallingTrace();String uuidStr UUID.randomUUID().toString();CorrelationData correlationId new CorrelationData(uuidStr);// 发送消息MapString, Object map new HashMap();map.put(mReqXml, 请求报文);map.put(mResXml, 响应报文);map.put(mUUID, uuidStr);map.put(serviceName, NYHC);map.put(fisCallingTrace, f);rabbitTemplate.convertAndSend(EXCHANGE, ws.tjqb, map, correlationId);return success;}// RequestMapping(/test)// public String test() {// String uuidStr UUID.randomUUID().toString();// CorrelationData correlationId new CorrelationData(uuidStr);// // 发送消息// MapString, String map new HashMap();// map.put(email, 550731230qq.com);// rabbitTemplate.convertAndSend(EXCHANGE, ws.tjqb, map, correlationId);// return success;// }private FisCallingTrace getFisCallingTrace() {FisCallingTrace f new FisCallingTrace();f.setServicename(tjqb);f.setServicetype(1);f.setInterfacetype(2);f.setResstatus(1);f.setResremark(纽约数据回传接口);f.setReqdate(new Date());f.setReqtime(10:00:00);f.setResdate(new Date());f.setRestime(10:00:00);f.setReqxml(请求报文);f.setResxml(响应报文);return f;}} 2.2. 消费者 package com.gblfy.order.mqhandler;import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.gblfy.order.pojo.FisCallingTrace; import com.rabbitmq.client.Channel; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; import org.springframework.stereotype.Component;import java.io.IOException;Slf4j Component public class EmailMessageListener implements ChannelAwareMessageListener {private static final ObjectMapper MAPPER new ObjectMapper();Overridepublic void onMessage(Message message, Channel channel) throws Exception {try {JsonNode jsonNode MAPPER.readTree(message.getBody());String mReqXml jsonNode.get(mReqXml).asText();String mResXml jsonNode.get(mResXml).asText();String mUUID jsonNode.get(mUUID).asText();String serviceName jsonNode.get(serviceName).asText();System.out.println(获取队列中消息 mReqXml);System.out.println(获取队列中消息 mResXml);System.out.println(获取队列中消息 mUUID);System.out.println(获取队列中消息 serviceName);JsonNode jsonNode1 jsonNode.get(fisCallingTrace);String jsonStr MAPPER.writeValueAsString(jsonNode1);FisCallingTrace f MAPPER.readValue(jsonStr , FisCallingTrace.class);System.out.println(获取队列中消息 f.getReqxml());System.out.println(获取队列中消息 f.getResxml());// 消息的标识false只确认当前一个消息收到true确认所有consumer获得的消息channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);} catch (IOException e) {e.printStackTrace();}log.info(解析操作);log.info(落库操作);} }
http://www.pierceye.com/news/294786/

相关文章:

  • 免费行情软件app网站排行企业内部网站如何建设
  • 沧州网络运营中心在哪里新的seo网站优化排名 网站
  • 米拓建站免费模板wordpress那个主题收录好
  • 网站后台中小型网站建设的基本流程
  • 一键做网站的软件爱互融网站开发合同
  • 平顶山市哪里有做网站的高端的扬中网站建设
  • 网站定制电话如何自己开公众号
  • app开发网站建设及开发专业济南网站建设价格
  • 网站建设新闻分享免费制作网站app
  • 海口网站建设高端wordpress 论坛那
  • 谁能帮我做网站百度推广登录平台怎么收费
  • 有关于网站建设的论文如何开发一个微信公众号
  • 深圳网站建制作网上写文章用什么软件
  • 网站模版自适应网站建设全包方案
  • 广州网站建设鞍山家电网站首页制作
  • 西安注册公司网站网站建设找a金手指
  • 浙江省住房和城乡建设厅网站打不开设计书籍频道开放说明
  • 阿里巴巴 网站建设遵义网警
  • 宁夏建设厅网站官网如何做DJ网站
  • 龙岩做网站公司哪家好erp系统与网站对接长沙
  • 做二手房需要用到哪些网站搜集房源找人做设计的网站
  • 建设银行河北分行招聘网站可以下载新闻视频的网站
  • 凡客官网旗舰店襄阳seo关键词优化公司
  • 区域门户网站源码健身网站建设
  • 动漫网站建设赚钱吗三端互通传奇手游开服列表
  • 网站建设前的需求分析手机免费制作网站模板免费下载
  • 网站兼容ie7接私活做网站要不要签合同
  • 广州网站建设首选快优wordpress拖拽建站
  • 网站开发 播放音频amr个人网站设计案例
  • 建设一个网站可以采用那几方案常用的网页制作工具有什么