本文整理汇总了Java中com.alibaba.rocketmq.client.consumer.listener.MessageListener类的典型用法代码示例。如果您正苦于以下问题:Java MessageListener类的具体用法?Java MessageListener怎么用?Java MessageListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageListener类属于com.alibaba.rocketmq.client.consumer.listener包,在下文中一共展示了MessageListener类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: pushConsumerFromLastOffset
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
@Test
public void pushConsumerFromLastOffset() throws MQClientException {
consumer.setMessageModel(MessageModel.CLUSTERING);
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
MessageListener listener = createMessageListener();
consumer.registerMessageListener(listener);
consumer.start();
System.out.println("Consumer Started.");
try {
System.in.read();
}
catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:17,代码来源:PushConsumerTest.java
示例2: pushConsumerFromMinOffset
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
@Test
public void pushConsumerFromMinOffset() throws MQClientException {
consumer.setMessageModel(MessageModel.CLUSTERING);
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
MessageListener listener = createMessageListener();
consumer.registerMessageListener(listener);
consumer.start();
System.out.println("Consumer Started.");
try {
System.in.read();
}
catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:17,代码来源:PushConsumerTest.java
示例3: createMessageListener
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
private MessageListener createMessageListener() {
return new MessageListenerConcurrently() {
AtomicLong consumeTimes = new AtomicLong(0);
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) {
this.consumeTimes.incrementAndGet();
if ((this.consumeTimes.get() % 11) == 0) {
System.out.println("Delay 0========Receive New Messages: " + msgs);
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
else if ((this.consumeTimes.get() % 22) == 0) {
System.out.println(Thread.currentThread().getName()
+ "Delay 5========Receive New Messages: " + msgs);
context.setDelayLevelWhenNextConsume(5);
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
System.out.println("No Delay========Receive New Messages: " + msgs);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
};
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:26,代码来源:PushConsumerTest.java
示例4: pushConsumerFromLastOffset
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
@Test
public void pushConsumerFromLastOffset() throws MQClientException {
consumer.setMessageModel(MessageModel.CLUSTERING);
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
MessageListener listener = getRollBackMessageListener();
consumer.registerMessageListener(listener);
consumer.start();
System.out.println("Consumer Started.");
try {
System.in.read();
}
catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:17,代码来源:PushConsumerTest.java
示例5: pushConsumerWithAutoCommitFromLastOffset
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
@Test
public void pushConsumerWithAutoCommitFromLastOffset() throws MQClientException {
consumer.setMessageModel(MessageModel.CLUSTERING);
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
MessageListener listener = getAutoCommitMessageListener();
consumer.registerMessageListener(listener);
consumer.start();
System.out.println("Consumer Started.");
try {
System.in.read();
}
catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:17,代码来源:PushConsumerTest.java
示例6: pushConsumerWithAutoCommitFromMinOffset
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
@Test
public void pushConsumerWithAutoCommitFromMinOffset() throws MQClientException {
consumer.setMessageModel(MessageModel.CLUSTERING);
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
MessageListener listener = getAutoCommitMessageListener();
consumer.registerMessageListener(listener);
consumer.start();
System.out.println("Consumer Started.");
try {
System.in.read();
}
catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:17,代码来源:PushConsumerTest.java
示例7: createConsumer
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
private static MQPushConsumer createConsumer(String nsAddr, String... topics) throws MQClientException {
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(consumerGroup);
consumer.setInstanceName("unit_consumer_" + System.nanoTime());
consumer.setNamesrvAddr(nsAddr);
for (String topic : topics) {
consumer.subscribe(topic, "*");
}
consumer.setMessageModel(MessageModel.CLUSTERING);
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
MessageListener listener = createMessageListener();
consumer.registerMessageListener(listener);
consumer.setConsumeThreadMax(1);
consumer.setConsumeThreadMin(1);
consumer.start();
return consumer;
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:19,代码来源:UnitOrderTest.java
示例8: pushConsumerByBroadCast
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
@Test
public void pushConsumerByBroadCast() throws MQClientException {
consumer.setMessageModel(MessageModel.BROADCASTING);
MessageListener listener = createMessageListener();
consumer.registerMessageListener(listener);
consumer.start();
System.out.println("Consumer Started.");
try {
System.in.read();
}
catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:16,代码来源:PushConsumerTest.java
示例9: createMessageListener
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
private static MessageListener createMessageListener() {
return new MessageListenerOrderly() {
@Override
public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
for (MessageExt msg : msgs) {
System.err.println("topic:" + msg.getTopic() + ", msgId:" + msg.getMsgId() + ", body:"
+ new String(msg.getBody()));
}
return ConsumeOrderlyStatus.SUCCESS;
}
};
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:14,代码来源:UnitOrderTest.java
示例10: createConsumer
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
private static void createConsumer(String nsAddr, String... topics) throws MQClientException {
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(consumerGroup);
consumer.setInstanceName("unit_consumer_" + System.nanoTime());
consumer.setNamesrvAddr(nsAddr);
for (String topic : topics) {
consumer.subscribe(topic, "*");
}
consumer.setMessageModel(MessageModel.CLUSTERING);
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
MessageListener listener = createMessageListener();
consumer.registerMessageListener(listener);
consumer.start();
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:16,代码来源:UnitNormalTest.java
示例11: createMessageListener
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
private static MessageListener createMessageListener() {
return new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) {
for (MessageExt msg : msgs) {
System.err.println("topic:" + msg.getTopic() + ", msgId:" + msg.getMsgId() + ", body:"
+ new String(msg.getBody()));
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
};
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:14,代码来源:UnitNormalTest.java
示例12: getMessageListener
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
public MessageListener getMessageListener() {
return messageListener;
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:4,代码来源:DefaultMQPushConsumer.java
示例13: setMessageListener
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
public void setMessageListener(MessageListener messageListener) {
this.messageListener = messageListener;
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:4,代码来源:DefaultMQPushConsumer.java
示例14: registerMessageListener
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
@Override
@Deprecated
public void registerMessageListener(MessageListener messageListener) {
this.messageListener = messageListener;
this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:7,代码来源:DefaultMQPushConsumer.java
示例15: registerMessageListener
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
public void registerMessageListener(MessageListener messageListener) {
this.messageListenerInner = messageListener;
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:4,代码来源:DefaultMQPushConsumerImpl.java
示例16: getMessageListenerInner
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
public MessageListener getMessageListenerInner() {
return messageListenerInner;
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:4,代码来源:DefaultMQPushConsumerImpl.java
示例17: registerMessageListener
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
@Override
public void registerMessageListener(MessageListener messageListener) {
this.messageListener = messageListener;
this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
}
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:6,代码来源:DefaultMQPushConsumer.java
示例18: registerMessageListener
import com.alibaba.rocketmq.client.consumer.listener.MessageListener; //导入依赖的package包/类
/**
* Register the message listener
*
* @param messageListener
*/
@Deprecated
public void registerMessageListener(MessageListener messageListener);
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:8,代码来源:MQPushConsumer.java
注:本文中的com.alibaba.rocketmq.client.consumer.listener.MessageListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论