Skip to content

Commit

Permalink
fix: Module 注入mq 前,预先加载 MqConfig 配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
liqingfeng committed Feb 12, 2019
1 parent 7cc0421 commit 6310cce
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.artlongs.act.mq.plugin.rabbit;

import act.app.App;
import act.event.EventBus;
import com.artlongs.act.mq.plugin.core.CallMe;
import com.artlongs.act.mq.plugin.core.MQ;
Expand All @@ -21,6 +22,8 @@
import java.io.IOException;
import java.util.concurrent.TimeoutException;

import static act.app.conf.AutoConfigPlugin.loadPluginAutoConfig;

/**
* Rabbitmq 实现
* Created by leeton on 8/18/17.
Expand Down Expand Up @@ -49,6 +52,7 @@ public RabbitMqImpl init(ISerializer serializer) {
public static class Module extends org.osgl.inject.Module {
@Override
protected void configure() {
loadPluginAutoConfig(MqConfig.class, App.instance()); // 预先加载 MqConfig 配置文件
bind(MQ.class).in(Singleton.class).qualifiedWith(RabbitMq.class).named("rabbitmq").to(new Provider<MQ>() {
@Override
public MQ get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import javax.inject.Provider;
import javax.inject.Singleton;

import static act.app.conf.AutoConfigPlugin.loadPluginAutoConfig;

/**
* REDIS 消息发送与接收
* Created by leeton on 8/22/17.
Expand All @@ -30,6 +32,7 @@ public class RedisMqImpl implements MQ {
public static class Module extends org.osgl.inject.Module {
@Override
protected void configure() {
loadPluginAutoConfig(MqConfig.class, App.instance()); // 预先加载 MqConfig 配置文件
bind(MQ.class).in(Singleton.class).qualifiedWith(RedisMq.class).named("redismq").to(new Provider<MQ>() {
@Override
public MQ get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import javax.inject.Provider;
import javax.inject.Singleton;

import static act.app.conf.AutoConfigPlugin.loadPluginAutoConfig;

/**
* ROCKETMQ 的消息发送与接收
* <p>
Expand Down Expand Up @@ -55,6 +57,7 @@ public RocketMqImpl init(ISerializer serializer) {
public static class Module extends org.osgl.inject.Module {
@Override
protected void configure() {
loadPluginAutoConfig(MqConfig.class, App.instance()); // 预先加载 MqConfig 配置文件
bind(MQ.class).in(Singleton.class).qualifiedWith(RocketMq.class).named("rocketmq").to(new Provider<MQ>() {
@Override
public MQ get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception {

@GetAction("/mq/redis")
public Result mqRedis() {
String host = MqConfig2.redis_host.get();
String host = MqConfig.redis_host.get();
// 接收消息,并回调执行
boolean isReceived = redismq.subscribe(MqEntity.Key.ofRedis("mq:topic") ,"show_topic_1");

Expand Down

This file was deleted.

0 comments on commit 6310cce

Please sign in to comment.