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


Java RemotingException类代码示例

本文整理汇总了Java中org.apache.rocketmq.remoting.exception.RemotingException的典型用法代码示例。如果您正苦于以下问题:Java RemotingException类的具体用法?Java RemotingException怎么用?Java RemotingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: sendMessage

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
/**
 * 发送消息【同步】
 * @param message
 * @return
 */
public String sendMessage(String message){
    DefaultMQProducer producer=new DefaultMQProducer(RocketMQConfiguration.ROCKETMQ_GROUP);
    producer.setNamesrvAddr(RocketMQConfiguration.ROCKETMQ_NAMESRV);
    producer.setVipChannelEnabled(false);
    try {
        producer.start();
        for (int i = 0; i < 100; i++) {
            SendResult sendResult = producer.send(new Message(RocketMQConfiguration.ROCKETMQ_TOPIC, message!=null?message.getBytes():null));
            System.out.println(sendResult);
        }
        return null;
    } catch (MQClientException|InterruptedException| RemotingException|MQBrokerException e) {
        e.printStackTrace();
        System.exit(1);
    }finally {
        producer.shutdown();
    }
    return null;
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:25,代码来源:RocketMQProcedure.java

示例2: sendFilterMessage

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
/**
 * 发送消息
 * @return
 */
public String sendFilterMessage(){
    DefaultMQProducer producer=new DefaultMQProducer(RocketMQConfiguration.ROCKETMQ_GROUP);
    producer.setNamesrvAddr(RocketMQConfiguration.ROCKETMQ_NAMESRV);
    producer.setVipChannelEnabled(false);
    try {
        producer.start();
        for (int i = 0; i <10 ; i++) {
            Message message1 = new Message(RocketMQConfiguration.ROCKETMQ_TOPIC,"filter",null, ("lovecws"+i).getBytes());
            message1.putUserProperty("a",String.valueOf(i));
            SendResult sendResult = producer.send(message1);
            System.out.println(sendResult);
        }
        return null;
    } catch (MQClientException |InterruptedException| RemotingException |MQBrokerException e) {
        e.printStackTrace();
        System.exit(1);
    }finally {
        producer.shutdown();
    }
    return null;
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:26,代码来源:RocketMQFilterProcedure.java

示例3: sendAsyncMessage

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
/**
 * 发送异步消息
 * @throws InterruptedException
 * @throws RemotingException
 * @throws MQClientException
 * @throws MQBrokerException
 */
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void sendAsyncMessage() throws InterruptedException, RemotingException, MQClientException, MQBrokerException {
    producer.send(new Message(RocketMQConfiguration.ROCKETMQ_TOPIC,message), new SendCallback() {
        @Override
        public void onSuccess(SendResult sendResult) {
            //System.out.println("receive message"+sendResult);
        }

        @Override
        public void onException(Throwable throwable) {
            //System.out.println("receive message error"+throwable.getLocalizedMessage());
        }
    });
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:23,代码来源:RocketMQAsyncMessage.java

示例4: getConsumerRunningInfo

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public ConsumerRunningInfo getConsumerRunningInfo(final String addr, String consumerGroup, String clientId, boolean jstack,
    final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
    GetConsumerRunningInfoRequestHeader requestHeader = new GetConsumerRunningInfoRequestHeader();
    requestHeader.setConsumerGroup(consumerGroup);
    requestHeader.setClientId(clientId);
    requestHeader.setJstackEnable(jstack);

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

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            byte[] body = response.getBody();
            if (body != null) {
                ConsumerRunningInfo info = ConsumerRunningInfo.decode(body, ConsumerRunningInfo.class);
                return info;
            }
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:27,代码来源:MQClientAPIImpl.java

示例5: reportConsumerRunningInfo

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public void reportConsumerRunningInfo(final String consumerGroup) throws InterruptedException,
    MQBrokerException, RemotingException, MQClientException {
    ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(consumerGroup);
    TreeMap<String, ConsumerRunningInfo> infoMap = new TreeMap<String, ConsumerRunningInfo>();
    for (Connection c : cc.getConnectionSet()) {
        String clientId = c.getClientId();

        if (c.getVersion() < MQVersion.Version.V3_1_8_SNAPSHOT.ordinal()) {
            continue;
        }

        try {
            ConsumerRunningInfo info =
                defaultMQAdminExt.getConsumerRunningInfo(consumerGroup, clientId, false);
            infoMap.put(clientId, info);
        } catch (Exception e) {
        }
    }

    if (!infoMap.isEmpty()) {
        this.monitorListener.reportConsumerRunningInfo(infoMap);
    }
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:24,代码来源:MonitorService.java

示例6: queryConsumerOffset

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public long queryConsumerOffset(//
    final String addr, //
    final QueryConsumerOffsetRequestHeader requestHeader, //
    final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUMER_OFFSET, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            QueryConsumerOffsetResponseHeader responseHeader =
                (QueryConsumerOffsetResponseHeader) response.decodeCommandCustomHeader(QueryConsumerOffsetResponseHeader.class);

            return responseHeader.getOffset();
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:24,代码来源:MQClientAPIImpl.java

示例7: sendMessageBack

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    try {
        String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
            : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
        this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg,
            this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000, getMaxReconsumeTimes());
    } catch (Exception e) {
        log.error("sendMessageBack Exception, " + this.defaultMQPushConsumer.getConsumerGroup(), e);

        Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());

        String originMsgId = MessageAccessor.getOriginMessageId(msg);
        MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);

        newMsg.setFlag(msg.getFlag());
        MessageAccessor.setProperties(newMsg, msg.getProperties());
        MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
        MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
        MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(getMaxReconsumeTimes()));
        newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());

        this.mQClientFactory.getDefaultMQProducer().send(newMsg);
    }
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:26,代码来源:DefaultMQPushConsumerImpl.java

示例8: lockBatchMQ

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的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(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), 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:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:22,代码来源:MQClientAPIImpl.java

示例9: getMinOffset

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public long getMinOffset(final String addr, final String topic, final int queueId, final long timeoutMillis)
    throws RemotingException, MQBrokerException, InterruptedException {
    GetMinOffsetRequestHeader requestHeader = new GetMinOffsetRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MIN_OFFSET, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            GetMinOffsetResponseHeader responseHeader =
                (GetMinOffsetResponseHeader) response.decodeCommandCustomHeader(GetMinOffsetResponseHeader.class);

            return responseHeader.getOffset();
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:24,代码来源:MQClientAPIImpl.java

示例10: deleteTopicInNameServer

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public void deleteTopicInNameServer(final String addr, final String topic, final long timeoutMillis)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    DeleteTopicRequestHeader requestHeader = new DeleteTopicRequestHeader();
    requestHeader.setTopic(topic);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_TOPIC_IN_NAMESRV, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:19,代码来源:MQClientAPIImpl.java

示例11: createSubscriptionGroup

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config, final long timeoutMillis)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);

    byte[] body = RemotingSerializable.encode(config);
    request.setBody(body);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
        request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            return;
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());

}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:22,代码来源:MQClientAPIImpl.java

示例12: testPullMessage_Success

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
@Test
public void testPullMessage_Success() throws InterruptedException, RemotingException, MQBrokerException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final MessageExt[] messageExts = new MessageExt[1];
    pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
        @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            messageExts[0] = msgs.get(0);
            countDownLatch.countDown();
            return null;
        }
    }));

    PullMessageService pullMessageService = mQClientFactory.getPullMessageService();
    pullMessageService.executePullRequestImmediately(createPullRequest());
    countDownLatch.await();
    assertThat(messageExts[0].getTopic()).isEqualTo(topic);
    assertThat(messageExts[0].getBody()).isEqualTo(new byte[] {'a'});
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:20,代码来源:DefaultMQPushConsumerTest.java

示例13: pullMessage

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public PullResult pullMessage(//
    final String addr, //
    final PullMessageRequestHeader requestHeader, //
    final long timeoutMillis, //
    final CommunicationMode communicationMode, //
    final PullCallback pullCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
	//发送PULL_MESSAGE类型的请求
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.PULL_MESSAGE, requestHeader);

    switch (communicationMode) {
        case ONEWAY:
            assert false;
            return null;
        case ASYNC:
            this.pullMessageAsync(addr, request, timeoutMillis, pullCallback);
            return null;
        case SYNC:
            return this.pullMessageSync(addr, request, timeoutMillis);
        default:
            assert false;
            break;
    }

    return null;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:27,代码来源:MQClientAPIImpl.java

示例14: fetchConsumeOffsetFromBroker

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
private long fetchConsumeOffsetFromBroker(MessageQueue mq) throws RemotingException, MQBrokerException,
    InterruptedException, MQClientException {
    FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
    if (null == findBrokerResult) {
        // TODO Here may be heavily overhead for Name Server,need tuning
        this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
        findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
    }

    if (findBrokerResult != null) {
        QueryConsumerOffsetRequestHeader requestHeader = new QueryConsumerOffsetRequestHeader();
        requestHeader.setTopic(mq.getTopic());
        requestHeader.setConsumerGroup(this.groupName);
        requestHeader.setQueueId(mq.getQueueId());

        return this.mQClientFactory.getMQClientAPIImpl().queryConsumerOffset(
            findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
    } else {
        throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:22,代码来源:RemoteBrokerOffsetStore.java

示例15: getTopicsByCluster

import org.apache.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public TopicList getTopicsByCluster(final String cluster, final long timeoutMillis)
    throws RemotingException, MQClientException, InterruptedException {
    GetTopicsByClusterRequestHeader requestHeader = new GetTopicsByClusterRequestHeader();
    requestHeader.setCluster(cluster);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPICS_BY_CLUSTER, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            byte[] body = response.getBody();
            if (body != null) {
                TopicList topicList = TopicList.decode(body, TopicList.class);
                return topicList;
            }
        }
        default:
            break;
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:23,代码来源:MQClientAPIImpl.java


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