- 浏览: 2261566 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (423)
- FileNet相关 (3)
- 应用服务器相关 (22)
- Java综合 (77)
- 持久层 (24)
- struts (11)
- webservice (8)
- 虚拟机 (2)
- 光盘刻录 (0)
- AD及AD集群 (1)
- JS (33)
- F5 (0)
- loadrunner8.1 (0)
- Java 反编译工具 (2)
- DataBase (62)
- ant (1)
- 操作系统 (29)
- 我的任务 (3)
- 平台架构 (16)
- 业务规则引擎 (2)
- 模板 (1)
- EJB (5)
- spring (24)
- CMMI (1)
- 项目管理 (20)
- LDAP (13)
- JMS (10)
- JSP (19)
- JBPM (2)
- web MVC框架设计思想 (2)
- 第三方支付平台 (2)
- BUG管理工具 (1)
- 垃圾站 (2)
- php (1)
- swing (1)
- 书籍 (1)
- QQ qq (2)
- 移动互联网 (26)
- 爱听的歌曲 (0)
- hadoop (4)
- 数据库 (9)
- 设计模式 (1)
- 面试经验只谈 (1)
- 大数据 (9)
- sp (1)
- 缓存数据库 (8)
- storm (2)
- taobao (2)
- 分布式,高并发,大型互联网,负载均衡 (6)
- Apache Ignite (0)
- Docker & K8S (0)
最新评论
-
wangyudong:
新版本 Wisdom RESTClienthttps://gi ...
spring rest mvc使用RestTemplate调用 -
wangyudong:
很多API doc生成工具生成API文档需要引入第三方依赖,重 ...
spring rest mvc使用RestTemplate调用 -
zhaoshijie:
cfying 写道大侠,还是加载了两次,怎么解决啊?求。QQ: ...
spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件) -
xinglianxlxl:
对我有用,非常感谢
spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件) -
k_caesar:
多谢,学习了
利用maven的resources、filter和profile实现不同环境使用不同配置文件
RocketMQ在Windows7上安装和使用(注:win8失败)
1.RocketMQ简介
RocketMQ是alibaba公司开源的一个纯java的开源消息中间件。
2.开发测试环境搭建
下载安装包:https://github.com/alibaba/RocketMQ/releases(下载:alibaba-rocketmq-3.2.6.tar.gz)-解压安装包
CD D:\machine\RocketMQ-3.0.8>cd alibaba-rocketmq
创建日志需要的路径:D:\logs\alibaba-rocketmq
启动服务
//启动mqnamesrv
D:\machine\RocketMQ-3.0.8\alibaba-rocketmq>start/b bin/mqnamesrv.exe >D:\logs\alibaba-rocketmq/mqnamesrv.log
可以通过jps查看一下是不是有了RocketMQ的进程,如下方的6484
C:\Users\houchangren>jps -v
6484 -Djava.ext.dirs=D:\machine\RocketMQ-3.0.8\alibaba-rocketmq\bin/../lib-Drocketmq.home.dir=D:\machine\RocketMQ-3.0.8\alibaba-rocketmq\bin/..-XX:MaxNewSize=512M -XX:MaxPermSize=128M -XX:NewSit abort
6876 JConsole -Denv.class.path=D:\ProgramFiles\Java\jdk1.6.0_26\lib -Dapplication.home=D:\Program Files\Java\jdk1.6.0_26-Djconsole.showOutputViewer
6936org.eclipse.equinox.launcher_1.2.0.v20110502.jar -Dosgi.requiredJavaVersion=1.5-Xms40m -Xmx512m -XX:MaxPermSize=256m
4140 Jps -Denv.class.path=D:\ProgramFiles\Java\jdk1.6.0_26\lib -Dapplication.home=D:\Program Files\Java\jdk1.6.0_26-Xms8m
看日志中信息D:\logs\alibaba-rocketmq/mqnamesrv.log
The Name Server boot success.
//启动broker
D:\machine\RocketMQ-3.0.8\alibaba-rocketmq>start/b bin/mqbroker.exe -n "10.57.41.19:9876">D:\logs\alibaba-rocketmq/mqbroker.log
看日志中信息D:\logs\alibaba-rocketmq/mqbroker.log
The broker[houchangren, 10.57.41.19:10911]boot success.
2.项目实例
1. 创建maven项目
Pom.xml文件如下
<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.0http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ruishenh</groupId>
<artifactId>gomeTest</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>gomeTest Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.alibaba.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>com.alibaba.rocketmq</groupId>
<artifactId>rocketmq-all</artifactId>
<version>3.0.8</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>gomeTest</finalName>
</build>
</project>
2. 编写消息产生者Producer
文件路径:/gomeTest/src/main/java/com/ruishenh/rocketmq/example/Producer.java
package com.ruishenh.rocketmq.example;
import java.util.concurrent.TimeUnit;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;
public classProducer {
public static void main(String[] args) throws MQClientException,
InterruptedException{
/**
* 一个应用创建一个Producer,由应用来维护此对象,可以设置为全局对象或者单例<br>
* 注意:ProducerGroupName需要由应用来保证唯一<br>
* ProducerGroup这个概念发送普通的消息时,作用不大,但是发送分布式事务消息时,比较关键,
* 因为服务器会回查这个Group下的任意一个Producer
*/
final DefaultMQProducerproducer = newDefaultMQProducer("ProducerGroupName");
producer.setNamesrvAddr("10.57.41.19:9876");
producer.setInstanceName("Producer");
/**
* Producer对象在使用之前必须要调用start初始化,初始化一次即可<br>
* 注意:切记不可以在每次发送消息时,都调用start方法
*/
producer.start();
/**
* 下面这段代码表明一个Producer对象可以发送多个topic,多个tag的消息。
* 注意:send方法是同步调用,只要不抛异常就标识成功。但是发送成功也可会有多种状态,<br>
* 例如消息写入Master成功,但是Slave不成功,这种情况消息属于成功,但是对于个别应用如果对消息可靠性要求极高,<br>
* 需要对这种情况做处理。另外,消息可能会存在发送失败的情况,失败重试由应用来处理。
*/
for (int i = 0; i < 10; i++){
try {
{
Messagemsg = newMessage("TopicTest1",// topic
"TagA",// tag
"OrderID001",// key
("Hello MetaQA").getBytes());// body
SendResultsendResult = producer.send(msg);
System.out.println(sendResult);
}
{
Messagemsg = newMessage("TopicTest2",// topic
"TagB",// tag
"OrderID0034",// key
("Hello MetaQB").getBytes());// body
SendResultsendResult = producer.send(msg);
System.out.println(sendResult);
}
{
Messagemsg = newMessage("TopicTest3",// topic
"TagC",// tag
"OrderID061",// key
("Hello MetaQC").getBytes());// body
SendResultsendResult = producer.send(msg);
System.out.println(sendResult);
}
}catch(Exception e) {
e.printStackTrace();
}
TimeUnit.MILLISECONDS.sleep(1000);
}
/**
* 应用退出时,要调用shutdown来清理资源,关闭网络连接,从MetaQ服务器上注销自己
* 注意:我们建议应用在JBOSS、Tomcat等容器的退出钩子里调用shutdown方法
*/
// producer.shutdown();
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
producer.shutdown();
}
}));
System.exit(0);
}
}
3. 编写消息消费者Consumer
文件路径:Test/src/main/java/com/ruishenh/rocketmq/example/PushConsumer.java
package com.ruishenh.rocketmq.example;
import java.util.List;
importcom.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
importcom.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
importcom.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
importcom.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
importcom.alibaba.rocketmq.client.exception.MQClientException;
importcom.alibaba.rocketmq.common.message.MessageExt;
public class PushConsumer {
/**
* 当前例子是PushConsumer用法,使用方式给用户感觉是消息从RocketMQ服务器推到了应用客户端。<br>
* 但是实际PushConsumer内部是使用长轮询Pull方式从MetaQ服务器拉消息,然后再回调用户Listener方法<br>
*/
publicstatic void main(String[] args) throws InterruptedException,
MQClientException{
/**
* 一个应用创建一个Consumer,由应用来维护此对象,可以设置为全局对象或者单例<br>
* 注意:ConsumerGroupName需要由应用来保证唯一
*/
DefaultMQPushConsumerconsumer = new DefaultMQPushConsumer(
"ConsumerGroupName");
consumer.setNamesrvAddr("10.57.41.19:9876");
consumer.setInstanceName("Consumber");
/**
* 订阅指定topic下tags分别等于TagA或TagC或TagD
*/
consumer.subscribe("TopicTest1","TagA || TagC || TagD");
/**
* 订阅指定topic下所有消息<br>
* 注意:一个consumer对象可以订阅多个topic
*/
consumer.subscribe("TopicTest2","*");
consumer.registerMessageListener(newMessageListenerConcurrently() {
publicConsumeConcurrentlyStatus consumeMessage(
List<MessageExt>msgs, ConsumeConcurrentlyContext context) {
System.out.println(Thread.currentThread().getName()
+" Receive New Messages: " + msgs.size());
MessageExtmsg = msgs.get(0);
if(msg.getTopic().equals("TopicTest1")) {
//执行TopicTest1的消费逻辑
if(msg.getTags() != null && msg.getTags().equals("TagA")) {
//执行TagA的消费
System.out.println(newString(msg.getBody()));
}else if (msg.getTags() != null
&&msg.getTags().equals("TagC")) {
//执行TagC的消费
System.out.println(newString(msg.getBody()));
}else if (msg.getTags() != null
&&msg.getTags().equals("TagD")) {
//执行TagD的消费
System.out.println(newString(msg.getBody()));
}
}else if (msg.getTopic().equals("TopicTest2")) {
System.out.println(newString(msg.getBody()));
}
returnConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
});
/**
* Consumer对象在使用之前必须要调用start初始化,初始化一次即可<br>
*/
consumer.start();
System.out.println("ConsumerStarted.");
}
}
Producer执行console:
12:05:39.399 [main] DEBUGi.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
12:05:39.405 [main] DEBUGi.n.c.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
12:05:39.411 [main] DEBUGi.n.util.internal.PlatformDependent - Platform: Windows
12:05:39.411 [main] DEBUGi.n.util.internal.PlatformDependent - Java version: 6
12:05:39.411 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false
12:05:39.412 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.ByteBuffer.cleaner: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent - sun.misc.Unsafe: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noJavassist: false
12:05:39.414 [main] DEBUGi.n.util.internal.PlatformDependent - Javassist: unavailable
12:05:39.414 [main] DEBUGi.n.util.internal.PlatformDependent - You don't have Javassist in your classpath or you don't have enough permission to load dynamically generatedclasses. Please check the configurationfor better performance.
12:05:39.414 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
12:05:39.429 [main] DEBUGio.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
12:05:39.429 [main] DEBUGio.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold:512
12:05:39.481 [main] DEBUGi.n.util.internal.ThreadLocalRandom - -Dio.netty.initialSeedUniquifier:0x653a966ddb02e036
12:05:39.523[NettyClientWorkerThread_1] DEBUG io.netty.util.ResourceLeakDetector --Dio.netty.noResourceLeakDetection: false
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BA16, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=0], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BAAB, messageQueue=MessageQueue [topic=TopicTest2,brokerName=houchangren, queueId=0], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BB41, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=0], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BBD6, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=1], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BC6B, messageQueue=MessageQueue [topic=TopicTest2,brokerName=houchangren, queueId=1], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BD01, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=1], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BD96, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=2], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BE2B, messageQueue=MessageQueue [topic=TopicTest2,brokerName=houchangren, queueId=2], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BEC1, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=2], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BF56, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=3], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BFEB, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=3], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C081, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=3], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C116, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=0], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C1AB, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=0], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C241, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=0], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C2D6, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=1], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C36B, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=1], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C401, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=1], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C496, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=2], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C52B, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=2], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C5C1, messageQueue=MessageQueue [topic=TopicTest3,brokerName=houchangren, queueId=2], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C656, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=3], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C6EB, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=3], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C781, messageQueue=MessageQueue [topic=TopicTest3,brokerName=houchangren, queueId=3], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C816, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=0], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C8AB, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=0], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C941, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=0], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C9D6, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=1], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001CA6B, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=1], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001CB01, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=1], queueOffset=68]
Consumer执行console:
12:00:49.539 [main] DEBUGi.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
12:00:49.545 [main] DEBUGi.n.c.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
12:00:49.550 [main] DEBUGi.n.util.internal.PlatformDependent - Platform: Windows
12:00:49.550 [main] DEBUGi.n.util.internal.PlatformDependent - Java version: 6
12:00:49.550 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false
12:00:49.551 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.ByteBuffer.cleaner: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent - sun.misc.Unsafe: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noJavassist: false
12:00:49.553 [main] DEBUGi.n.util.internal.PlatformDependent - Javassist: unavailable
12:00:49.553 [main] DEBUGi.n.util.internal.PlatformDependent - You don't have Javassist in your classpath or you don't have enough permission to load dynamically generatedclasses. Please check the configurationfor better performance.
12:00:49.553 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
12:00:49.568 [main] DEBUGio.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
12:00:49.568 [main] DEBUGio.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold:512
12:00:49.622 [main] DEBUGi.n.util.internal.ThreadLocalRandom - -Dio.netty.initialSeedUniquifier:0x2e4f8e2e67b4cc9b
12:00:49.663[NettyClientWorkerThread_1] DEBUG io.netty.util.ResourceLeakDetector --Dio.netty.noResourceLeakDetection: false
Consumer Started.
ConsumeMessageThread-ConsumerGroupName-4Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-2Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-1Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-6Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-5Receive New Messages: 1
ConsumeMessageThread-ConsumerGroupName-3Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-8Receive New Messages: 1
Hello MetaQA
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-9Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-10Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-7Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-11Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-12Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-13Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-15Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-14Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-16Receive New Messages: 1
ConsumeMessageThread-ConsumerGroupName-17Receive New Messages: 1
Hello MetaQB
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-18Receive New Messages: 1
ConsumeMessageThread-ConsumerGroupName-19Receive New Messages: 1
Hello MetaQB
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-20Receive New Messages: 1
Hello MetaQB
RocketMQ是alibaba公司开源的一个纯java的开源消息中间件。
2.开发测试环境搭建
下载安装包:https://github.com/alibaba/RocketMQ/releases(下载:alibaba-rocketmq-3.2.6.tar.gz)-解压安装包
CD D:\machine\RocketMQ-3.0.8>cd alibaba-rocketmq
创建日志需要的路径:D:\logs\alibaba-rocketmq
启动服务
//启动mqnamesrv
D:\machine\RocketMQ-3.0.8\alibaba-rocketmq>start/b bin/mqnamesrv.exe >D:\logs\alibaba-rocketmq/mqnamesrv.log
可以通过jps查看一下是不是有了RocketMQ的进程,如下方的6484
C:\Users\houchangren>jps -v
6484 -Djava.ext.dirs=D:\machine\RocketMQ-3.0.8\alibaba-rocketmq\bin/../lib-Drocketmq.home.dir=D:\machine\RocketMQ-3.0.8\alibaba-rocketmq\bin/..-XX:MaxNewSize=512M -XX:MaxPermSize=128M -XX:NewSit abort
6876 JConsole -Denv.class.path=D:\ProgramFiles\Java\jdk1.6.0_26\lib -Dapplication.home=D:\Program Files\Java\jdk1.6.0_26-Djconsole.showOutputViewer
6936org.eclipse.equinox.launcher_1.2.0.v20110502.jar -Dosgi.requiredJavaVersion=1.5-Xms40m -Xmx512m -XX:MaxPermSize=256m
4140 Jps -Denv.class.path=D:\ProgramFiles\Java\jdk1.6.0_26\lib -Dapplication.home=D:\Program Files\Java\jdk1.6.0_26-Xms8m
看日志中信息D:\logs\alibaba-rocketmq/mqnamesrv.log
The Name Server boot success.
//启动broker
D:\machine\RocketMQ-3.0.8\alibaba-rocketmq>start/b bin/mqbroker.exe -n "10.57.41.19:9876">D:\logs\alibaba-rocketmq/mqbroker.log
看日志中信息D:\logs\alibaba-rocketmq/mqbroker.log
The broker[houchangren, 10.57.41.19:10911]boot success.
2.项目实例
1. 创建maven项目
Pom.xml文件如下
<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.0http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ruishenh</groupId>
<artifactId>gomeTest</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>gomeTest Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.alibaba.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>com.alibaba.rocketmq</groupId>
<artifactId>rocketmq-all</artifactId>
<version>3.0.8</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>gomeTest</finalName>
</build>
</project>
2. 编写消息产生者Producer
文件路径:/gomeTest/src/main/java/com/ruishenh/rocketmq/example/Producer.java
package com.ruishenh.rocketmq.example;
import java.util.concurrent.TimeUnit;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;
public classProducer {
public static void main(String[] args) throws MQClientException,
InterruptedException{
/**
* 一个应用创建一个Producer,由应用来维护此对象,可以设置为全局对象或者单例<br>
* 注意:ProducerGroupName需要由应用来保证唯一<br>
* ProducerGroup这个概念发送普通的消息时,作用不大,但是发送分布式事务消息时,比较关键,
* 因为服务器会回查这个Group下的任意一个Producer
*/
final DefaultMQProducerproducer = newDefaultMQProducer("ProducerGroupName");
producer.setNamesrvAddr("10.57.41.19:9876");
producer.setInstanceName("Producer");
/**
* Producer对象在使用之前必须要调用start初始化,初始化一次即可<br>
* 注意:切记不可以在每次发送消息时,都调用start方法
*/
producer.start();
/**
* 下面这段代码表明一个Producer对象可以发送多个topic,多个tag的消息。
* 注意:send方法是同步调用,只要不抛异常就标识成功。但是发送成功也可会有多种状态,<br>
* 例如消息写入Master成功,但是Slave不成功,这种情况消息属于成功,但是对于个别应用如果对消息可靠性要求极高,<br>
* 需要对这种情况做处理。另外,消息可能会存在发送失败的情况,失败重试由应用来处理。
*/
for (int i = 0; i < 10; i++){
try {
{
Messagemsg = newMessage("TopicTest1",// topic
"TagA",// tag
"OrderID001",// key
("Hello MetaQA").getBytes());// body
SendResultsendResult = producer.send(msg);
System.out.println(sendResult);
}
{
Messagemsg = newMessage("TopicTest2",// topic
"TagB",// tag
"OrderID0034",// key
("Hello MetaQB").getBytes());// body
SendResultsendResult = producer.send(msg);
System.out.println(sendResult);
}
{
Messagemsg = newMessage("TopicTest3",// topic
"TagC",// tag
"OrderID061",// key
("Hello MetaQC").getBytes());// body
SendResultsendResult = producer.send(msg);
System.out.println(sendResult);
}
}catch(Exception e) {
e.printStackTrace();
}
TimeUnit.MILLISECONDS.sleep(1000);
}
/**
* 应用退出时,要调用shutdown来清理资源,关闭网络连接,从MetaQ服务器上注销自己
* 注意:我们建议应用在JBOSS、Tomcat等容器的退出钩子里调用shutdown方法
*/
// producer.shutdown();
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
producer.shutdown();
}
}));
System.exit(0);
}
}
3. 编写消息消费者Consumer
文件路径:Test/src/main/java/com/ruishenh/rocketmq/example/PushConsumer.java
package com.ruishenh.rocketmq.example;
import java.util.List;
importcom.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
importcom.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
importcom.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
importcom.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
importcom.alibaba.rocketmq.client.exception.MQClientException;
importcom.alibaba.rocketmq.common.message.MessageExt;
public class PushConsumer {
/**
* 当前例子是PushConsumer用法,使用方式给用户感觉是消息从RocketMQ服务器推到了应用客户端。<br>
* 但是实际PushConsumer内部是使用长轮询Pull方式从MetaQ服务器拉消息,然后再回调用户Listener方法<br>
*/
publicstatic void main(String[] args) throws InterruptedException,
MQClientException{
/**
* 一个应用创建一个Consumer,由应用来维护此对象,可以设置为全局对象或者单例<br>
* 注意:ConsumerGroupName需要由应用来保证唯一
*/
DefaultMQPushConsumerconsumer = new DefaultMQPushConsumer(
"ConsumerGroupName");
consumer.setNamesrvAddr("10.57.41.19:9876");
consumer.setInstanceName("Consumber");
/**
* 订阅指定topic下tags分别等于TagA或TagC或TagD
*/
consumer.subscribe("TopicTest1","TagA || TagC || TagD");
/**
* 订阅指定topic下所有消息<br>
* 注意:一个consumer对象可以订阅多个topic
*/
consumer.subscribe("TopicTest2","*");
consumer.registerMessageListener(newMessageListenerConcurrently() {
publicConsumeConcurrentlyStatus consumeMessage(
List<MessageExt>msgs, ConsumeConcurrentlyContext context) {
System.out.println(Thread.currentThread().getName()
+" Receive New Messages: " + msgs.size());
MessageExtmsg = msgs.get(0);
if(msg.getTopic().equals("TopicTest1")) {
//执行TopicTest1的消费逻辑
if(msg.getTags() != null && msg.getTags().equals("TagA")) {
//执行TagA的消费
System.out.println(newString(msg.getBody()));
}else if (msg.getTags() != null
&&msg.getTags().equals("TagC")) {
//执行TagC的消费
System.out.println(newString(msg.getBody()));
}else if (msg.getTags() != null
&&msg.getTags().equals("TagD")) {
//执行TagD的消费
System.out.println(newString(msg.getBody()));
}
}else if (msg.getTopic().equals("TopicTest2")) {
System.out.println(newString(msg.getBody()));
}
returnConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
});
/**
* Consumer对象在使用之前必须要调用start初始化,初始化一次即可<br>
*/
consumer.start();
System.out.println("ConsumerStarted.");
}
}
Producer执行console:
12:05:39.399 [main] DEBUGi.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
12:05:39.405 [main] DEBUGi.n.c.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
12:05:39.411 [main] DEBUGi.n.util.internal.PlatformDependent - Platform: Windows
12:05:39.411 [main] DEBUGi.n.util.internal.PlatformDependent - Java version: 6
12:05:39.411 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false
12:05:39.412 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.ByteBuffer.cleaner: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent - sun.misc.Unsafe: available
12:05:39.413 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noJavassist: false
12:05:39.414 [main] DEBUGi.n.util.internal.PlatformDependent - Javassist: unavailable
12:05:39.414 [main] DEBUGi.n.util.internal.PlatformDependent - You don't have Javassist in your classpath or you don't have enough permission to load dynamically generatedclasses. Please check the configurationfor better performance.
12:05:39.414 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
12:05:39.429 [main] DEBUGio.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
12:05:39.429 [main] DEBUGio.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold:512
12:05:39.481 [main] DEBUGi.n.util.internal.ThreadLocalRandom - -Dio.netty.initialSeedUniquifier:0x653a966ddb02e036
12:05:39.523[NettyClientWorkerThread_1] DEBUG io.netty.util.ResourceLeakDetector --Dio.netty.noResourceLeakDetection: false
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BA16, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=0], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BAAB, messageQueue=MessageQueue [topic=TopicTest2,brokerName=houchangren, queueId=0], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BB41, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=0], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BBD6, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=1], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BC6B, messageQueue=MessageQueue [topic=TopicTest2,brokerName=houchangren, queueId=1], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BD01, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=1], queueOffset=66]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BD96, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=2], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BE2B, messageQueue=MessageQueue [topic=TopicTest2,brokerName=houchangren, queueId=2], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BEC1, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=2], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BF56, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=3], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001BFEB, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=3], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C081, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=3], queueOffset=61]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C116, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=0], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C1AB, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=0], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C241, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=0], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C2D6, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=1], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C36B, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=1], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C401, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=1], queueOffset=67]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C496, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=2], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C52B, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=2], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C5C1, messageQueue=MessageQueue [topic=TopicTest3,brokerName=houchangren, queueId=2], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C656, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=3], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C6EB, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=3], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C781, messageQueue=MessageQueue [topic=TopicTest3,brokerName=houchangren, queueId=3], queueOffset=62]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C816, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=0], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C8AB, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=0], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C941, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=0], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001C9D6, messageQueue=MessageQueue[topic=TopicTest1, brokerName=houchangren, queueId=1], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001CA6B, messageQueue=MessageQueue[topic=TopicTest2, brokerName=houchangren, queueId=1], queueOffset=68]
SendResult [sendStatus=SEND_OK,msgId=0A39291300002A9F000000000001CB01, messageQueue=MessageQueue[topic=TopicTest3, brokerName=houchangren, queueId=1], queueOffset=68]
Consumer执行console:
12:00:49.539 [main] DEBUGi.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
12:00:49.545 [main] DEBUGi.n.c.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
12:00:49.550 [main] DEBUGi.n.util.internal.PlatformDependent - Platform: Windows
12:00:49.550 [main] DEBUGi.n.util.internal.PlatformDependent - Java version: 6
12:00:49.550 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false
12:00:49.551 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.ByteBuffer.cleaner: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent - sun.misc.Unsafe: available
12:00:49.552 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noJavassist: false
12:00:49.553 [main] DEBUGi.n.util.internal.PlatformDependent - Javassist: unavailable
12:00:49.553 [main] DEBUGi.n.util.internal.PlatformDependent - You don't have Javassist in your classpath or you don't have enough permission to load dynamically generatedclasses. Please check the configurationfor better performance.
12:00:49.553 [main] DEBUGi.n.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
12:00:49.568 [main] DEBUGio.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
12:00:49.568 [main] DEBUGio.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold:512
12:00:49.622 [main] DEBUGi.n.util.internal.ThreadLocalRandom - -Dio.netty.initialSeedUniquifier:0x2e4f8e2e67b4cc9b
12:00:49.663[NettyClientWorkerThread_1] DEBUG io.netty.util.ResourceLeakDetector --Dio.netty.noResourceLeakDetection: false
Consumer Started.
ConsumeMessageThread-ConsumerGroupName-4Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-2Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-1Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-6Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-5Receive New Messages: 1
ConsumeMessageThread-ConsumerGroupName-3Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-8Receive New Messages: 1
Hello MetaQA
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-9Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-10Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-7Receive New Messages: 1
Hello MetaQA
ConsumeMessageThread-ConsumerGroupName-11Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-12Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-13Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-15Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-14Receive New Messages: 1
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-16Receive New Messages: 1
ConsumeMessageThread-ConsumerGroupName-17Receive New Messages: 1
Hello MetaQB
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-18Receive New Messages: 1
ConsumeMessageThread-ConsumerGroupName-19Receive New Messages: 1
Hello MetaQB
Hello MetaQB
ConsumeMessageThread-ConsumerGroupName-20Receive New Messages: 1
Hello MetaQB
相关推荐
在Windows上部署RocketMQ,首先确保Java开发环境已安装,即JDK,并配置好环境变量。推荐使用JDK 8或更高版本。 **三、RocketMQ单机模式安装** 1. 下载RocketMQ的Windows版本,解压到指定目录。 2. 打开命令行,切换...
本教程将详细讲解如何在Windows操作系统上进行RocketMQ的安装与配置,适合初学者快速入门。 一、 RocketMQ的组成部分 RocketMQ主要包含四个核心组件:NameServer、Broker、Producer和Consumer。NameServer是服务...
以下将详细介绍如何在Windows上部署RocketMQ。 首先,理解RocketMQ的基本概念至关重要。RocketMQ的核心功能是作为消息代理,它在生产者与消费者之间传递消息,确保数据的可靠传输。它支持多种消息模式,如点对点...
centos7 安装 ROCKETMQ rocketmq-all-4.9.4
总之,RocketMQ 4.9.1在Windows上的部署和使用涉及多个环节,包括环境配置、服务启动、客户端集成、管理和监控等。了解和掌握这些知识点,将有助于你在实际项目中充分利用RocketMQ的性能和功能,构建可靠的分布式...
我们需要先将这个JDK安装到服务器上,配置好环境变量,确保系统可以识别并使用Java。 接下来是 RocketMQ 的安装。通常,这涉及到下载RocketMQ的源码或者二进制包,然后解压到服务器的指定目录,并启动NameServer、...
8. **测试发送与接收消息**: 使用RocketMQ提供的样例客户端,或者自行编写客户端代码,测试消息的发送和接收。确保一切正常后,RocketMQ在Windows上的部署即完成。 注意,RocketMQ在Windows上的部署可能遇到一些与...
在Windows环境下部署RocketMQ 4.7.0版本,可以提供高效、稳定的消息服务,以支持高并发、低延迟的业务需求。 在`rocketmq-all-4.7.0-bin-release.zip`压缩包中,包含了以下主要组件和文件: 1. **bin目录**:包含...
在这个"rocketmq4.5.0安装部署(安装包,开发手册,配置文件).zip"压缩包中,包含了进行RocketMQ 4.5.0版本安装和部署所需的所有关键资源。 首先,我们来看"RocketMQ 开发手册3.2.4.pdf",这是一份详细的开发者指南...
最后,虽然`jpype1`提供了一种方式来调用Java的RocketMQ,但是这种方法可能在性能和易用性上不如专门为Python设计的客户端,比如`pyrocketmq`。如果可能的话,建议考虑使用专门为Python编写的RocketMQ客户端,这样...
rocketmq docker安装全流程
RocketMQ-4.0.0的安装及使用
标题和描述部分提到的知识点是关于如何安装和部署RocketMQ集群。RocketMQ是一个开源的消息中间件,由阿里巴巴开源,并且是Apache顶级项目,广泛应用于高并发、高可靠的消息分发场景中。 首先,部署RocketMQ集群需要...
在Linux环境下进行RocketMQ的安装部署是一项重要的系统管理工作,本文将详细介绍如何在Linux系统上完成RocketMQ的4.8.0版本的安装和配置。 首先,我们需要了解RocketMQ的基本架构。RocketMQ主要包括NameServer、...
3. **配置与连接**:在控制台上,你需要配置RocketMQ集群的NameServer地址,然后可以查看和管理你的主题(Topic)、队列(Queue)等资源,监控消费状态,进行消息查询等操作。 在实际应用中,RocketMQ支持多种部署...
在本文中,我们将深入探讨RocketMQ Dashboard的相关知识点,包括其功能、特性、安装与使用以及它如何帮助用户更好地管理RocketMQ集群。 1. **RocketMQ Dashboard的功能**: - **监控**: 提供实时的消费者和生产者...
通过以上介绍,我们可以看到RocketMQ是一个强大而灵活的消息中间件,4.9.0版本针对Windows平台提供了全面的支持,便于开发者在Windows环境中部署和使用。无论是开发分布式系统,还是优化现有应用的性能,RocketMQ都...