# RabbitMQ

# 如何启用

`cn.wizzer.app.web.commons.core.Module`

```
@IocBy(type = ComboIocProvider.class, args = {"*json", "config/ioc/", "*anno", "cn.wizzer", 
"*jedis", "*tx", "*quartz", "*async", "*rabbitmq"})

```
* 增加 *rabbitmq 配置项

`cn.wizzer.app.web.commons.core.Setup`

* 去掉 initRabbit(config, dao) 前面的注释，执行初始化
* 默认会初始化 topicExchange 和 fanoutExchange 两种消息模式，并初始化默认消费者
* 当集群部署时，请配置并启用RabbitMQ，通过fanoutExchange模式，实现系统参数、自定义路由的重新装载

`rabbit.properties`

* RabbitMQ配置文件

# 如何生产

```
                if (Globals.RabbitMQEnabled) {
                    String exchange = "fanoutExchange";
                    String routeKey = "sysconfig";
                    RabbitMessage msg = new RabbitMessage(exchange, routeKey, new NutMap());
                    rabbitProducer.sendMessage(msg);
                }
```
# 如何消费

改写方法

cn.wizzer.app.web.commons.core.Setup.initRabbit(NutConfig config, Dao dao)