首页天道酬勤rabbitmq集群原理,java spring框架

rabbitmq集群原理,java spring框架

张世龙 05-05 13:34 108次浏览

流概述了使用中间件的组件,以及可选组件Kafka和RabbitMQ。

基本的Spring云

3359 blog.csdn.net/QQ _ 41520636/article/details/115848795

rabbitmq

3359 blog.csdn.net/QQ _ 41520636/article/details/115473826

hystrix-consumer子工程pom

! --- stream---- dependencygroupidorg.spring framework.cloud/groupidartifactidspring-cloud-starter-stream-rabrabed rabbit ependencydependencygroupidorg.spring framework.cloud/groupidartifactidspring-cloud-stream-binder-rabit/aaad

spring : application : name : hy strix-consumer #设置当前APP应用程序的名称。 将来会在eureka上看到APP。 将来,必须使用此名称获取路径cloud: stream: #定义绑定。 绑定到哪个消息中间件binders: test_binder: #自定义绑定名称type: rabbit #绑定类型environment: # mq的环境spring : rabbit MQ : host :192.168.135.143 port :5672用户名称: guest password 3360 guest virtual-host 33366660 channel名称content-type : application/JSON #传输内容的格式binder: test_binder #指定使用哪个binderdestination

package com.hikktn.listener; importorg.spring帧. integration.annotation.service activator; importorg.spring帧. messaging.message; importorg.spring framework.cloud.stream.annotation.enable绑定; importorg.spring framework.cloud.stream.annotation.stream listener; importorg.spring帧. cloud.stream.messaging.sink; importorg.spring framework.stereotype.com ponent;/* * @ classnamemessagelistener * @描述工具* @ authorlisonglin * @ date 2021/4/192:17 * @版本1.0 */@ @ componentpublicclassmessagelistener { @ stream listener (sink.input ) public void receive (message ) message ) stem.out sssage }/** *消息消耗失败时的降级处理逻辑(* @ param message (//@ service activator (input channel=' test-topic.stream-exxator ) //}} hystrix-provider子项目pom

! --- stream---- dependencygroupidorg.spring framework.cloud/groupidartifactidspring-cloud-starter-stream-rabrabed rabbit ependencydependencygroupidorg.spring framework.cloud/groupidartifactidspring-cloud-stream-binder-rabit/aaad

spring : application : name : hy strix-provider #设置当前APP应用程序的名称。 将来会在eureka上看到APP。 将来,必须使用此名称获取路径cloud: stream: #定义绑定。 绑定到哪个消息中间件binders: test_binder: #自定义绑定名称type: rabbit #绑定类型environment: # mq的环境spring : rabbit MQ : host :192.168.135.143 port :5672用户名称: guest password 3360 guest virtual-host 33366660 channel名称content-type : application/JSON #传输内容的格式binder: test_binder #指定使用哪个binderdestination

package com.hikktn.dao; import com.hikktn.channel.message event; importorg.spring framework.beans.factory.annotation.auto wired; importorg.spring framework.cloud.stream.annotation.enable绑定; importorg.spring framework.cloud.stream.messaging.source; importorg.spring framework.messaging.message channel; importorg.spring帧. messaging.support.message builder; importorg.spring framework.stereotype.com ponent; import java.util.HashMap; import java.util.Map;/* * @ classnamemessageproducer * @描述工具* @ authorlisonglin * @ date 2021/4/192:32 * @版本1.0 */@ component @ enable binding (source.class ) publicclassmessageproducer (@ autowiredprivatemessagechanneloutput; //@自动无线//私有消息事件消息事件; 公共语音发送(字符串消息) {//MapString,Object map=new HashMap; //map.put (路由密钥)、) add ); //routing key//stringmsessage=' hellostream~~ '; //消息output.send (消息构建器. with payload (消息).build ); //message event.user producer (.send ) messagebuilder.withpayload ).copyheaders ) (.map ).build ); System.out.println; }控制器

@ rest controller @requestmapping (/goods ) ) @RefreshScope //刷新功能publicclassgoodscontroller ) @ request mapping )/seser }测试eureka-serverhystrix-consumerhystrix-provider

activemq入门,rabbitmq官方教程中文