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

cn.hyperchain.sdk.service.impl.MQServiceImpl Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package cn.hyperchain.sdk.service.impl;

import cn.hyperchain.sdk.provider.ProviderManager;
import cn.hyperchain.sdk.request.MQRequest;
import cn.hyperchain.sdk.request.Request;
import cn.hyperchain.sdk.response.mq.MQResponse;
import cn.hyperchain.sdk.service.MQService;
import cn.hyperchain.sdk.service.params.MQParam;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MQServiceImpl implements MQService {
    private ProviderManager providerManager;
    private static final String MQ_PREFIX = "mq_";

    public MQServiceImpl(ProviderManager providerManager) {
        this.providerManager = providerManager;
    }

    @Override
    public Request registerQueue(String from, String queueName, List routingkeys, Boolean isVerbose, int... nodeIds) {
        MQRequest mqResponseMQRequest = new MQRequest(MQ_PREFIX + "register", providerManager, MQResponse.class, nodeIds);

        Map params = new HashMap<>();
        params.put("from", from);
        params.put("queueName", queueName);
        params.put("routingkeys", routingkeys);
        params.put("isVerbose", isVerbose);
        mqResponseMQRequest.addParams(params);

        return mqResponseMQRequest;

    }

    @Override
    public Request registerQueue(MQParam mqParam, int... nodeIds) {
        MQRequest mqResponseMQRequest = new MQRequest(MQ_PREFIX + "register", providerManager, MQResponse.class, nodeIds);
        mqResponseMQRequest.addParams(mqParam.getMetas());
        return mqResponseMQRequest;
    }

    @Override
    public Request unRegisterQueue(String from, String queueName, String exchangerName, int... nodeIds) {
        MQRequest mqResponseMQRequest = new MQRequest(MQ_PREFIX + "unRegister", providerManager, MQResponse.class, nodeIds);
        mqResponseMQRequest.addParams(queueName);
        mqResponseMQRequest.addParams(exchangerName);
        mqResponseMQRequest.addParams(from);
        mqResponseMQRequest.addParams("");
        return mqResponseMQRequest;
    }


    @Override
    public Request getAllQueueNames(int... nodeIds) {
        MQRequest mqResponseMQRequest = new MQRequest(MQ_PREFIX + "getAllQueueNames", providerManager, MQResponse.class, nodeIds);
        return mqResponseMQRequest;
    }


    @Override
    public Request informNormal(int... nodeIds) {
        MQRequest mqResponseMQRequest = new MQRequest(MQ_PREFIX + "informNormal", providerManager, MQResponse.class, nodeIds);
        mqResponseMQRequest.addParams("");
        return mqResponseMQRequest;
    }


    @Override
    public Request getExchangerName(int... nodeIds) {
        MQRequest mqResponseMQRequest = new MQRequest(MQ_PREFIX + "getExchangerName", providerManager, MQResponse.class, nodeIds);
        return mqResponseMQRequest;
    }


    @Override
    public Request deleteExchanger(String exchangerName, int... nodeIds) {
        MQRequest mqResponseMQRequest = new MQRequest(MQ_PREFIX + "deleteExchanger", providerManager, MQResponse.class, nodeIds);
        mqResponseMQRequest.addParams(exchangerName);
        return mqResponseMQRequest;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy