use of com.hummer.rocketmq.consumer.plugin.support.offset.MessageOffset in project hummer-framework by hummer-team.
the class MessageHandlerHolder method builderEventData.
public Tuple.TupleTwo<List<MessageData<E>>, List<MessageOffset>> builderEventData(List<MessageExt> msgs, String group) {
List<MessageData<E>> data = Lists.newArrayListWithCapacity(msgs.size());
List<MessageOffset> offsets = Lists.newArrayListWithCapacity(msgs.size());
for (MessageExt message : msgs) {
// event data
try {
MessageData<E> messageData = createEventData(message);
data.add(messageData);
} catch (Exception e) {
LOGGER.warn("topic {} message deserialize error ", message.getTopic(), e);
}
// queue offset
MessageOffset offset = getMessageOffset(message, group);
offsets.add(offset);
}
return new Tuple.TupleTwo<>(data, offsets);
}
use of com.hummer.rocketmq.consumer.plugin.support.offset.MessageOffset in project hummer-framework by hummer-team.
the class PullConsumer method setOffset.
private void setOffset(List<MessageExt> msgs) {
for (MessageExt msg : msgs) {
Tuple.TupleTwo<Boolean, Long> offset = offsetMap.get(msg.getQueueId());
if (offset == null) {
MessageOffset msgOffset = MessageOffset.loadMessageOffset(group, msg.getTopic(), msg.getQueueId());
if (msgOffset != null) {
offsetMap.put(msg.getQueueId(), new Tuple.TupleTwo<>(Boolean.TRUE, msgOffset.getOffset()));
queueOffsetMap.put(msg.getQueueId(), msgOffset.getOffset());
MessageOffset.seekOffsetWithMessage(msgOffset, msg, pullConsumer);
}
}
}
// reSet offset index
if (MapUtils.isNotEmpty(queueOffsetMap)) {
MessageOffset.reSetMessageExt(msgs, queueOffsetMap);
}
}
Aggregations