springboot 集成 activemq

说明

1-在两个不同的应用发送和接收消息
2-消息发送应用是 e-car 项目,接收端是 tcm-chatgpt项目,当然,同一个项目也是可以发送和接收的

e-car项目配置

引入activemq依赖

<!-- 集成 ActiveMQ -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-activemq</artifactId>
</dependency>

application.yml配置

spring:
  # activemq相关配置
  activemq:
    broker-url: tcp://localhost:61616
    user: liping
    password: liping
    packages:
      # 配置信任所有的包,这个配置为了支持发送对象消息(如果传递的是对象则需要设置为true,默认是传字符串)
      trust-all: true
  # 开启主题策略,默认是关闭 开启主题模式
  jms:
    pub-sub-domain: true

# 配置activemq队列的名称和主题名称
amq:
  qname:
    queueName-1:
      queueName-1
  topicName:
    name-1:
      topic-prot-1
    name-2:
      topic-prot-2

MQConfig.java 配置类

/**
 * 专门配置mq通道的配置类
 */
@Slf4j
@Configuration
public class MQConfig {

    @Value("${amq.topicName.name-1}")
    private String tpName;

    @Bean(name = "queueName")
    Queue queueName() {
        return new ActiveMQQueue("test_queue");
    }

    /**
     * 主题(发布\订阅模式)通道
     * @author kazaf
     * @date 2024/4/24 16:43
     */
    @Bean(name = "topic1")
    Topic queueFind() {
        log.info("${amq.topicName.name-1}=" + tpName);
        return new ActiveMQTopic("topic-model");
    }

    @Bean(name = "topic2")
    Topic topic2() {
        return new ActiveMQTopic("topic-model2");
    }

    @Bean(name = "topic3")
    Topic topic3() {
        return new ActiveMQTopic(tpName);
    }

}

相关推荐

  1. springboot 集成 activemq

    2024-04-25 07:28:03       43 阅读
  2. SpringBoot整合ActiveMQ步骤

    2024-04-25 07:28:03       34 阅读
  3. ActiveMQ 03 整合SpringBoot

    2024-04-25 07:28:03       38 阅读
  4. <span style='color:red;'>activeMq</span>

    activeMq

    2024-04-25 07:28:03      58 阅读
  5. <span style='color:red;'>ActiveMQ</span>

    ActiveMQ

    2024-04-25 07:28:03      43 阅读
  6. <span style='color:red;'>ActiveMQ</span>

    ActiveMQ

    2024-04-25 07:28:03      33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-25 07:28:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-25 07:28:03       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-25 07:28:03       82 阅读
  4. Python语言-面向对象

    2024-04-25 07:28:03       91 阅读

热门阅读

  1. Centos 7.9 一键安装 Oracle 12CR2(240116)单机 PDB

    2024-04-25 07:28:03       38 阅读
  2. 415. 字符串相加

    2024-04-25 07:28:03       34 阅读
  3. [C++]多态是如何调用不同的函数对象的?

    2024-04-25 07:28:03       33 阅读
  4. docker安装efk

    2024-04-25 07:28:03       39 阅读
  5. 【Jenkins】Jenkins nohup执行失败

    2024-04-25 07:28:03       47 阅读
  6. Mac 上可以使用 ping 端口

    2024-04-25 07:28:03       42 阅读
  7. pnpm的安装与配置(Windows/macOS)

    2024-04-25 07:28:03       33 阅读
  8. Swift加载Lottie

    2024-04-25 07:28:03       37 阅读
  9. 基于Promise + XHR 封装myAxios函数

    2024-04-25 07:28:03       38 阅读
  10. Flutter 项目添加 IOS 小组件开发记录

    2024-04-25 07:28:03       36 阅读