本文整理汇总了Java中com.alibaba.rocketmq.common.message.MessageExt.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java MessageExt.getProperty方法的具体用法?Java MessageExt.getProperty怎么用?Java MessageExt.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.rocketmq.common.message.MessageExt
的用法示例。
在下文中一共展示了MessageExt.getProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetRetryTopic
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
public void resetRetryTopic(final List<MessageExt> msgs) {
final String groupTopic = MixAll.getRetryTopic(consumerGroup);
for (MessageExt msg : msgs) {
String retryTopic = msg.getProperty(MessageConst.PROPERTY_RETRY_TOPIC);
if (retryTopic != null && groupTopic.equals(msg.getTopic())) {
msg.setTopic(retryTopic);
}
}
}
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:10,代码来源:ConsumeMessageConcurrentlyService.java
示例2: checkTransactionState
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
public RemotingCommand checkTransactionState(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final CheckTransactionStateRequestHeader requestHeader =
(CheckTransactionStateRequestHeader) request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
final ByteBuffer byteBuffer = ByteBuffer.wrap(request.getBody());
final MessageExt messageExt = MessageDecoder.decode(byteBuffer);
if (messageExt != null) {
final String group = messageExt.getProperty(MessageConst.PROPERTY_PRODUCER_GROUP);
if (group != null) {
MQProducerInner producer = this.mqClientFactory.selectProducer(group);
if (producer != null) {
final String addr = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
producer.checkTransactionState(addr, messageExt, requestHeader);
}
else {
log.debug("checkTransactionState, pick producer by group[{}] failed", group);
}
}
else {
log.warn("checkTransactionState, pick producer group failed");
}
}
else {
log.warn("checkTransactionState, decode message failed");
}
return null;
}
示例3: match
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
@Override
public boolean match(MessageExt msg) {
String property = msg.getProperty("SequenceId");
if (property != null) {
int id = Integer.parseInt(property);
if (((id % 10) == 0) && //
(id > 100)) {
return true;
}
}
return false;
}
示例4: putMessage
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
public boolean putMessage(final List<MessageExt> msgs) {
boolean dispatchToConsume = false;
try {
this.lockTreeMap.writeLock().lockInterruptibly();
try {
int validMsgCnt = 0;
for (MessageExt msg : msgs) {
//把拉取到的消息存入msgTreeMap中
MessageExt old = msgTreeMap.put(msg.getQueueOffset(), msg);
if (null == old) {
validMsgCnt++;
/* 更新队列queueoffset */
this.queueOffsetMax = msg.getQueueOffset();
}
}
//msg数增加validMsgCnt
msgCount.addAndGet(validMsgCnt);
if (!msgTreeMap.isEmpty() && !this.consuming) {
dispatchToConsume = true;
this.consuming = true;
}
if (!msgs.isEmpty()) {
MessageExt messageExt = msgs.get(msgs.size() - 1); //获取最后一条消息
String property = messageExt.getProperty(MessageConst.PROPERTY_MAX_OFFSET);
if (property != null) {
//在消息属性PROPERTY_MAX_OFFSET中记录了队列的最大位点, 和当前拉取到的最后一条消息
//的位点做差值,就是broker这个队列还堆积了多少消息未消费。。 messageExt.getQueueOffset()表示从队列中取到的最后一条消息
//该getQueueOffset对应的就是从队列中拉取到的最后一条消息的offset,也就是该消费分组消费到队列中的那条offset最大的消息
long accTotal = Long.parseLong(property) - messageExt.getQueueOffset();
if (accTotal > 0) {
this.msgAccCnt = accTotal;
}
}
}
}
finally {
this.lockTreeMap.writeLock().unlock();
}
}
catch (InterruptedException e) {
log.error("putMessage exception", e);
}
return dispatchToConsume;
}
示例5: putMessage
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
/**
* 放入消息到ProcessQueue
*
* @param msgs
* @return
*/
public boolean putMessage(final List<MessageExt> msgs) {
boolean dispatchToConsume = false;
try {
this.lockTreeMap.writeLock().lockInterruptibly();
try {
/**
* 把消息放入treemap,根据offset值去除重复消息,统计有效消息数量,更新Offset
*
* 消息以Offset为Key放入了treemap,则默认会按照offset的升序排序
*
*/
int validMsgCnt = 0;
for (MessageExt msg : msgs) {
MessageExt old = msgTreeMap.put(msg.getQueueOffset(), msg);
if (null == old) {
validMsgCnt++;
this.queueOffsetMax = msg.getQueueOffset();
}
}
msgCount.addAndGet(validMsgCnt);
if (!msgTreeMap.isEmpty() && !this.consuming) {
dispatchToConsume = true;
this.consuming = true;
}
if (!msgs.isEmpty()) {
//获取最后一条消息的MaxOffSet
MessageExt messageExt = msgs.get(msgs.size() - 1);
String property = messageExt.getProperty(MessageConst.PROPERTY_MAX_OFFSET);
if (property != null) {
/**
* commitlog offset
* 减去
* 消息对应MessageQueue的Offset
*
*/
long accTotal = Long.parseLong(property) - messageExt.getQueueOffset();
if (accTotal > 0) {
this.msgAccCnt = accTotal;
}
}
}
} finally {
this.lockTreeMap.writeLock().unlock();
}
} catch (InterruptedException e) {
log.error("putMessage exception", e);
}
return dispatchToConsume;
}