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

美国做义工的网站网络营销师证

美国做义工的网站,网络营销师证,网站通cms,flash 网站欣赏说明&#xff1a;本文章只是springboot和rabbitmq的直连整合&#xff0c;只使用队列生产和消费消息&#xff0c;最简单整合&#xff01; 工程图&#xff1a; A.总体pom.xml <?xml version"1.0" encoding"UTF-8"?><project xmlns"http://…

说明:本文章只是springboot和rabbitmq的直连整合,只使用队列生产和消费消息,最简单整合!

工程图:

A.总体pom.xml

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><artifactId>spring-boot-starter-parent</artifactId>  <!-- 被继承的父项目的构件标识符 --><groupId>org.springframework.boot</groupId>  <!-- 被继承的父项目的全球唯一标识符 --><version>2.2.2.RELEASE</version>  <!-- 被继承的父项目的版本 --><relativePath/> <!-- lookup parent from repository --></parent><groupId>RabbitMqSpringbootDemo</groupId><artifactId>RabbitMqSpringbootDemo</artifactId><version>1.0-SNAPSHOT</version><packaging>pom</packaging><modules><module>MqCustomer</module><module>MqProducer</module></modules><name>RabbitMqSpringbootDemo Maven Webapp</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies></dependencies><build><finalName>RabbitMqSpringbootDemo</finalName><pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --><plugins><plugin><artifactId>maven-clean-plugin</artifactId><version>3.1.0</version></plugin><!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --><plugin><artifactId>maven-resources-plugin</artifactId><version>3.0.2</version></plugin><plugin><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version></plugin><plugin><artifactId>maven-surefire-plugin</artifactId><version>2.22.1</version></plugin><plugin><artifactId>maven-war-plugin</artifactId><version>3.2.2</version></plugin><plugin><artifactId>maven-install-plugin</artifactId><version>2.5.2</version></plugin><plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.2</version></plugin></plugins></pluginManagement></build>
</project>

B.生产者:MyProducer

1.pom.xml

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>RabbitMqSpringbootDemo</artifactId><groupId>RabbitMqSpringbootDemo</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>MqProducer</artifactId><packaging>jar</packaging><name>MqProducer Maven Webapp</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies><!--spring boot核心--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><!--spring boot 测试--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!--springmvc web--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--开发环境调试--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional></dependency><!--amqp 支持--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.78</version></dependency><!-- commons-lang3 --><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.4</version></dependency><!--lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.16.10</version></dependency></dependencies><build><finalName>MqProducer</finalName><pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --><plugins><plugin><artifactId>maven-clean-plugin</artifactId><version>3.1.0</version></plugin><!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --><plugin><artifactId>maven-resources-plugin</artifactId><version>3.0.2</version></plugin><plugin><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version></plugin><plugin><artifactId>maven-surefire-plugin</artifactId><version>2.22.1</version></plugin><plugin><artifactId>maven-war-plugin</artifactId><version>3.2.2</version></plugin><plugin><artifactId>maven-install-plugin</artifactId><version>2.5.2</version></plugin><plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.2</version></plugin></plugins></pluginManagement></build>
</project>

2.application.yml

server:port: 8080
spring:rabbitmq:port: 5672host: 192.168.18.145username: adminpassword: adminvirtual-host: /

3.AppP

package com.dev;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;/*** 类名称:** @author lqw* @date 2024年02月27日 14:20*/
@SpringBootApplication
public class AppP {public static void main(String[] args) {SpringApplication.run(AppP.class);}
}

4.OnlyQueueRabbitConfig

package com.dev.config;import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/*** 类名称:** @author lqw* @date 2024年02月28日 10:40*/
@Configuration
public class OnlyQueueRabbitConfig {/*** 队列* @return onlyQueue队列名称 true 持久化*/@Beanpublic Queue directOnlyQueue(){return new Queue("onlyQueue",true);}}

5.OnlyQueueController

package com.dev.controller;import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** 类名称:直接交换机 消息生产者** @author lqw* @date 2024年02月27日 14:47*/
@Slf4j
@RestController
@RequestMapping("onlyQueue")
public class OnlyQueueController {@AutowiredRabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法/*** Direct测试* @return*/@GetMapping("/sendMessageByOnlyQueue")public String sendMessageByOnlyQueue() {rabbitTemplate.convertAndSend("", "onlyQueue", "你好,Queue!我是直连队列发送的消息!");return "ok";}}

C.消费者:MqCustomer

1.pom.xml

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>RabbitMqSpringbootDemo</artifactId><groupId>RabbitMqSpringbootDemo</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>MqCustomer</artifactId><packaging>jar</packaging><name>MqCustomer Maven Webapp</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies><!--spring boot核心--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><!--spring boot 测试--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!--springmvc web--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--开发环境调试--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional></dependency><!--amqp 支持--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency><!-- commons-lang3 --><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.4</version></dependency><!--lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.16.10</version></dependency></dependencies><build><finalName>MqCustomer</finalName><pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --><plugins><plugin><artifactId>maven-clean-plugin</artifactId><version>3.1.0</version></plugin><!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --><plugin><artifactId>maven-resources-plugin</artifactId><version>3.0.2</version></plugin><plugin><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version></plugin><plugin><artifactId>maven-surefire-plugin</artifactId><version>2.22.1</version></plugin><plugin><artifactId>maven-war-plugin</artifactId><version>3.2.2</version></plugin><plugin><artifactId>maven-install-plugin</artifactId><version>2.5.2</version></plugin><plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.2</version></plugin></plugins></pluginManagement></build>
</project>

2.application.yml

server:port: 8081spring:rabbitmq:port: 5672host: 192.168.18.145username: adminpassword: admin

3.AppC

package cn.ct;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;/*** 类名称:** @author lqw* @date 2024年02月27日 14:20*/
@SpringBootApplication
public class AppC {public static void main(String[] args) {SpringApplication.run(AppC.class);}
}

4.OnlyQueueRabbitListener

package cn.ct.listeners;import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;/*** 类名称:消息消费者* 直连* @author lqw* @date 2024年02月27日 14:58*/
@Component
public class OnlyQueueRabbitListener {@RabbitListener(queues = "onlyQueue")@RabbitHandlerpublic void process(String hello) {System.out.println("Rabbitmq  : " + hello);}}

总结:这个是mq消息的最简单的使用,只使用队列!

http://www.dinnco.com/news/37120.html

相关文章:

  • 自己主机做网站服务器吗一个完整的产品运营方案
  • 大连网站建设顾问百度官方网址
  • 杭州住房建设部官方网站自媒体营销的策略和方法
  • 国外html5网站源码有哪些平台可以免费发广告
  • 北京网站建设需要多少钱电子商务主要干什么
  • 做百度推广需要有自己的网站吗网站是怎么优化推广的
  • 对网站建设需求河北网络推广技术
  • 专做批发的网站百度推广工具
  • 购买域名后怎么建网站金融网站推广圳seo公司
  • 网站建设公司信科网络甘肃seo网站
  • 网站建设预付款比例排名优化服务
  • 建设网站托管费用万网域名管理入口
  • 珠海培训网站建设最新中高风险地区名单
  • 网站排名突然下降抚顺网站seo
  • 合肥在线网站班级优化大师的优点
  • 网站建设 云计算网络推广用什么软件好
  • 做按摩网站违法吗网络营销的策略包括
  • 做爰免费视频网站优化关键词的步骤
  • 桂林北站附近有什么好玩的如何推广一个新的app
  • wordpress响应式博客海南seo
  • 自己可以做拼单网站吗旺道优化软件
  • 如何开始做b2b网站高端网站建设公司哪家好
  • 为什么要建设营销型网站win10系统优化软件
  • 如何做网站的线下推广竞价 推广
  • 直接ip访问网站南京seo优化公司
  • 有没有做网站的多少钱google海外版
  • 有没有做的很炫的科技型网站百度百科优化排名
  • 济南网站建设公司晟创未来内容营销是什么意思
  • 医院 网站建设爱站网ip反域名查询
  • 网站开发就业薪酬seo需要会什么