RabbitMQ学习1. 在windows下安装配置

RabbitMQ学习一. 在windows下安装配置

1.下载并安装erlang,http://www.erlang.org/download.html,最新版是R15B01(5.9.1)。由于我机器是64位的Win7,所以找到otp_win64_R15B01.exe下载并安装。

2.配置环境变量
增加一个系统环境变量ERLANG_HOME配置为C:\Program Files\erl5.9.1

3.下载RabbitMQ,最新版是2.8.1,http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.1/rabbitmq-server-windows-2.8.1.zip。

4.解压RabbitMQ的zip包,运行sbin/rabbitmq-server.bat,启动RabbitMQ服务器。

 
5.测试安装是否成功
在 dos命令下进入rabbitmq的sbin目录 rabbitmq <wbr>安装 ,输入 rabbitmq-server start 启动mq服务
 
Rabbit还自带监控功能.
cmd进到sbin目录,键入rabbitmq-plugins enable rabbitmq_management启用监控管理,然后重启Rabbitmq服务器。打开网址http://localhost:55672,用户名和密码都是guest。 
 
node.js 下的rabbitmq api地址:https://github.com/postwait/node-amqp
rabbitmq 安装配置和管理  http://blog.csdn.net/zhangxinrun/article/details/8178262


测试类:

发生消息到MQ



import java.util.concurrent.TimeoutException;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
public class Send {
private final static String QUEUE_NAME = "hello";
public static void main(String[] argv) throws java.io.IOException, TimeoutException {


/* 使用工厂类建立Connection和Channel,并且设置参数 */
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");// MQ的IP
factory.setPort(5672);// MQ端口
factory.setUsername("guest");// MQ用户名
factory.setPassword("guest");// MQ密码
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
/* 创建消息队列,并且发送消息 */
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
String message = "Hello World!"+System.currentTimeMillis();
channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
System.out.println(" [x] Sent '" + message + "'");


/* 关闭连接 */
channel.close();
connection.close();
}
}
接受mq消息

import com.rabbitmq.client.Channel;  
import com.rabbitmq.client.Connection;  
import com.rabbitmq.client.ConnectionFactory;  
import com.rabbitmq.client.QueueingConsumer;  
  
public class Reqv {  
    private final static String QUEUE_NAME = "hello";  
  
    public static void main(String[] argv) throws Exception {  
  
        ConnectionFactory factory = new ConnectionFactory();  
        factory.setHost("localhost");  
        Connection connection = factory.newConnection();  
        Channel channel = connection.createChannel();  
  
        channel.queueDeclare(QUEUE_NAME, false, false, false, null);  
        System.out.println(" [*] Waiting for messages. To exit press CTRL+C");  
  
        QueueingConsumer consumer = new QueueingConsumer(channel);  
        channel.basicConsume(QUEUE_NAME, true, consumer);  
  
        while (true) {  
            QueueingConsumer.Delivery delivery = consumer.nextDelivery();  
            String message = new String(delivery.getBody());  
            System.out.println(" [x1] Received '" + message + "'");  
        }  
    }  
}  

RabbitMQ 3.6.12 is a maintenance release. Upgrades and Compatibility See the "Upgrading clusters" section of the documentation for general documentation on upgrades. This release has no other known incompatibilities with versions 3.6.7 through 3.6.11. See the upgrade and compatibility sections in the 3.6.7 release notes if upgrading from an earlier release. Core Server Bug Fixes Process responsible for running the autoheal partition handling strategy could run into a deadlock with its peers, preventing autoheal from completing. GitHub issue: rabbitmq-server#1346 Garbage collection of mirrored queue metrics on nodes that did not host a master or mirror for a queue affected delivery and acknowledgement rates. This could result in rates being 0 or negative when they should not be. GitHub issue: rabbitmq-server#1340 Stats emission could prevent queue mirrors from performing garbage collection and consume memory even when they were empty. GitHub issue: rabbitmq-common#220 (continuation to rabbitmq-common#196) RABBITMQ_SCHEDULER_BIND_TYPE and RABBITMQ_DISTRIBUTION_BUFFER_SIZE now can be set via rabbitmq-env.conf. GitHub issue: rabbitmq-server#1338 Shovel Management Plugin Bug Fixes Passwords in source and destination URIs are now redacted out. GitHub issue: rabbitmq-federation-management#15 Federation Management Plugin Bug Fixes Passwords in upstream URIs are now redacted out. GitHub issue: rabbitmq-federation-management#15 Upgrading To upgrade a non-clustered RabbitMQ simply install the new version. All configuration and persistent message data are retained. When upgrading using definitions export/import from versions earlier than 3.6.0, see http://rabbitmq.com/passwords.html. To upgrade a RabbitMQ cluster, follow the instructions in RabbitMQ documentation.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值