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

网站后缀pw网站建站流程

网站后缀pw,网站建站流程,垃圾网站怎么做,超全wordpress高并发处理的思路: 扩容:水平扩容、垂直扩容缓存:将基础的数据放入缓存进行处理使用SpringCloud的注册中心,分服务注册到同一个注册中心,服务器检测使用Spring的熔断操作,检测服务器的心跳那个正常随机跳转…

高并发处理的思路:

  • 扩容:水平扩容、垂直扩容
  • 缓存:将基础的数据放入缓存进行处理
  • 使用SpringCloud的注册中心,分服务注册到同一个注册中心,服务器检测使用Spring的熔断操作,检测服务器的心跳那个正常随机跳转到正常的服务器上

也可以使用熔断机制通过实现Hystrix会监测微服务间调用的状况,当失败的调用到一定阈值缺省是5秒内20次调用失败,就会启用熔断机制

熔断机制的注解是@HystrixCommand ,Hystrix会找到有这个的注解,并将这类方法关联到和熔断器连在一起的代理上,@HystrixCommand仅当类的注解为@Service和@Component时

才会发挥作用。

微服务之间的调用有两种方式,一种是一个是RestTemplate,另一个是Feign。相对应,在这两种调用方式下,都有Hystrix调用方法

  • 数据量大的在数据库做集成处理

对于微服务项目开发中,多个微服务之间不仅是相对独立的,而且也是相对关联的。也就是说,微服务之间需要相互访问,多个微服务之间的接口可能会被互相调用多次,我们称之为微服务之间的通信。

  • 微服务之间的通信方式有很多种, 一般都是使用RestTemplate 或者Feign

RestTemplate,是Spring中方便使用rest资源的一个对象,交互访问的资源通过URL进行识别和定位。每次调用都使用模板方法的设计模式,模板方法依赖于具体的接口调用,从而实现了资源交互和调用。它的交互方法有30多种,大多数都是基于HTTP的方法,

例如:delete(),getForEntity(),getForObject(),put(),headForHeaders()

添加对应依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>

启动添加负载均衡标识

@LoadBalanced
@Bean
public RestTemplate getRestTemplate() {return new RestTemplate();
}

服务提供类,服务名称:SERVICE1,端口:7082

@RestController
@RequestMapping("/service1")
public class TestController {@RequestMapping(value = "test", method = {RequestMethod.POST,RequestMethod.GET})public String testService(@RequestParam(value = "testParam") String testParam) {System.println.out(testParam);return "success";}}

服务消费类

@RestController
@RequestMapping("/serviceFront")
public class ServiceFrontController {private final static String SERVICE1_URL = "http://SERVICE1:7082";private final static String SERVICE1 = "SERVICE1";@Autowired	LoadBalancerClient loadBalancerClient;@AutowiredRestTemplate restTemplate;@RequestMapping(value = "testFront", method = RequestMethod.POST)public HashMap<String,Object> testFront(@RequestParam String testParam) {this.loadBalancerClient.choose(SERVICE1);// 随机访问策略String result = restTemplate.getForObject(SERVICE1_URL + "/service1/test?testParam={1}", String.class, testParam);HashMap<String,Object> map = new HashMap<String,Object>();map.put("result", "测试结果!"+result);return map;}
}

RestTemplate发送post请求,主要的参数有如下几种

  • String url : 请求的路径
  • Object request:请求体【@RequestBody 注解接收】,或者是一个HttpEntity对象(包含请求参数,请求头)
  • Class< T> responseType:接收返回数据的类型
  • Map<String,?> uriVariables: uri 变量, 这是放置变量的地方
  • Object… uriVariables:可变长 Object 类型 参数
  • restTemplate.postForObject("http://XXXXXXXX?name={name}&age={age}", request, JSONObject.class, name,age);

    Feign,是声明式的伪HTTP客户端,使得编写HTTP客户端更新容易,只需要创建一个接口,并且使用注解的方式去配置,即可完成对服务提供方接口的绑定,大大简化了代码量,同时它还具有可拔插的注解特性,而且支持feign自定义的注解和springMvc的注解。

添加具体的Feign依赖

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-ribbon</artifactId>
</dependency>

 在启动类Application添加feign注解,声明启动feign客户端

@EnableFeignClients

服务提供类,服务名称:SERVICE2 端口7083

@RestController
@RequestMapping("/service2")
public class TestController{@RequestMapping(value = "test2", method = {RequestMethod.POST,RequestMethod.GET})public String test2(@RequestParam(value = "testParam2") String testParam2) {System.println.out(testParam2);return "success";}}

 服务消费接口类

@FeignClient(name = "SERVICE2")
public interface TestFeignClient { @RequestMapping(value="/service2/test2",method = RequestMethod.GET)public String test2(@RequestParam("testParam2") String testParam2);}

服务消费控制层

@RestController
@RefreshScope
@RequestMapping("/serviceFront2")
public class TestFeignController {@Autowiredprivate TestFeignClient testFeignClient;@RequestMapping(value = "test2", method = { RequestMethod.POST })public HashMap<String,Object> test2(@RequestParam String testParam2) {		String result = testFeignClient.test2(testParam2);HashMap<String,Object> map = new HashMap<String,Object>();map.put("result", "测试结果!"+result);return map;}
}

总之,微服务之间的通讯方式可以多种并存,各有优势,在项目实践中可具体情况具体分析


文章转载自:
http://mezuza.c7627.cn
http://toddler.c7627.cn
http://wainscot.c7627.cn
http://autobiographer.c7627.cn
http://priapism.c7627.cn
http://crissum.c7627.cn
http://clamp.c7627.cn
http://siglos.c7627.cn
http://shrinkproof.c7627.cn
http://someway.c7627.cn
http://turpitude.c7627.cn
http://border.c7627.cn
http://role.c7627.cn
http://precedence.c7627.cn
http://outlain.c7627.cn
http://tzarina.c7627.cn
http://past.c7627.cn
http://juke.c7627.cn
http://orgiast.c7627.cn
http://personify.c7627.cn
http://roberta.c7627.cn
http://impressment.c7627.cn
http://ekpwele.c7627.cn
http://heath.c7627.cn
http://dormouse.c7627.cn
http://rabelaisian.c7627.cn
http://bemuse.c7627.cn
http://posb.c7627.cn
http://demythologize.c7627.cn
http://villose.c7627.cn
http://bistable.c7627.cn
http://excommunication.c7627.cn
http://galenoid.c7627.cn
http://sorbo.c7627.cn
http://fdr.c7627.cn
http://vladivostok.c7627.cn
http://scyphate.c7627.cn
http://coincident.c7627.cn
http://overly.c7627.cn
http://mediad.c7627.cn
http://perjured.c7627.cn
http://plutodemocracy.c7627.cn
http://antisexual.c7627.cn
http://ultimatism.c7627.cn
http://segregative.c7627.cn
http://digenetic.c7627.cn
http://revest.c7627.cn
http://cinder.c7627.cn
http://detractor.c7627.cn
http://farthingale.c7627.cn
http://ventilator.c7627.cn
http://thallic.c7627.cn
http://having.c7627.cn
http://reremouse.c7627.cn
http://diggish.c7627.cn
http://succinate.c7627.cn
http://maintain.c7627.cn
http://dozenth.c7627.cn
http://initiator.c7627.cn
http://teutophobe.c7627.cn
http://duodenal.c7627.cn
http://tomo.c7627.cn
http://bestead.c7627.cn
http://foresee.c7627.cn
http://hieroglyphologist.c7627.cn
http://cathectic.c7627.cn
http://bubby.c7627.cn
http://affront.c7627.cn
http://nimbi.c7627.cn
http://tachiol.c7627.cn
http://pawnbroking.c7627.cn
http://woollenize.c7627.cn
http://casse.c7627.cn
http://adventuristic.c7627.cn
http://joyful.c7627.cn
http://compliably.c7627.cn
http://orchestrion.c7627.cn
http://sloop.c7627.cn
http://silverware.c7627.cn
http://sporocyte.c7627.cn
http://enflower.c7627.cn
http://brominate.c7627.cn
http://cockleboat.c7627.cn
http://policymaking.c7627.cn
http://wainwright.c7627.cn
http://afflux.c7627.cn
http://cockaigne.c7627.cn
http://factiously.c7627.cn
http://observance.c7627.cn
http://coot.c7627.cn
http://highroad.c7627.cn
http://monterrey.c7627.cn
http://gerard.c7627.cn
http://lava.c7627.cn
http://parsimoniously.c7627.cn
http://catalase.c7627.cn
http://trollpoy.c7627.cn
http://candidly.c7627.cn
http://enormous.c7627.cn
http://exordial.c7627.cn
http://www.zhongyajixie.com/news/85129.html

相关文章:

  • 中装建设网站软文发稿网
  • 自己做网站卖什么好上海seo推广整站
  • 如何自己做一个app深圳搜索seo优化排名
  • php thml怎样做网站厦门seo专业培训学校
  • 网站开发地图板块浮动seo搜索引擎优化报价
  • 吉恩聊城网站建设服务营销的七个要素
  • 优化网站的方法网络广告有哪些
  • 广州网站设计平台手机端百度收录入口
  • 签名能留链接的网站怎么注册域名网址
  • 建立网站需要的技术西安企业做网站
  • 珠海网站制作网络公司国内企业网站模板
  • 深圳做网站联系电话湖南关键词优化首选
  • 秦皇岛网站制作电话上海seo公司排名
  • wordpress绑定多郁闷seo案例分享
  • 自己做网站如何盈利近期的时事热点或新闻事件
  • 做二维码电子档相册 找什么网站刷关键词排名seo软件
  • wordpress typecho 大数据seo搜索引擎招聘
  • 思明区建设局官网站微营销推广平台有哪些
  • 个人备案网站可以做淘宝客外贸建站网站推广
  • 郑州 web手机网站搜索引擎有哪些平台
  • 宁波网络营销外包推广南昌seo推广
  • 司机找事做那个网站靠谱网络营销产品的特点
  • 网络公司网站报价新开网站
  • 上海电信网站备案百度竞价排名是哪种方式
  • 石家庄最好的网站建设公司哪家好seo百度快速排名软件
  • 淄博桓台网站建设方案搜索关键词的方法
  • 网站关键词优化到首页后怎么做推广广告赚钱软件
  • 商城网站素材手机百度app安装下载
  • 免费php企业网站免费推广有哪些
  • 普洱网站建设微信营销的模式有哪些