Hello World!

程序员那点事儿

首页 新随笔 联系 聚合 管理
  20 Posts :: 6 Stories :: 0 Comments :: 0 Trackbacks

附一个rocketmq各语言客户端仓库:https://github.com/apache/incubator-rocketmq-externals,我用go客户端,但是master分支的go没有producer,在go-client-develop分支有,尚未合并入主干。

1        安装jdk

1http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html挑一个jdk下载下来。因为需要accept license,不能wget直接下载

2tar zxvf xxxx

3mkdir /usr/local/jdk/jre-xx

4mv xxx /usr/local/jdk/jre-xx

修改环境变量

# vi /etc/profile

#set java env

JAVA_HOME=/usr/local/jdk/

JRE_HOME=/usr/local/jdk/jre

CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib

PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

export JAVA_HOME JRE_HOME CLASS_PATH PATH

# source /etc/profile

验证java

#java -version

java version "1.8.0_144"

Java(TM) SE Runtime Environment (build 1.8.0_144-b01)

Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

2        安装mvn

1wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz

2tar zxvf apache-maven-3.5.0-bin.tar.gz

3mv apache-maven-3.5.0-bin.tar.gz /usr/local/apache-maven

4# vi /etc/profile

export M2_HOME=/usr/local/apache-maven

export PATH=$PATH:$M2_HOME/bin

# source /etc/profile

5、验证是否安装成功

# mvn -version

Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)

Maven home: /usr/local/apache-maven

Java version: 1.8.0_144, vendor: Oracle Corporation

Java home: /usr/local/jdk/jre

Default locale: zh_CN, platform encoding: UTF-8

OS name: "linux", version: "2.6.32-358.el6.x86_64", arch: "amd64", family: "unix"

6、配置maven国内镜像

修改maven根目录下的conf文件夹中的setting.xml文件,内容如下:

 <mirrors>

    <mirror>

      <id>alimaven</id>

      <name>aliyun maven</name>

      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

      <mirrorOf>central</mirrorOf>       

    </mirror>

  </mirrors>

 

3        安装rocketmq

Clone & Build

  > git clone https://github.com/apache/incubator-rocketmq.git
  > cd incubator-rocketmq
  > mvn -Prelease-all -DskipTests clean install -U
  > cd distribution/target/apache-rocketmq
如果服务器内存不够,可以修改runserver.sh脚本(mqnamesrv文件中通过runserver.sh脚本调用Name Server的主函数com.alibaba.rocketmq.namesrv.NamesrvStartup启动Name Server)中的JAVA_OPT_1参数

Start Name Server

  > nohup sh bin/mqnamesrv &
  > tail -f ~/logs/rocketmqlogs/namesrv.log
  The Name Server boot success...

Start Broker

  > nohup sh bin/mqbroker -n localhost:9876 &
  > tail -f ~/logs/rocketmqlogs/broker.log 
  The broker[%s, 172.30.30.233:10911] boot success...

Send & Receive Messages

Before sending/receiving messages, we need to tell clients the location of name servers. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable NAMESRV_ADDR

 > export NAMESRV_ADDR=localhost:9876
 > sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
 SendResult [sendStatus=SEND_OK, msgId= ...
 
 > sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
 ConsumeMessageThread_%d Receive New Messages: [MessageExt...

Shutdown Servers

> sh bin/mqshutdown broker
The mqbroker(36695) is running...
Send shutdown request to mqbroker(36695) OK
 
> sh bin/mqshutdown namesrv
The mqnamesrv(36664) is running...
Send shutdown request to mqnamesrv(36664) OK

More

https://rocketmq.incubator.apache.org/docs/quick-start/
posted on 2017-08-25 11:12 hello wold! 阅读(2185) 评论(0)  编辑 收藏 引用 所属分类: 编程相关

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理