Search in sources :

Example 6 with RPCHook

use of org.apache.rocketmq.remoting.RPCHook in project rocketmq-externals by apache.

the class HudiSinkConnector method startMQAdminTools.

private synchronized void startMQAdminTools() {
    if (!configValid || adminStarted) {
        return;
    }
    RPCHook rpcHook = null;
    this.srcMQAdminExt = new DefaultMQAdminExt(rpcHook);
    this.srcMQAdminExt.setNamesrvAddr(this.sinkConnectConfig.getSrcNamesrvs());
    this.srcMQAdminExt.setAdminExtGroup(Utils.createGroupName(HUDI_CONNECTOR_ADMIN_PREFIX));
    this.srcMQAdminExt.setInstanceName(Utils.createInstanceName(this.sinkConnectConfig.getSrcNamesrvs()));
    try {
        log.info("Trying to start srcMQAdminExt");
        this.srcMQAdminExt.start();
        log.info("RocketMQ srcMQAdminExt started");
    } catch (MQClientException e) {
        log.error("Hudi Sink Task start failed for `srcMQAdminExt` exception.", e);
    }
    adminStarted = true;
}
Also used : RPCHook(org.apache.rocketmq.remoting.RPCHook) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 7 with RPCHook

use of org.apache.rocketmq.remoting.RPCHook in project rocketmq-externals by apache.

the class JdbcSinkConnector method startMQAdminTools.

private synchronized void startMQAdminTools() {
    if (!configValid || adminStarted) {
        return;
    }
    RPCHook rpcHook = null;
    this.srcMQAdminExt = new DefaultMQAdminExt(rpcHook);
    this.srcMQAdminExt.setNamesrvAddr(((SinkDbConnectorConfig) this.dbConnectorConfig).getSrcNamesrvs());
    this.srcMQAdminExt.setAdminExtGroup(Utils.createGroupName(ConstDefine.JDBC_CONNECTOR_ADMIN_PREFIX));
    this.srcMQAdminExt.setInstanceName(Utils.createInstanceName(((SinkDbConnectorConfig) this.dbConnectorConfig).getSrcNamesrvs()));
    try {
        this.srcMQAdminExt.start();
        log.info("RocketMQ srcMQAdminExt started");
    } catch (MQClientException e) {
        log.error("Replicator start failed for `srcMQAdminExt` exception.", e);
    }
    adminStarted = true;
}
Also used : SinkDbConnectorConfig(org.apache.rocketmq.connect.jdbc.config.SinkDbConnectorConfig) RPCHook(org.apache.rocketmq.remoting.RPCHook) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 8 with RPCHook

use of org.apache.rocketmq.remoting.RPCHook in project rocketmq-externals by apache.

the class CassandraSinkConnector method startMQAdminTools.

private synchronized void startMQAdminTools() {
    if (!configValid || adminStarted) {
        return;
    }
    RPCHook rpcHook = null;
    this.srcMQAdminExt = new DefaultMQAdminExt(rpcHook);
    this.srcMQAdminExt.setNamesrvAddr(((SinkDbConnectorConfig) this.dbConnectorConfig).getSrcNamesrvs());
    this.srcMQAdminExt.setAdminExtGroup(Utils.createGroupName(ConstDefine.CASSANDRA_CONNECTOR_ADMIN_PREFIX));
    this.srcMQAdminExt.setInstanceName(Utils.createInstanceName(((SinkDbConnectorConfig) this.dbConnectorConfig).getSrcNamesrvs()));
    try {
        log.info("Trying to start srcMQAdminExt");
        this.srcMQAdminExt.start();
        log.info("RocketMQ srcMQAdminExt started");
    } catch (MQClientException e) {
        log.error("Cassandra Sink Task start failed for `srcMQAdminExt` exception.", e);
    }
    adminStarted = true;
}
Also used : RPCHook(org.apache.rocketmq.remoting.RPCHook) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 9 with RPCHook

use of org.apache.rocketmq.remoting.RPCHook in project rocketmq-externals by apache.

the class Utils method startTargetMQAdminTool.

public static DefaultMQAdminExt startTargetMQAdminTool(RmqConnectorConfig replicatorConfig) throws MQClientException {
    RPCHook rpcHook = null;
    if (replicatorConfig.isTargetAclEnable()) {
        rpcHook = new AclClientRPCHook(new SessionCredentials(replicatorConfig.getTargetAccessKey(), replicatorConfig.getTargetSecretKey()));
    }
    DefaultMQAdminExt targetMQAdminExt = new DefaultMQAdminExt(rpcHook);
    targetMQAdminExt.setNamesrvAddr(replicatorConfig.getTargetNamesrvs());
    targetMQAdminExt.setAdminExtGroup(ConstDefine.REPLICATOR_ADMIN_GROUP);
    targetMQAdminExt.setInstanceName(Utils.createUniqIntanceName(replicatorConfig.getTargetNamesrvs()));
    targetMQAdminExt.start();
    log.info("TARGET: RocketMQ targetMQAdminExt started.");
    return targetMQAdminExt;
}
Also used : SessionCredentials(org.apache.rocketmq.acl.common.SessionCredentials) RPCHook(org.apache.rocketmq.remoting.RPCHook) AclClientRPCHook(org.apache.rocketmq.acl.common.AclClientRPCHook) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) AclClientRPCHook(org.apache.rocketmq.acl.common.AclClientRPCHook)

Example 10 with RPCHook

use of org.apache.rocketmq.remoting.RPCHook in project rocketmq-externals by apache.

the class ConnectUtil method initDefaultMQPullConsumer.

public static DefaultMQPullConsumer initDefaultMQPullConsumer(ConnectConfig connectConfig) {
    RPCHook rpcHook = null;
    if (connectConfig.getAclEnable()) {
        rpcHook = new AclClientRPCHook(new SessionCredentials(connectConfig.getAccessKey(), connectConfig.getSecretKey()));
    }
    DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(rpcHook);
    consumer.setNamesrvAddr(connectConfig.getNamesrvAddr());
    consumer.setInstanceName(createUniqInstance(connectConfig.getNamesrvAddr()));
    consumer.setConsumerGroup(connectConfig.getRmqConsumerGroup());
    consumer.setMaxReconsumeTimes(connectConfig.getRmqMaxRedeliveryTimes());
    consumer.setBrokerSuspendMaxTimeMillis(connectConfig.getBrokerSuspendMaxTimeMillis());
    consumer.setConsumerPullTimeoutMillis((long) connectConfig.getRmqMessageConsumeTimeout());
    consumer.setLanguage(LanguageCode.JAVA);
    return consumer;
}
Also used : SessionCredentials(org.apache.rocketmq.acl.common.SessionCredentials) RPCHook(org.apache.rocketmq.remoting.RPCHook) AclClientRPCHook(org.apache.rocketmq.acl.common.AclClientRPCHook) AclClientRPCHook(org.apache.rocketmq.acl.common.AclClientRPCHook) DefaultMQPullConsumer(org.apache.rocketmq.client.consumer.DefaultMQPullConsumer)

Aggregations

RPCHook (org.apache.rocketmq.remoting.RPCHook)16 AclClientRPCHook (org.apache.rocketmq.acl.common.AclClientRPCHook)11 SessionCredentials (org.apache.rocketmq.acl.common.SessionCredentials)11 DefaultMQAdminExt (org.apache.rocketmq.tools.admin.DefaultMQAdminExt)7 MQClientException (org.apache.rocketmq.client.exception.MQClientException)5 DefaultMQPushConsumer (org.apache.rocketmq.client.consumer.DefaultMQPushConsumer)3 ArrayList (java.util.ArrayList)2 ExecutorService (java.util.concurrent.ExecutorService)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 DefaultMQPullConsumer (org.apache.rocketmq.client.consumer.DefaultMQPullConsumer)2 AllocateMessageQueueAveragely (org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely)2 DefaultMQProducer (org.apache.rocketmq.client.producer.DefaultMQProducer)2 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)2 JSON (com.alibaba.fastjson.JSON)1 CanalException (com.alibaba.otter.canal.common.CanalException)1 NamedThreadFactory (com.alibaba.otter.canal.common.utils.NamedThreadFactory)1 CanalConstants (com.alibaba.otter.canal.connector.core.config.CanalConstants)1 CommonMessage (com.alibaba.otter.canal.connector.core.consumer.CommonMessage)1 CanalMsgConsumer (com.alibaba.otter.canal.connector.core.spi.CanalMsgConsumer)1 SPI (com.alibaba.otter.canal.connector.core.spi.SPI)1