本文整理汇总了Java中com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer.pull方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMQPullConsumer.pull方法的具体用法?Java DefaultMQPullConsumer.pull怎么用?Java DefaultMQPullConsumer.pull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer
的用法示例。
在下文中一共展示了DefaultMQPullConsumer.pull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer; //导入方法依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer(MixAll.TOOLS_CONSUMER_GROUP);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
defaultMQPullConsumer.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
//解析 sh mqadmin queryMsgByOffset 命令携带的各种参数信息
String topic = commandLine.getOptionValue('t').trim();
String brokerName = commandLine.getOptionValue('b').trim();
String queueId = commandLine.getOptionValue('i').trim();
String offset = commandLine.getOptionValue('o').trim();
MessageQueue mq = new MessageQueue();
mq.setTopic(topic);
mq.setBrokerName(brokerName);
mq.setQueueId(Integer.parseInt(queueId));
defaultMQPullConsumer.start();
defaultMQAdminExt.start();
PullResult pullResult = defaultMQPullConsumer.pull(mq, "*", Long.parseLong(offset), 1);
if (pullResult != null) {
switch (pullResult.getPullStatus()) {
case FOUND:
QueryMsgByIdSubCommand.queryById(defaultMQAdminExt, pullResult.getMsgFoundList().get(0)
.getMsgId());
break;
case NO_MATCHED_MSG:
case NO_NEW_MSG:
case OFFSET_ILLEGAL:
default:
break;
}
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQPullConsumer.shutdown();
defaultMQAdminExt.shutdown();
}
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:47,代码来源:QueryMsgByOffsetSubCommand.java
示例2: execute
import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer; //导入方法依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer(MixAll.TOOLS_CONSUMER_GROUP);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
defaultMQPullConsumer.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
String topic = commandLine.getOptionValue('t').trim();
String brokerName = commandLine.getOptionValue('b').trim();
String queueId = commandLine.getOptionValue('i').trim();
String offset = commandLine.getOptionValue('o').trim();
MessageQueue mq = new MessageQueue();
mq.setTopic(topic);
mq.setBrokerName(brokerName);
mq.setQueueId(Integer.parseInt(queueId));
defaultMQPullConsumer.start();
defaultMQAdminExt.start();
PullResult pullResult = defaultMQPullConsumer.pull(mq, "*", Long.parseLong(offset), 1);
if (pullResult != null) {
switch (pullResult.getPullStatus()) {
case FOUND:
QueryMsgByIdSubCommand.queryById(defaultMQAdminExt, pullResult.getMsgFoundList().get(0)
.getMsgId());
break;
case NO_MATCHED_MSG:
case NO_NEW_MSG:
case OFFSET_ILLEGAL:
default:
break;
}
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQPullConsumer.shutdown();
defaultMQAdminExt.shutdown();
}
}
示例3: queryMsgByOffset
import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer; //导入方法依赖的package包/类
@CmdTrace(cmdClazz = QueryMsgByOffsetSubCommand.class)
public Table queryMsgByOffset(String topicName, String brokerName, String queueId, String offset)
throws Throwable {
Throwable t = null;
DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer(MixAll.TOOLS_CONSUMER_GROUP);
defaultMQPullConsumer.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
MessageQueue mq = new MessageQueue();
mq.setTopic(topicName);
mq.setBrokerName(brokerName);
mq.setQueueId(Integer.parseInt(queueId));
defaultMQPullConsumer.start();
PullResult pullResult = defaultMQPullConsumer.pull(mq, "*", Long.parseLong(offset), 1);
if (pullResult != null) {
switch (pullResult.getPullStatus()) {
case FOUND:
Table table = queryMsgById(pullResult.getMsgFoundList().get(0).getMsgId());
return table;
case NO_MATCHED_MSG:
case NO_NEW_MSG:
case OFFSET_ILLEGAL:
default:
break;
}
}
else {
throw new IllegalStateException("pullResult is null");
}
}
catch (Throwable e) {
logger.error(e.getMessage(), e);
t = e;
}
finally {
defaultMQPullConsumer.shutdown();
}
throw t;
}
示例4: execute
import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer; //导入方法依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt();
DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer(MixAll.TOOLS_CONSUMER_GROUP);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
defaultMQPullConsumer.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
String topic = commandLine.getOptionValue('t').trim();
String brokerName = commandLine.getOptionValue('b').trim();
String queueId = commandLine.getOptionValue('i').trim();
String offset = commandLine.getOptionValue('o').trim();
MessageQueue mq = new MessageQueue();
mq.setTopic(topic);
mq.setBrokerName(brokerName);
mq.setQueueId(Integer.parseInt(queueId));
defaultMQPullConsumer.start();
PullResult pullResult = defaultMQPullConsumer.pull(mq, "*", Long.parseLong(offset), 1);
if (pullResult != null) {
switch (pullResult.getPullStatus()) {
case FOUND:
QueryMsgByIdSubCommand.queryById(defaultMQAdminExt, pullResult.getMsgFoundList().get(0)
.getMsgId());
break;
case NO_MATCHED_MSG:
case NO_NEW_MSG:
case OFFSET_ILLEGAL:
default:
break;
}
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQPullConsumer.shutdown();
defaultMQAdminExt.shutdown();
}
}