MQ消息中间件:

    1、入门概述:

    2、ActiveMq的安装和控制台

    3、java编码实现ActiveMQ   

Elasticsearch:

    kafka produce --- zk --- client 

  mq的种类:

    kafka

    rabittmq 

    rocketmq 


    activemq的技术维度 

       :落地的细节有不一样。

       API发送和接收 

       mq的高可用性

       mq的集群和容错配置

       mq的持久化 

       延时发送/定时投递 

       签收机制

       spring整合 


     activeMQ的作用:

        削峰

        解耦

        异步 



    kafka 

        编程语言:java/scala 

    rabbitmq:

        erlang 

    rocketmq:

        java 


    notify 

    broker :activemq的实例 

    功能:实现高可用、可性能、可伸缩、易用和安全的企业

    异步消息的消费和处理。

    控制消息的顺序

    可以和spring和springboot整合简化编码

    配置集群容错的mq集群


    3、安装步骤

        官网下载

        /opt目录下面

        解压缩 activeMQ tar.gz 


    4、主题    


消息对列的模式特性:

    1、点对点

    2、消息发布订阅模式

在点对点的消息传递域中,目的地称为队列(queue)

在发布订阅消息传递域中,目的地称为主题(topic)

<?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>

<groupId>org.example</groupId>
<artifactId>mavenproject</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.15.15</version>
</dependency>

<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.16</version>
</dependency>

<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

生产者代码

package com.text.jms;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

public class JmsProduce {
public static final String hostname="localhost";
public static final String port="61616";
public static final String QUEUE_NAME="queue01";

public static final String DEFAULT_BROKER_BIND_URL="tcp://"+hostname+":61616";
public static void main(String[] args) throws JMSException {
//1 创建连接工场
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("admin","admin",DEFAULT_BROKER_BIND_URL);
//通过联接工厂,获得连接
Connection connection = activeMQConnectionFactory.createConnection();
//创建连接
connection.start();

//3创建会话session
//两个参数,第一个叫事务,第二个叫签收
final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//创建目的地(队列还是主题)
Queue queue = session.createQueue(QUEUE_NAME);
//5 创建消息的生产者
MessageProducer messageProducer = session.createProducer(queue);
for (int i = 0; i < 3; i++) {
//7 创建消息,好比学生按照要求写好面试消息
TextMessage textMessage = session.createTextMessage("msg--" + i);
//8 通过messagePorudecder 发给msg
messageProducer.send(textMessage);
}
messageProducer.close();
session.close();
connection.close();
System.out.println("消息发布完成+++");


}
}