package com.study.mq.a1_example.helloworld.queue;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

/**



  • 简单生产者

    */

    public class Producer {

    public static void main(String[] args) {

    new ProducerThread("tcp://10.201.157.250:61616", "queue1").start();

    } static class ProducerThread extends Thread {

    String brokerUrl;

    String destinationUrl;
     public ProducerThread(String brokerUrl, String destinationUrl) {
    this.brokerUrl = brokerUrl;
    this.destinationUrl = destinationUrl;
    } @Override
    public void run() {
    ActiveMQConnectionFactory connectionFactory;
    Connection conn;
    Session session; try {
    // 1、创建连接工厂
    connectionFactory = new ActiveMQConnectionFactory(brokerUrl);
    // 2、创建连接对象md
    conn = connectionFactory.createConnection();
    conn.start();
    // 3、创建会话,表示是否支持事务
    session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    // 4、创建点对点发送的目标
    Destination destination = session.createQueue(destinationUrl);
    // 5、创建生产者消息
    MessageProducer producer = session.createProducer(destination);
    // 设置生产者的模式,有两种可选 持久化 / 不持久化
    producer.setDeliveryMode(DeliveryMode.PERSISTENT);
    // 6、创建一条文本消息
    String text = "Hello world!";
    TextMessage message = session.createTextMessage(text);
    for (int i = 0; i < 1; i++) {
    // 7、发送消息
    producer.send(message);
    }
    // 8、 关闭连接
    session.close();
    conn.close();
    } catch (JMSException e) {
    e.printStackTrace();
    }
    }

    }

    }

1、可以通过log4j.properties可以记录log信息

阅读下面的文档就可以添加修改相应的参数

http://activemq.apache.org/tcp-transport-reference

vi activemq.xml

2、传输协议改成UDP

package com.study.mq.a1_example.transport;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

// UDP示例 http://activemq.apache.org/udp-transport-reference.html

public class ConsumerAndProducerUDP {

public static void main(String[] args) {

ActiveMQConnectionFactory connectionFactory = null;

Connection conn = null;

Session session = null;

MessageConsumer consumer = null;
    try {
// 1、创建连接工厂
connectionFactory = new ActiveMQConnectionFactory("udp://activemq.tony.com:61616");
// 2、创建连接对象
conn = connectionFactory.createConnection("admin", "admin");
conn.start(); session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); // 4、创建点对点接收的目标
Destination destination = session.createQueue("queue1"); // 5、创建生产者消息
MessageProducer producer = session.createProducer(destination);
// 设置生产者的模式,有两种可选
// DeliveryMode.PERSISTENT 当activemq关闭的时候,队列数据将会被保存
// DeliveryMode.NON_PERSISTENT 当activemq关闭的时候,队列里面的数据将会被清空
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); // 6、创建一条消息
String text = "Hello world!";
TextMessage message = session.createTextMessage(text);
// 7、发送消息
producer.send(message); // 8、创建消费者消息
consumer = session.createConsumer(destination); // 9、接收消息
Message consumerMessage = consumer.receive();
if (consumerMessage instanceof TextMessage) {
System.out.println("收到文本消息:" + ((TextMessage) consumerMessage).getText());
} else {
System.out.println(consumerMessage);
}
} catch (JMSException e) {
e.printStackTrace();
} finally {
if (consumer != null) {
try {
consumer.close();
} catch (JMSException e) {
e.printStackTrace();
}
} if (session != null) {
try {
session.close();
} catch (JMSException e1) {
e1.printStackTrace();
}
} if (conn != null) {
try {
conn.close();
} catch (JMSException e1) {
e1.printStackTrace();
}
}
}
}

}

3、SSL修改

 ssl客户端: http://activemq.apache.org/ssl-transport-reference.html
http://activemq.apache.org/how-do-i-use-ssl.html
package com.study.mq.a1_example.transport;

import org.apache.activemq.ActiveMQConnectionFactory;

import org.apache.activemq.ActiveMQSslConnectionFactory; import javax.jms.*; // ssl客户端: http://activemq.apache.org/ssl-transport-reference.html

// http://activemq.apache.org/how-do-i-use-ssl.html

public class ConsumerAndProducerSSL {

public static void main(String[] args) {

// ssl

ActiveMQSslConnectionFactory connectionFactory = null;

Connection conn = null;

Session session = null;

MessageConsumer consumer = null;
    try {
// 1、创建连接工厂
connectionFactory = new ActiveMQSslConnectionFactory("ssl://activemq.tony.com:61617?socket.verifyHostName=false");
connectionFactory.setTrustStore("activemq-client.ts");
connectionFactory.setTrustStorePassword("netease");
// 2、创建连接对象
conn = connectionFactory.createConnection();
conn.start();
// 3、 创建session
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
// 4、创建点对点接收的目标
Destination destination = session.createQueue("queue1");
// 5、创建生产者消息
MessageProducer producer = session.createProducer(destination);
// 设置生产者的模式,有两种可选
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// 6、创建一条消息
String text = "Hello world!";
TextMessage message = session.createTextMessage(text);
// 7、发送消息
producer.send(message);
// 8、创建消费者消息
consumer = session.createConsumer(destination);
// 9、接收消息
Message consumerMessage = consumer.receive();
if (consumerMessage instanceof TextMessage) {
System.out.println("收到文本消息:" + ((TextMessage) consumerMessage).getText());
} else {
System.out.println(consumerMessage);
} consumer.close();
session.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}

}

4、NIO

 http://activemq.apache.org/configuring-transports.html
http://activemq.apache.org/tcp-transport-reference.html
package com.study.mq.a1_example.transport;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

// http://activemq.apache.org/configuring-transports.html

// http://activemq.apache.org/tcp-transport-reference.html

public class ConsumerAndProducerNIO {

public static void main(String[] args) {

ActiveMQConnectionFactory connectionFactory = null;

Connection conn = null;

Session session = null;

MessageConsumer consumer = null;
    try {
// 1、创建连接工厂
connectionFactory = new ActiveMQConnectionFactory("nio://activemq.tony.com:61616");
// 2、创建连接对象
conn = connectionFactory.createConnection();
conn.start();
// 3、 创建session
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
// 4、创建点对点接收的目标
Destination destination = session.createQueue("queue1");
// 5、创建生产者消息
MessageProducer producer = session.createProducer(destination);
// 设置生产者的模式,有两种可选
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// 6、创建一条消息
String text = "Hello world!";
TextMessage message = session.createTextMessage(text);
// 7、发送消息
producer.send(message);
// 8、创建消费者消息
consumer = session.createConsumer(destination);
// 9、接收消息
Message consumerMessage = consumer.receive();
if (consumerMessage instanceof TextMessage) {
System.out.println("收到文本消息:" + ((TextMessage) consumerMessage).getText());
} else {
System.out.println(consumerMessage);
} consumer.close();
session.close();
conn.close();
} catch (JMSException e) {
e.printStackTrace();
}
}

}

5、组播形式,自动发现服务器

  • 组播的形式自动发现服务器: http://activemq.apache.org/multicast-transport-reference.html
  • 自己电脑上启动一个activemq,在activemq.xml connector加上
  • <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?trace=true&amp;maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600" discoveryUri="multicast://default"/>
  • 玩一玩就行,跨网络啥的,要配置网络.客户端不用这个,一般是服务器集群用得到
package com.study.mq.a1_example.discovery;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

// 组播的形式自动发现服务器: http://activemq.apache.org/multicast-transport-reference.html

// 自己电脑上启动一个activemq,在activemq.xml connector加上

// <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?trace=true&amp;maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600" discoveryUri="multicast://default"/>

// 玩一玩就行,跨网络啥的,要配置网络.客户端不用这个,一般是服务器集群用得到

public class ConsumerAndProducerMulticastDiscovery {

public static void main(String[] args) {

ActiveMQConnectionFactory connectionFactory = null;

Connection conn = null;

Session session = null;

MessageConsumer consumer = null;
    try {
// 1、创建连接工厂(不需要手动指定,自动发现)
connectionFactory = new ActiveMQConnectionFactory("discovery:(multicast://default)");
// 2、创建连接对象
conn = connectionFactory.createConnection();
conn.start();
// 3、 创建session
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
// 4、创建点对点接收的目标
Destination destination = session.createQueue("queue1");
// 5、创建生产者消息
MessageProducer producer = session.createProducer(destination);
// 设置生产者的模式,有两种可选
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// 6、创建一条消息
String text = "Hello world!";
TextMessage message = session.createTextMessage(text);
// 7、发送消息
producer.send(message);
// 8、创建消费者消息
consumer = session.createConsumer(destination);
// 9、接收消息
Message consumerMessage = consumer.receive();
if (consumerMessage instanceof TextMessage) {
System.out.println("收到文本消息:" + ((TextMessage) consumerMessage).getText());
} else {
System.out.println(consumerMessage);
} consumer.close();
session.close();
conn.close();
} catch (JMSException e) {
e.printStackTrace();
}
}

}

6、AMQP协议

7、MQTT协议

没收到消息会进行重发

有一个去重的操作,并且性能很差

MQTT实际操作

是一种发布订阅模式

        <dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.0</version>
</dependency>
package com.study.mq.a2_mqtt;

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;

import org.eclipse.paho.client.mqttv3.MqttCallback;

import org.eclipse.paho.client.mqttv3.MqttClient;

import org.eclipse.paho.client.mqttv3.MqttConnectOptions;

import org.eclipse.paho.client.mqttv3.MqttException;

import org.eclipse.paho.client.mqttv3.MqttMessage;

import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; public class MqttProducer {

private static int qos = 1;

private static String broker = "tcp://activemq.tony.com:1883";

private static String userName = "admin";

private static String passWord = "admin";
private static MqttClient connect(String clientId, String userName,
String password) throws MqttException {
MemoryPersistence persistence = new MemoryPersistence();
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setCleanSession(true);
connOpts.setUserName(userName);
connOpts.setPassword(password.toCharArray());
connOpts.setConnectionTimeout(10);
connOpts.setKeepAliveInterval(20);
// String[] uris = {"tcp://10.100.124.206:1883","tcp://10.100.124.207:1883"};
// connOpts.setServerURIs(uris); //这个是mqtt客户端实现的负载均衡和容错
MqttClient mqttClient = new MqttClient(broker, clientId, persistence);
mqttClient.setCallback(new PushCallback("test"));
mqttClient.connect(connOpts);
return mqttClient;
} private static void pub(MqttClient sampleClient, String msg, String topic)
throws Exception {
MqttMessage message = new MqttMessage(msg.getBytes());
message.setQos(qos);
message.setRetained(false);
sampleClient.publish(topic, message);
} private static void publish(String str, String clientId, String topic) throws Exception {
MqttClient mqttClient = connect(clientId, userName, passWord);
if (mqttClient != null) {
pub(mqttClient, str, topic);
System.out.println("pub--&gt;" + str);
}
if (mqttClient != null) {
mqttClient.disconnect();
}
} public static void main(String[] args) throws Exception {
publish("message content", "producer-client-id-0", "x/y/z");
}

}

class PushCallback implements MqttCallback {

private String threadId;

public PushCallback(String threadId) {
this.threadId = threadId;
} public void connectionLost(Throwable cause) {
cause.printStackTrace();
} public void deliveryComplete(IMqttDeliveryToken token) {
System.out.println("服务器是否正确接收---------" + token.isComplete());
} public void messageArrived(String topic, MqttMessage message) throws Exception {
String msg = new String(message.getPayload());
System.out.println(threadId + " " + msg);
}

}

package com.study.mq.a2_mqtt;

import org.eclipse.paho.client.mqttv3.IMqttMessageListener;

import org.eclipse.paho.client.mqttv3.MqttClient;

import org.eclipse.paho.client.mqttv3.MqttConnectOptions;

import org.eclipse.paho.client.mqttv3.MqttException;

import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; public class MqttConsumer {

private static int qos = 2;

private static String broker = "tcp://activemq.tony.com:1883";

private static String userName = "admin";

private static String passWord = "admin";
private static MqttClient connect(String clientId) throws MqttException {
MemoryPersistence persistence = new MemoryPersistence();
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setCleanSession(false);
connOpts.setUserName(userName);
connOpts.setPassword(passWord.toCharArray());
connOpts.setConnectionTimeout(10);
connOpts.setKeepAliveInterval(20);
MqttClient mqttClient = new MqttClient(broker, clientId, persistence);
mqttClient.connect(connOpts);
return mqttClient; } public static void sub(MqttClient mqttClient, String topic) throws MqttException {
int[] Qos = {qos};
String[] topics = {topic};
mqttClient.subscribe(topics, Qos, new IMqttMessageListener[]{(s, mqttMessage) -&gt; {
System.out.println("收到新消息" + s + " &gt; " + mqttMessage.toString());
}});
} private static void runsub(String clientId, String topic) throws MqttException {
MqttClient mqttClient = connect(clientId);
if (mqttClient != null) {
sub(mqttClient, topic);
}
} public static void main(String[] args) throws MqttException {
runsub("consumer-client-id-1", "x/y/z");
}

}

发布订阅

订阅这个topic的客户端都会收到消息

package com.study.mq.a1_example.helloworld.topic;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

// 发布订阅 - 1个生产者对多个消费者

public class Producer {

public static void main(String[] args) {

// brokerUrl: http://activemq.apache.org/connection-configuration-uri.html

new ProducerThread("tcp://activemq.tony.com:61616", "topic1").start();

}
static class ProducerThread extends Thread {
String brokerUrl;
String destinationUrl; public ProducerThread(String brokerUrl, String destinationUrl) {
this.brokerUrl = brokerUrl;
this.destinationUrl = destinationUrl;
} @Override
public void run() {
ActiveMQConnectionFactory connectionFactory;
Connection conn;
Session session; try {
// 1、创建连接工厂
connectionFactory = new ActiveMQConnectionFactory(brokerUrl);
// 2、创建连接对象md
conn = connectionFactory.createConnection();
conn.start();
// 3、创建会话
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
// 4、创建发布的目标 topic
Destination destination = session.createTopic(destinationUrl);
// 5、创建生产者消息
MessageProducer producer = session.createProducer(destination);
// 设置生产者的模式,有两种可选 持久化 / 不持久化
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// 6、创建一条文本消息
String text = "Hello world!";
TextMessage message = session.createTextMessage(text);
for (int i = 0; i &lt; 1; i++) {
// 7、发送消息
producer.send(message);
}
// 8、 关闭连接
session.close();
conn.close();
} catch (JMSException e) {
e.printStackTrace();
}
}
}

}

package com.study.mq.a1_example.helloworld.topic;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

// 非持久订阅者
// 非持久订阅只有当客户端处于连接状态才能收到发送到某个主题的消息,
// 而当客户端处于离线状态,这个时间段发到主题的消息它永远不会收到
public class Consumer {
public static void main(String[] args) {
new ConsumerThread("tcp://activemq.tony.com:61616", "topic1").start();
new ConsumerThread("tcp://activemq.tony.com:61616", "topic1").start();
} } class ConsumerThread extends Thread { String brokerUrl;
String destinationUrl; public ConsumerThread(String brokerUrl, String destinationUrl) {
this.brokerUrl = brokerUrl;
this.destinationUrl = destinationUrl;
} @Override
public void run() {
ActiveMQConnectionFactory connectionFactory;
Connection conn;
Session session;
MessageConsumer consumer; try {
// brokerURL http://activemq.apache.org/connection-configuration-uri.html
// 1、创建连接工厂
connectionFactory = new ActiveMQConnectionFactory(this.brokerUrl);
// 2、创建连接对象
conn = connectionFactory.createConnection();
conn.start(); // 一定要启动
// 3、创建会话(可以创建一个或者多个session)
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
// 4、创建订阅的目标 topic 一条消息,多个订阅者接收
Destination destination = session.createTopic(destinationUrl); // 5、创建消费者消息 http://activemq.apache.org/destination-options.html
consumer = session.createConsumer(destination); // 6、接收消息(没有消息就持续等待)
Message message = consumer.receive();
if (message instanceof TextMessage) {
System.out.println("收到文本消息:" + ((TextMessage) message).getText());
} else {
System.out.println(message);
} consumer.close();
session.close();
conn.close();
} catch (JMSException e) {
e.printStackTrace();
}
}
}

MQTT Spring使用

        <dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mqtt</artifactId>
</dependency>
package mqtt;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

import org.eclipse.paho.client.mqttv3.IMqttClient;

import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.annotation.Bean;

import org.springframework.integration.dsl.IntegrationFlow;

import org.springframework.integration.dsl.IntegrationFlows;

import org.springframework.integration.dsl.Pollers;

import org.springframework.integration.dsl.SourcePollingChannelAdapterSpec;

import org.springframework.integration.endpoint.MessageProducerSupport;

import org.springframework.integration.handler.LoggingHandler;

import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;

import org.springframework.integration.mqtt.core.MqttPahoClientFactory;

import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;

import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;

import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;

import org.springframework.messaging.Message;

import org.springframework.messaging.MessageHandler;

import org.springframework.messaging.MessagingException; import java.util.function.Consumer; @SpringBootApplication

public class MqttApplication {

private static final Log LOGGER = LogFactory.getLog(MqttApplication.class);
public static void main(final String... args) {
// https://spring.io/projects/spring-integration
// https://github.com/spring-projects/spring-integration-samples/
SpringApplication.run(MqttApplication.class, args);
} @Bean
public MqttPahoClientFactory mqttClientFactory() {
DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
MqttConnectOptions options = new MqttConnectOptions();
options.setServerURIs(new String[]{"tcp://activemq.tony.com:1883"});
options.setUserName("admin");
options.setPassword("admin".toCharArray());
factory.setConnectionOptions(options);
return factory;
} // publisher
@Bean
public IntegrationFlow mqttOutFlow() {
// IntegrationFlows.from 数据来源,可以设定为每秒去取数据
return IntegrationFlows.from(() -&gt; "hello mqtt", new Consumer&lt;SourcePollingChannelAdapterSpec&gt;() {
@Override
public void accept(SourcePollingChannelAdapterSpec sourcePollingChannelAdapterSpec) {
sourcePollingChannelAdapterSpec.poller(Pollers.fixedDelay(1000));
}
})
.transform(p -&gt; p + " sent to MQTT")
.handle(mqttOutbound())
.get();
} @Bean
public MessageHandler mqttOutbound() {
// 创建handller
MqttPahoMessageHandler messageHandler = new MqttPahoMessageHandler("client-si-producer-0", mqttClientFactory());
messageHandler.setAsync(true);
messageHandler.setDefaultTopic("x/y/z");
return messageHandler;
} // consumer
@Bean
public IntegrationFlow mqttInFlow() {
return IntegrationFlows.from(mqttInbound())
.transform(p -&gt; p + ", received from MQTT")
.handle(printHandler())
.get();
} private MessageHandler printHandler() {
return new MessageHandler() {
@Override
public void handleMessage(Message&lt;?&gt; message) throws MessagingException {
System.out.println(message.getPayload().toString());
}
};
} @Bean
public MessageProducerSupport mqttInbound() {
MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter("client-si-consumer-1",
mqttClientFactory(), "x/y/z");
adapter.setCompletionTimeout(5000);
adapter.setConverter(new DefaultPahoMessageConverter());
adapter.setQos(1);
return adapter;
}

}

Websocket

只是一个连接方式

package com.study.mq.a3_websocket_stomp;

import org.apache.activemq.ActiveMQConnectionFactory;

import org.apache.activemq.transport.stomp.Stomp;

import org.apache.activemq.transport.stomp.StompConnection;

import org.apache.activemq.transport.stomp.StompFrame; import javax.jms.*; // http://activemq.apache.org/stomp.html

public class ConsumerAndProducerStomp {

public static void main(String[] args) throws Exception {

// 直接用Stomp代码的方式

ConsumerAndProducerStomp.stompTest();

}
public static void stompTest() throws Exception {
StompConnection connection = new StompConnection();
connection.open("activemq.tony.com", 61613); connection.connect("system", "manager"); // 发送两条数据
connection.begin("tx1");
connection.send("/topic/test-stomp", "message1");
connection.send("/topic/test-stomp", "message2");
connection.commit("tx1"); // 订阅/topic/test-stomp
connection.subscribe("/topic/test-stomp", Stomp.Headers.Subscribe.AckModeValues.CLIENT); connection.begin("tx2");
// 接收数据并打印
StompFrame message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");
// 继续接收
message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2"); connection.commit("tx2");
connection.disconnect();
}

}

连接协议和消息协议是不同的,连接协议是tcp之类的,消息协议是AMQP

消息中间件-ActiveMQ支持的消息协议的更多相关文章

  1. ActiveMQ支持的消息协议

    ActiveMQ支持哪些协议 ActiveMQ支持多种协议传输和传输方式,允许客户端使用多种协议连接ActiveMQ支持的协议:AUTO,OpenWire,AMQP,Stomp,MQTT等Active ...

  2. ActiveMQ学习笔记(7)----ActiveMQ支持的传输协议

    1. 连接到ActiveMQ Connector: Active提供的,用来实现连接通讯的功能,包括:client-to-broker,broker-to-broker.ActiveMQ允许客户端使用 ...

  3. 分布式-信息方式-ActiveMQ支持的传输协议和配置

                             ActiveMQ支持的传输协议和配置■ Connector: ActiveMQ提供的,用来实现连接通讯的功能.包括: client-to-broker ...

  4. ActiveMQ支持的传输协议

    ------------------------------------------------------ ActiveMQ支持的client-broker通讯协议有:TCP.NIO.UDP.SSL ...

  5. JMS学习十(ActiveMQ支持的传输协议)

    ActiveMQ提供了一种连接机制,这种连接机制使用传输连接器(TransportConnector)实现客户端与代理(client - to - broker)之间的通信. 网络连接器(networ ...

  6. 消息中间件-activemq实战之消息持久化(六)

    对于activemq消息的持久化我们在第二节的时候就简单介绍过,今天我们详细的来分析一下activemq的持久化过程以及持久化插件.在生产环境中为确保消息的可靠性,我们肯定的面临持久化消息的问题,今天 ...

  7. 消息中间件ActiveMQ使用详解

    消息中间件ActiveMQ使用详解 一.消息中间件的介绍 介绍 ​ 消息队列 是指利用 高效可靠 的 消息传递机制 进行与平台无关的 数据交流,并基于 数据通信 来进行分布式系统的集成. 特点(作用) ...

  8. 消息中间件--ActiveMQ&JMS消息服务

    ### 消息中间件 ### ---------- **消息中间件** 1. 消息中间件的概述 2. 消息中间件的应用场景 * 异步处理 * 应用解耦 * 流量削峰 * 消息通信   --------- ...

  9. 消息中间件-activemq消息机制和持久化介绍(三)

    前面一节简单学习了activemq的使用,我们知道activemq的使用方式非常简单有如下几个步骤: 创建连接工厂 创建连接 创建会话 创建目的地 创建生产者或消费者 生产或消费消息 关闭生产或消费者 ...

随机推荐

  1. 千万不要错过VAST,NGK算力的下一个财富机会!

    我们把目光投向NGK市场,近来,NGK接连新币,推出了SPC后,又有VAST.在目前市场上债券收益率已经趋近于零的情况下,世界上的大多数央行都在试图让本国货币贬值,所以在此时寻找其他保值资产是合理的. ...

  2. webpack4.X源码解析之懒加载

    本文针对Webpack懒加载构建和加载的原理,对构建后的源码进行分析. 一.准备工作 首先,init之后创建一个简单的webpack基本的配置,在src目录下创建两个js文件(一个主入口文件和一个非主 ...

  3. 从零开始搞后台管理系统(1)——shin-admin

      shin 的读音是[ʃɪn],谐音就是行,寓意可行的后台管理系统,shin-admin 的特点是: 站在巨人的肩膀上,依托Umi 2.Dva 2.Ant Design 3和React 16.8搭建 ...

  4. 1053 Path of Equal Weight——PAT甲级真题

    1053 Path of Equal Weight 给定一个非空的树,树根为 RR. 树中每个节点 TiTi 的权重为 WiWi. 从 RR 到 LL 的路径权重定义为从根节点 RR 到任何叶节点 L ...

  5. docket 缺陷

    docker轻量级的虚拟机 依赖于内存和核数 相比于正常的虚拟机来说运行速度会慢

  6. Hadoop生态常用数据模型

    Hadoop生态常用数据模型 一.TextFile 二.SequenceFile 1.特性 2.存储结构 3.压缩结构与读取过程 4.读写操作 三.Avro 1.特性 2.数据类型 3.avro-to ...

  7. js如何判断一假则假,全真则真

    思路:初始化flag参数为true,一旦有一个为假,则将flag赋值为false,最后返回. 代码如下: checkSupplyWt(list){ var flag = true; list.forE ...

  8. MySQL学习笔记(五)

    倒数第二天!冲冲冲!!! 一.索引 一个表里面可以有多个索引. 1. 索引的作用:约束与加速查找 无索引:从前到后依次查找 有索引:会为索引列创造一个额外文件(以某种格式存储).在使用索引进行查找时, ...

  9. virtualbox-centos扩容

    virtualbox-centos扩容 版本信息 virtualbox:版本 6.1.4 r136177 (Qt5.6.2) centos:CentOS Linux release 7.7.1908 ...

  10. 关于使用C3P0程序报错Having failed to acquire a resource, com.mchange.v2.resourcepool的问题

    由于是新手的问题,C3P0的使用时严格跟着视频来的,但是问题却来的很突然 在导入了三个包以及创建了路径以后 进行测试 class JdbcutilsTest { @Test void TestGetC ...