本文整理汇总了Java中com.alibaba.rocketmq.client.impl.CommunicationMode类的典型用法代码示例。如果您正苦于以下问题:Java CommunicationMode类的具体用法?Java CommunicationMode怎么用?Java CommunicationMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommunicationMode类属于com.alibaba.rocketmq.client.impl包,在下文中一共展示了CommunicationMode类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: send
点赞 3
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的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);
}
}
开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:17,
代码来源:DefaultMQProducerImpl.java
示例2: sendSelectImpl
点赞 3
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的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);
}
开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:31,
代码来源:DefaultMQProducerImpl.java
示例3: send
点赞 3
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的package包/类
/**
* KERNEL ASYNC -------------------------------------------------------
*/
public void send(Message msg, MessageQueue mq, SendCallback sendCallback) 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);
}
catch (MQBrokerException e) {
throw new MQClientException("unknow exception", e);
}
}
开发者ID:diwayou,
项目名称:rocketmq-all-trans,
代码行数:21,
代码来源:DefaultMQProducerImpl.java
示例4: sendOneway
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的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);
}
}
开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:13,
代码来源:DefaultMQProducerImpl.java
示例5: send
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的package包/类
public void send(Message msg, SendCallback sendCallback, long timeout) throws MQClientException,
RemotingException, InterruptedException {
try {
this.sendDefaultImpl(msg, CommunicationMode.ASYNC, sendCallback, timeout);
} catch (MQBrokerException e) {
throw new MQClientException("unknown exception", e);
}
}
开发者ID:medusar,
项目名称:rocketmq-commet,
代码行数:9,
代码来源:DefaultMQProducerImpl.java
示例6: sendOneway
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的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);
}
}
开发者ID:medusar,
项目名称:rocketmq-commet,
代码行数:12,
代码来源:DefaultMQProducerImpl.java
示例7: sendSelectImpl
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的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);
}
开发者ID:medusar,
项目名称:rocketmq-commet,
代码行数:29,
代码来源:DefaultMQProducerImpl.java
示例8: sendOneway
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的package包/类
/**
* DEFAULT ONEWAY -------------------------------------------------------
*/
public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
try {
this.sendDefaultImpl(msg, CommunicationMode.ONEWAY, null);
}
catch (MQBrokerException e) {
throw new MQClientException("unknow exception", e);
}
}
开发者ID:diwayou,
项目名称:rocketmq-all-trans,
代码行数:12,
代码来源:DefaultMQProducerImpl.java
示例9: sendSelectImpl
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的package包/类
private SendResult sendSelectImpl(//
Message msg,//
MessageQueueSelector selector,//
Object arg,//
final CommunicationMode communicationMode,//
final SendCallback sendCallback//
) 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);
}
else {
throw new MQClientException("select message queue return null.", null);
}
}
throw new MQClientException("No route info for this topic, " + msg.getTopic(), null);
}
开发者ID:diwayou,
项目名称:rocketmq-all-trans,
代码行数:32,
代码来源:DefaultMQProducerImpl.java
示例10: getCommunicationMode
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的package包/类
public CommunicationMode getCommunicationMode() {
return communicationMode;
}
开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:4,
代码来源:CheckForbiddenContext.java
示例11: setCommunicationMode
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的package包/类
public void setCommunicationMode(CommunicationMode communicationMode) {
this.communicationMode = communicationMode;
}
开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:4,
代码来源:CheckForbiddenContext.java
示例12: pullSyncImpl
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的package包/类
private PullResult pullSyncImpl(MessageQueue mq, String subExpression, long offset, int maxNums,
boolean block, long timeout) throws MQClientException, RemotingException, MQBrokerException,
InterruptedException {
this.makeSureStateOK();
if (null == mq) {
throw new MQClientException("mq is null", null);
}
if (offset < 0) {
throw new MQClientException("offset < 0", null);
}
if (maxNums <= 0) {
throw new MQClientException("maxNums <= 0", null);
}
this.subscriptionAutomatically(mq.getTopic());
int sysFlag = PullSysFlag.buildSysFlag(false, block, true, false);
SubscriptionData subscriptionData;
try {
subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(),//
mq.getTopic(), subExpression);
} catch (Exception e) {
throw new MQClientException("parse subscription error", e);
}
long timeoutMillis =
block ? this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout;
PullResult pullResult = this.pullAPIWrapper.pullKernelImpl(//
mq, // 1
subscriptionData.getSubString(), // 2
0L, // 3
offset, // 4
maxNums, // 5
sysFlag, // 6
0, // 7
this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8
timeoutMillis, // 9
CommunicationMode.SYNC, // 10
null// 11
);
return this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData);
}
开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:50,
代码来源:DefaultMQPullConsumerImpl.java
示例13: pullKernelImpl
点赞 2
import com.alibaba.rocketmq.client.impl.CommunicationMode; //导入依赖的package包/类
public PullResult pullKernelImpl(//
final MessageQueue mq,// 1
final String subExpression,// 2
final long subVersion,// 3
final long offset,// 4
final int maxNums,// 5
final int sysFlag,// 6
final long commitOffset,// 7
final long brokerSuspendMaxTimeMillis,// 8
final long timeoutMillis,// 9
final CommunicationMode communicationMode,// 10
final PullCallback pullCallback// 11
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
FindBrokerResult findBrokerResult =
this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
this.recalculatePullFromWhichNode(mq), false);
if (null == findBrokerResult) {
//PullAPIWrapper.pullKernelImpl中调用updateTopicRouteInfoFromNameServer进行TopicRoute信息更新,最终保存在MQClientInstance.topicRouteTable
this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
findBrokerResult =
this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
this.recalculatePullFromWhichNode(mq), false);
}
if (findBrokerResult != null) {
int sysFlagInner = sysFlag;
if (findBrokerResult.isSlave()) { //拉取broker选择了slave, 清理掉提交消费位点的系统标识位。
sysFlagInner = PullSysFlag.clearCommitOffsetFlag(sysFlagInner);
}
PullMessageRequestHeader requestHeader = new PullMessageRequestHeader();
requestHeader.setConsumerGroup(this.consumerGroup);
requestHeader.setTopic(mq.getTopic());
requestHeader.setQueueId(mq.getQueueId());
requestHeader.setQueueOffset(offset);
requestHeader.setMaxMsgNums(maxNums);
requestHeader.setSysFlag(sysFlagInner);
requestHeader.setCommitOffset(commitOffset);
requestHeader.setSuspendTimeoutMillis(brokerSuspendMaxTimeMillis);
requestHeader.setSubscription(subExpression);
requestHeader.setSubVersion(subVersion);
String brokerAddr = findBrokerResult.getBrokerAddr();
if (PullSysFlag.hasClassFilterFlag(sysFlagInner)) {
brokerAddr = computPullFromWhichFilterServer(mq.getTopic(), brokerAddr);
}
//开始从broker对应的brokerAddr拉取消息
PullResult pullResult = this.mQClientFactory.getMQClientAPIImpl().pullMessage(//
brokerAddr,//
requestHeader,//
timeoutMillis,//
communicationMode,//同步从broker拉取消息还是异步拉取消息
pullCallback);
return pullResult;
}
throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
}
开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:62,
代码来源:PullAPIWrapper.java