Search in sources :

Example 1 with RemotingClient

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

the class MQAdminExtImpl method examineTopicConfig.

@Override
public TopicConfig examineTopicConfig(String addr, String topic) {
    RemotingClient remotingClient = MQAdminInstance.threadLocalRemotingClient();
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null);
    RemotingCommand response = null;
    try {
        response = remotingClient.invokeSync(addr, request, 3000);
    } catch (Exception err) {
        throw Throwables.propagate(err);
    }
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                TopicConfigSerializeWrapper topicConfigSerializeWrapper = decode(response.getBody(), TopicConfigSerializeWrapper.class);
                return topicConfigSerializeWrapper.getTopicConfigTable().get(topic);
            }
        default:
            throw Throwables.propagate(new MQBrokerException(response.getCode(), response.getRemark()));
    }
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) RemotingClient(org.apache.rocketmq.remoting.RemotingClient) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) TopicConfigSerializeWrapper(org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper) MQClientException(org.apache.rocketmq.client.exception.MQClientException) RemotingConnectException(org.apache.rocketmq.remoting.exception.RemotingConnectException) RemotingSendRequestException(org.apache.rocketmq.remoting.exception.RemotingSendRequestException) RemotingTimeoutException(org.apache.rocketmq.remoting.exception.RemotingTimeoutException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RemotingException(org.apache.rocketmq.remoting.exception.RemotingException) RemotingCommandException(org.apache.rocketmq.remoting.exception.RemotingCommandException) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException)

Example 2 with RemotingClient

use of org.apache.rocketmq.remoting.RemotingClient in project pinpoint by naver.

the class DefaultMQPushConsumerImplStartInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    DefaultMQPushConsumerImpl consumerImpl = (DefaultMQPushConsumerImpl) target;
    MessageListener messageListener = consumerImpl.getDefaultMQPushConsumer().getMessageListener();
    MQClientInstanceGetter mqClientInstanceGetter = (MQClientInstanceGetter) target;
    MQClientInstance mqClientInstance = mqClientInstanceGetter._$PINPOINT$_getMQClientInstance();
    RemotingClient remotingClient = mqClientInstance.getMQClientAPIImpl().getRemotingClient();
    if (remotingClient instanceof NettyRemotingClient) {
        ChannelTablesGetter nettyRemotingClient = (ChannelTablesGetter) remotingClient;
        ChannelTablesAccessor channelTablesAccessor = (ChannelTablesAccessor) messageListener;
        channelTablesAccessor._$PINPOINT$_setChannelTables(nettyRemotingClient._$PINPOINT$_getChannelTables());
    }
}
Also used : DefaultMQPushConsumerImpl(org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl) NettyRemotingClient(org.apache.rocketmq.remoting.netty.NettyRemotingClient) RemotingClient(org.apache.rocketmq.remoting.RemotingClient) MQClientInstanceGetter(com.navercorp.pinpoint.plugin.rocketmq.field.accessor.MQClientInstanceGetter) ChannelTablesAccessor(com.navercorp.pinpoint.plugin.rocketmq.field.accessor.ChannelTablesAccessor) ChannelTablesGetter(com.navercorp.pinpoint.plugin.rocketmq.field.accessor.ChannelTablesGetter) MessageListener(org.apache.rocketmq.client.consumer.listener.MessageListener) NettyRemotingClient(org.apache.rocketmq.remoting.netty.NettyRemotingClient) MQClientInstance(org.apache.rocketmq.client.impl.factory.MQClientInstance)

Example 3 with RemotingClient

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

the class MQAdminExtImpl method examineSubscriptionGroupConfig.

@Override
public SubscriptionGroupConfig examineSubscriptionGroupConfig(String addr, String group) {
    RemotingClient remotingClient = MQAdminInstance.threadLocalRemotingClient();
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG, null);
    RemotingCommand response = null;
    try {
        response = remotingClient.invokeSync(addr, request, 3000);
    } catch (Exception err) {
        throw Throwables.propagate(err);
    }
    assert response != null;
    switch(response.getCode()) {
        case ResponseCode.SUCCESS:
            {
                SubscriptionGroupWrapper subscriptionGroupWrapper = decode(response.getBody(), SubscriptionGroupWrapper.class);
                return subscriptionGroupWrapper.getSubscriptionGroupTable().get(group);
            }
        default:
            throw Throwables.propagate(new MQBrokerException(response.getCode(), response.getRemark()));
    }
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) RemotingClient(org.apache.rocketmq.remoting.RemotingClient) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) MQClientException(org.apache.rocketmq.client.exception.MQClientException) RemotingConnectException(org.apache.rocketmq.remoting.exception.RemotingConnectException) RemotingSendRequestException(org.apache.rocketmq.remoting.exception.RemotingSendRequestException) RemotingTimeoutException(org.apache.rocketmq.remoting.exception.RemotingTimeoutException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RemotingException(org.apache.rocketmq.remoting.exception.RemotingException) RemotingCommandException(org.apache.rocketmq.remoting.exception.RemotingCommandException) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException) SubscriptionGroupWrapper(org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper)

Aggregations

RemotingClient (org.apache.rocketmq.remoting.RemotingClient)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2 RemotingCommandException (org.apache.rocketmq.remoting.exception.RemotingCommandException)2 RemotingConnectException (org.apache.rocketmq.remoting.exception.RemotingConnectException)2 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)2 RemotingSendRequestException (org.apache.rocketmq.remoting.exception.RemotingSendRequestException)2 RemotingTimeoutException (org.apache.rocketmq.remoting.exception.RemotingTimeoutException)2 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)2 ChannelTablesAccessor (com.navercorp.pinpoint.plugin.rocketmq.field.accessor.ChannelTablesAccessor)1 ChannelTablesGetter (com.navercorp.pinpoint.plugin.rocketmq.field.accessor.ChannelTablesGetter)1 MQClientInstanceGetter (com.navercorp.pinpoint.plugin.rocketmq.field.accessor.MQClientInstanceGetter)1 MessageListener (org.apache.rocketmq.client.consumer.listener.MessageListener)1 DefaultMQPushConsumerImpl (org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl)1 MQClientInstance (org.apache.rocketmq.client.impl.factory.MQClientInstance)1 SubscriptionGroupWrapper (org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper)1 TopicConfigSerializeWrapper (org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper)1 NettyRemotingClient (org.apache.rocketmq.remoting.netty.NettyRemotingClient)1