Buggy code:
public class RocketMQTridentSpout implements IPartitionedTridentSpout < List < MessageQueue > , ISpoutPartition , BatchMessage > { private static final long serialVersionUID = 8972193358178718167L ; private static final Logger LOG = LoggerFactory . getLogger ( RocketMQTridentSpout . class ) ; private static final ConcurrentMap < String , List < MessageQueue > > cachedMessageQueue = new MapMaker ( ) . makeMap ( ) ; private RocketMQConfig config ; private transient volatile DefaultMQPullConsumer consumer ; public RocketMQTridentSpout ( ) { } private MQPullConsumer getConsumer ( ) throws MQClientException { } public RocketMQTridentSpout ( RocketMQConfig config ) throws MQClientException { } private List < MessageQueue > getMessageQueue ( String topic ) throws MQClientException { } class RocketMQCoordinator implements Coordinator < List < MessageQueue > > { @ Override public List < MessageQueue > getPartitionsForBatch ( ) { } @ Override public boolean isReady ( long txId ) { } @ Override public void close ( ) { } } class RocketMQEmitter implements Emitter < List < MessageQueue > , ISpoutPartition , BatchMessage > { @ Override public List < ISpoutPartition > getOrderedPartitions ( List < MessageQueue > allPartitionInfo ) { } private BatchMessage handlePullResult ( TransactionAttempt tx , TridentCollector collector , PullResult result , MessageQueue mq , BatchMessage lastPartitionMeta ) throws MQClientException { final String signature = ( getClass ( ) . getName ( ) ) + "#handlePullResult" ; RocketMQTridentSpout . LOG . debug ( "PullResult<seq2seq4repair_space>status:<seq2seq4repair_space>{},<seq2seq4repair_space>maxOffset:{},<seq2seq4repair_space>nextBeginOffset:<seq2seq4repair_space>{},<seq2seq4repair_space>signature:{},<seq2seq4repair_space>mq:{},<seq2seq4repair_space>lastPartitionMeta:{}" , result . getPullStatus ( ) . name ( ) , result . getMaxOffset ( ) , result . getNextBeginOffset ( ) , signature , mq , lastPartitionMeta ) ; switch ( result . getPullStatus ( ) ) { case FOUND : BatchMessage batchMessages = null ; List < MessageExt > msgs = result . getMsgFoundList ( ) ; RocketMQTridentSpout . LOG . debug ( "MessageFoundList<seq2seq4repair_space>size:<seq2seq4repair_space>{}" , msgs . size ( ) ) ; if ( ( null != ( config . getTopicTag ( ) ) ) && ( ! ( "*" . equals ( config . getTopicTag ( ) ) ) ) ) { String [ ] tags = config . getTopicTag ( ) . split ( "\\|\\|" ) ; List < MessageExt > filteredMsgs = Lists . newArrayList ( ) ; if ( ! ( msgs . isEmpty ( ) ) ) { for ( MessageExt msg : msgs ) { for ( String tag : tags ) { if ( tag . equals ( msg . getTags ( ) ) ) { filteredMsgs . add ( msg ) ; break ; } } } } msgs = filteredMsgs ; } if ( ( msgs . size ( ) ) > 0 ) { batchMessages = new BatchMessage ( msgs , mq ) ; batchMessages . setOffset ( result . getMinOffset ( ) ) ; batchMessages . setNextOffset ( result . getNextBeginOffset ( ) ) ; for ( MessageExt msg : msgs ) { collector . emit ( Lists . newArrayList ( tx , msg ) ) ; } } getConsumer ( ) . updateConsumeOffset ( mq , result . getNextBeginOffset ( ) ) ; DefaultMQPullConsumer defaultMQPullConsumer = ( ( DefaultMQPullConsumer ) ( getConsumer ( ) ) ) ; defaultMQPullConsumer . getOffsetStore ( ) . persist ( mq ) ; return batchMessages ; case NO_NEW_MSG : RocketMQTridentSpout . LOG . debug ( "No<seq2seq4repair_space>new<seq2seq4repair_space>messages<seq2seq4repair_space>for<seq2seq4repair_space>this<seq2seq4repair_space>pull<seq2seq4repair_space>request." ) ; break ; case NO_MATCHED_MSG : RocketMQTridentSpout . LOG . debug ( "No<seq2seq4repair_space>matched<seq2seq4repair_space>messages<seq2seq4repair_space>for<seq2seq4repair_space>this<seq2seq4repair_space>pull<seq2seq4repair_space>request" ) ; break ; case OFFSET_ILLEGAL : RocketMQTridentSpout . LOG . error ( "Offset<seq2seq4repair_space>illegal,<seq2seq4repair_space>please<seq2seq4repair_space>notify<seq2seq4repair_space>RocketMQ<seq2seq4repair_space>Development<seq2seq4repair_space>Team" ) ; return lastPartitionMeta ; case SLAVE_LAG_BEHIND : RocketMQTridentSpout . LOG . warn ( "Master<seq2seq4repair_space>node<seq2seq4repair_space>is<seq2seq4repair_space>down<seq2seq4repair_space>and<seq2seq4repair_space>slave<seq2seq4repair_space>replication<seq2seq4repair_space>is<seq2seq4repair_space>lagged<seq2seq4repair_space>behind." ) ; break ; case SUBSCRIPTION_NOT_LATEST : RocketMQTridentSpout . LOG . error ( "Subscription<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>latest,<seq2seq4repair_space>please<seq2seq4repair_space>notify<seq2seq4repair_space>RocketMQ<seq2seq4repair_space>Development<seq2seq4repair_space>Team" ) ; break ; default : RocketMQTridentSpout . LOG . error ( "Unexpected<seq2seq4repair_space>execution,<seq2seq4repair_space>please<seq2seq4repair_space>notify<seq2seq4repair_space>RocketMQ<seq2seq4repair_space>Development<seq2seq4repair_space>Team" ) ; break ; } BatchMessage batchMessage = new BatchMessage ( ) ; <START_BUG> batchMessage . setOffset ( ( ( result . getNextBeginOffset ( ) ) - 1 ) ) ; <END_BUG> batchMessage . setNextOffset ( result . getNextBeginOffset ( ) ) ; return batchMessage ; } @ Override public BatchMessage emitPartitionBatchNew ( TransactionAttempt tx , TridentCollector collector , ISpoutPartition partition , BatchMessage lastPartitionMeta ) { } @ Override public void refreshPartitions ( List < ISpoutPartition > partitionResponsibilities ) { } @ Override public void emitPartitionBatch ( TransactionAttempt tx , TridentCollector collector , ISpoutPartition partition , BatchMessage partitionMeta ) { } @ Override public void close ( ) { } } @ Override public Coordinator < List < MessageQueue > > getCoordinator ( @ SuppressWarnings ( "rawtypes" ) Map conf , TopologyContext context ) { } @ Override public Emitter < List < MessageQueue > , ISpoutPartition , BatchMessage > getEmitter ( @ SuppressWarnings ( "rawtypes" ) Map conf , TopologyContext context ) { } @ SuppressWarnings ( "rawtypes" ) @ Override public Map getComponentConfiguration ( ) { } @ Override public Fields getOutputFields ( ) { } }

Fix:
batchMessage . setOffset ( result . getNextBeginOffset ( ) ) ;