本文整理汇总了Java中com.alibaba.rocketmq.remoting.exception.RemotingException类的典型用法代码示例。如果您正苦于以下问题:Java RemotingException类的具体用法?Java RemotingException怎么用?Java RemotingException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RemotingException类属于com.alibaba.rocketmq.remoting.exception包,在下文中一共展示了RemotingException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
throws MQClientException, RemotingException, InterruptedException {
this.makeSureStateOK();
Validators.checkMessage(msg, this.defaultMQProducer);
if (!msg.getTopic().equals(mq.getTopic())) {
throw new MQClientException("message's topic not equal mq's topic", null);
}
try {
this.sendKernelImpl(msg, mq, CommunicationMode.ASYNC, sendCallback, timeout);
}
catch (MQBrokerException e) {
throw new MQClientException("unknow exception", e);
}
}
示例2: updateConsumeOffsetToBroker
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
/**
* Update the Consumer Offset, once the Master is off, updated to Slave,
* here need to be optimized.
*/
private void updateConsumeOffsetToBroker(MessageQueue mq, long offset) 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) {
UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
requestHeader.setTopic(mq.getTopic());
requestHeader.setConsumerGroup(this.groupName);
requestHeader.setQueueId(mq.getQueueId());
requestHeader.setCommitOffset(offset);
this.mQClientFactory.getMQClientAPIImpl().updateConsumerOffsetOneway(
findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
} else {
throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
}
}
示例3: sendSelectImpl
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
private SendResult sendSelectImpl(//
Message msg,//
MessageQueueSelector selector,//
Object arg,//
final CommunicationMode communicationMode,//
final SendCallback sendCallback, final long timeout//
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
this.makeSureStateOK();
Validators.checkMessage(msg, this.defaultMQProducer);
TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
if (topicPublishInfo != null && topicPublishInfo.ok()) {
MessageQueue mq = null;
try {
mq = selector.select(topicPublishInfo.getMessageQueueList(), msg, arg);
}
catch (Throwable e) {
throw new MQClientException("select message queue throwed exception.", e);
}
if (mq != null) {
return this.sendKernelImpl(msg, mq, communicationMode, sendCallback, timeout);
}
else {
throw new MQClientException("select message queue return null.", null);
}
}
throw new MQClientException("No route info for this topic, " + msg.getTopic(), null);
}
示例4: findTopicBelongToWhichCluster
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo,
final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException,
InterruptedException {
TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);
BrokerData brokerData = topicRouteData.getBrokerDatas().get(0);
String brokerName = brokerData.getBrokerName();
Iterator<Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator();
while (it.hasNext()) {
Entry<String, Set<String>> next = it.next();
if (next.getValue().contains(brokerName)) {
return next.getKey();
}
}
return null;
}
示例5: reportConsumerRunningInfo
import com.alibaba.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);
}
}
示例6: send
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public SendResult send(String topic, String tags, String keys, byte[] body) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
Message msg = new Message(topic, tags, keys, body);
log.info("rocketMQ sending msg=" + msg.toString());
SendResult sendResult = producer.send(msg);
log.info("rocketMQ sending result, key=" + keys + ",result=" + sendResult.toString());
return sendResult;
}
示例7: sendOneway
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
/**
* DEFAULT ONEWAY -------------------------------------------------------
*/
public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
try {
this.sendDefaultImpl(msg, CommunicationMode.ONEWAY, null,
this.defaultMQProducer.getSendMsgTimeout());
}
catch (MQBrokerException e) {
throw new MQClientException("unknow exception", e);
}
}
示例8: sendMessageBack
import com.alibaba.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());
//结合结合SendMessageProcessor.consumerSendMsgBack阅读
//消费失败,重新打回消息到broker中 这里发送的报文的code:CONSUMER_SEND_MSG_BACK,对端收到后,会创建重试队列RETRY_GROUP_TOPIC_PREFIX + consumer
this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg,
this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000);
}
catch (Exception e) { //消费失败的消息打回重试队列失败,,需要重新发送到重试队列
log.error("sendMessageBack Exception, " + this.defaultMQPushConsumer.getConsumerGroup(), e);
//这里发送的报文code默认为code:SEND_MESSAGE,因此需要带上重试队列名,对于broker来说就相当于收到了一条发往RETRY_GROUP_TOPIC_PREFIX + consumer的消息
Message newMsg =
//修改topic,修改后的topic为 RETRY_GROUP_TOPIC_PREFIX + consumer 需要重新发送
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());
int reTimes = msg.getReconsumeTimes() + 1;
MessageAccessor.setReconsumeTime(newMsg, reTimes + "");
newMsg.setDelayTimeLevel(3 + reTimes);
this.mQClientFactory.getDefaultMQProducer().send(newMsg);
}
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:36,代码来源:DefaultMQPushConsumerImpl.java
示例9: sendMessageBack
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName, String consumerGroup)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
String brokerAddr =
(null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
: RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
if (UtilAll.isBlank(consumerGroup)) {
consumerGroup = this.defaultMQPullConsumer.getConsumerGroup();
}
this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg, consumerGroup,
delayLevel, 3000);
} catch (Exception e) {
log.error("sendMessageBack Exception, " + this.defaultMQPullConsumer.getConsumerGroup(), e);
Message newMsg =
new Message(MixAll.getRetryTopic(this.defaultMQPullConsumer.getConsumerGroup()),
msg.getBody());
newMsg.setFlag(msg.getFlag());
MessageAccessor.setProperties(newMsg, msg.getProperties());
MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
this.mQClientFactory.getDefaultMQProducer().send(newMsg);
}
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:28,代码来源:DefaultMQPullConsumerImpl.java
示例10: viewMessage
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
MessageId messageId = null;
try {
messageId = MessageDecoder.decodeMessageId(msgId);
}
catch (Exception e) {
throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
}
return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
messageId.getOffset(), timeoutMillis);
}
示例11: send
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
SendResult send(String var1, String var2, String var3, byte[] var4)
throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
示例12: send
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
SendResult send(final Message msg) throws MQClientException, RemotingException, MQBrokerException,
InterruptedException;
示例13: createAndUpdateTopicConfig
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
@Override
public void createAndUpdateTopicConfig(String addr, TopicConfig config)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
MQAdminInstance.threadLocalMQAdminExt().createAndUpdateTopicConfig(addr, config);
}
示例14: sendOneway
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
void sendOneway(final Message msg) throws MQClientException, RemotingException,
InterruptedException;
示例15: examineConsumeStats
import com.alibaba.rocketmq.remoting.exception.RemotingException; //导入依赖的package包/类
@Override
public ConsumeStats examineConsumeStats(String consumerGroup, String topic)
throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
return MQAdminInstance.threadLocalMQAdminExt().examineConsumeStats(consumerGroup, topic);
}