当前位置: 首页>>代码示例>>Java>>正文


Java RemotingCommand.createRequestCommand方法代码示例

本文整理汇总了Java中com.alibaba.rocketmq.remoting.protocol.RemotingCommand.createRequestCommand方法的典型用法代码示例。如果您正苦于以下问题:Java RemotingCommand.createRequestCommand方法的具体用法?Java RemotingCommand.createRequestCommand怎么用?Java RemotingCommand.createRequestCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.rocketmq.remoting.protocol.RemotingCommand的用法示例。


在下文中一共展示了RemotingCommand.createRequestCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: lockBatchMQ

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public Set<MessageQueue> lockBatchMQ(//
        final String addr,//
        final LockBatchRequestBody requestBody,//
        final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.LOCK_BATCH_MQ, null);

    request.setBody(requestBody.encode());
    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        LockBatchResponseBody responseBody = LockBatchResponseBody.decode(response.getBody(), LockBatchResponseBody.class);
        Set<MessageQueue> messageQueues = responseBody.getLockOKMQSet();
        return messageQueues;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:21,代码来源:MQClientAPIImpl.java

示例2: unlockBatchMQ

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public void unlockBatchMQ(//
        final String addr,//
        final UnlockBatchRequestBody requestBody,//
        final long timeoutMillis,//
        final boolean oneway//
) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNLOCK_BATCH_MQ, null);

    request.setBody(requestBody.encode());

    if (oneway) {
        this.remotingClient.invokeOneway(addr, request, timeoutMillis);
    }
    else {
        RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
        switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
        }

        throw new MQBrokerException(response.getCode(), response.getRemark());
    }
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:27,代码来源:MQClientAPIImpl.java

示例3: getTopicStatsInfo

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis) throws InterruptedException,
        RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
        return topicStatsTable;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:20,代码来源:MQClientAPIImpl.java

示例4: getConsumeStats

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public ConsumeStats getConsumeStats(final String addr, final String consumerGroup, final String topic, final long timeoutMillis)
        throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
        MQBrokerException {
    GetConsumeStatsRequestHeader requestHeader = new GetConsumeStatsRequestHeader();
    requestHeader.setConsumerGroup(consumerGroup);
    requestHeader.setTopic(topic);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUME_STATS, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        ConsumeStats consumeStats = ConsumeStats.decode(response.getBody(), ConsumeStats.class);
        return consumeStats;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:22,代码来源:MQClientAPIImpl.java

示例5: examineTopicConfig

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
@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()));
    }
}
 
开发者ID:didapinchegit,项目名称:rocket-console,代码行数:20,代码来源:MQAdminExtImpl.java

示例6: getConsumerConnectionList

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public ConsumerConnection getConsumerConnectionList(final String addr, final String consumerGroup, final long timeoutMillis)
        throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
        MQBrokerException {
    GetConsumerConnectionListRequestHeader requestHeader = new GetConsumerConnectionListRequestHeader();
    requestHeader.setConsumerGroup(consumerGroup);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_CONNECTION_LIST, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        ConsumerConnection consumerConnection = ConsumerConnection.decode(response.getBody(), ConsumerConnection.class);
        return consumerConnection;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:21,代码来源:MQClientAPIImpl.java

示例7: getBrokerRuntimeInfo

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public KVTable getBrokerRuntimeInfo(final String addr, final long timeoutMillis) throws RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        return KVTable.decode(response.getBody(), KVTable.class);
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:17,代码来源:MQClientAPIImpl.java

示例8: updateBrokerConfig

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public void updateBrokerConfig(final String addr, final Properties properties, final long timeoutMillis)
        throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
        MQBrokerException, UnsupportedEncodingException {

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_BROKER_CONFIG, null);

    String str = MixAll.properties2String(properties);
    if (str != null && str.length() > 0) {
        request.setBody(str.getBytes(MixAll.DEFAULT_CHARSET));
        RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
        switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
        }

        throw new MQBrokerException(response.getCode(), response.getRemark());
    }
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:22,代码来源:MQClientAPIImpl.java

示例9: test_RPC_Oneway

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
@Test
public void test_RPC_Oneway() throws InterruptedException, RemotingConnectException,
        RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
    RemotingServer server = createRemotingServer();
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 100; i++) {
        RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
        request.setRemark(String.valueOf(i));
        client.invokeOneway("localhost:8888", request, 1000 * 3);
    }

    client.shutdown();
    server.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:17,代码来源:NettyRPCTest.java

示例10: queryConsumeTimeSpan

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public List<QueueTimeSpan> queryConsumeTimeSpan(final String addr, final String topic, final String group, final long timeoutMillis)
        throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
        MQBrokerException {
    QueryConsumeTimeSpanRequestHeader requestHeader = new QueryConsumeTimeSpanRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setGroup(group);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_TIME_SPAN, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        QueryConsumeTimeSpanBody consumeTimeSpanBody = GroupList.decode(response.getBody(), QueryConsumeTimeSpanBody.class);
        return consumeTimeSpanBody.getConsumeTimeSpanSet();
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:22,代码来源:MQClientAPIImpl.java

示例11: test_RPC_Sync

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
@Test
public void test_RPC_Sync() throws InterruptedException, RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException {
    RemotingServer server = createRemotingServer();
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 100; i++) {
        TestRequestHeader requestHeader = new TestRequestHeader();
        requestHeader.setCount(i);
        requestHeader.setMessageTitle("HelloMessageTitle");
        RemotingCommand request = RemotingCommand.createRequestCommand(0, requestHeader);
        RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3000);
        System.out.println("invoke result = " + response);
        assertTrue(response != null);
    }

    client.shutdown();
    server.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:21,代码来源:NettyRPCTest.java

示例12: test_RPC_Async

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
@Test
public void test_RPC_Async() throws InterruptedException, RemotingConnectException,
        RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
    RemotingServer server = createRemotingServer();
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 100; i++) {
        RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
        request.setRemark(String.valueOf(i));
        client.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
            @Override
            public void operationComplete(ResponseFuture responseFuture) {
                System.out.println(responseFuture.getResponseCommand());
            }
        });
    }

    Thread.sleep(1000 * 3);

    client.shutdown();
    server.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:24,代码来源:NettyRPCTest.java

示例13: test_idle_event

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
public void test_idle_event() throws InterruptedException, RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException {
    RemotingServer server = createRemotingServer();
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 10; i++) {
        RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
        RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
        System.out.println(i + " invoke result = " + response);
        assertTrue(response != null);

        Thread.sleep(1000 * 10);
    }

    Thread.sleep(1000 * 60);

    client.shutdown();
    server.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:21,代码来源:NettyIdleTest.java

示例14: test_connect_timeout

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
@Test
public void test_connect_timeout() throws InterruptedException, RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException {
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 100; i++) {
        try {
            RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
            RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

    client.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:19,代码来源:NettyConnectionTest.java

示例15: test_RPC_Sync

import com.alibaba.rocketmq.remoting.protocol.RemotingCommand; //导入方法依赖的package包/类
@Test
public void test_RPC_Sync() throws Exception {
    RemotingServer server = NettyRPCTest.createRemotingServer();
    RemotingClient client = NettyRPCTest.createRemotingClient();

    for (int i = 0; i < 100; i++) {
        try {
            RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
            RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
            System.out.println(i + "\t" + "invoke result = " + response);
            assertTrue(response != null);
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    client.shutdown();
    server.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:23,代码来源:SyncInvokeTest.java


注:本文中的com.alibaba.rocketmq.remoting.protocol.RemotingCommand.createRequestCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。