All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.wizzer.iot.mqtt.server.broker.internal.InternalCommunication Maven / Gradle / Ivy

There is a newer version: 1.2.0-netty
Show newest version
/**
 * Copyright (c) 2018, Mr.Wang ([email protected]) All rights reserved.
 */

package cn.wizzer.iot.mqtt.server.broker.internal;

import cn.wizzer.iot.mqtt.server.broker.cluster.RedisCluster;
import cn.wizzer.iot.mqtt.server.broker.config.BrokerProperties;
import cn.wizzer.iot.mqtt.server.broker.service.KafkaService;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 消息转发,基于kafka
 */
@IocBean
public class InternalCommunication {
    private static final Logger LOGGER = LoggerFactory.getLogger(InternalCommunication.class);
    @Inject
    private BrokerProperties brokerProperties;
    @Inject
    private KafkaService kafkaService;
    @Inject
    private RedisCluster redisCluster;

    public void internalSend(InternalMessage internalMessage) {
        //如果开启kafka消息转发
        if (brokerProperties.getKafkaBrokerEnabled()) {
            kafkaService.send(internalMessage);
        }
        //如果开启集群功能
        if (brokerProperties.getClusterEnabled()) {
            redisCluster.sendMessage(internalMessage);
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy