Skip to content

MockConsumer does not work #176

@jagrutmehta

Description

@jagrutmehta

Parallel Consumer wrapper does not work with MockConsumer. It keeps on skipping messages with error message "Record in buffer for a partition no longer assigned. Dropping."

		
            mockconsumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
	    HashMap<TopicPartition, Long> startOffsets = new HashMap<>();
	    TopicPartition tp = new TopicPartition(topic, 0);
	    startOffsets.put(tp, 0L);
	    mockconsumer.updateBeginningOffsets(startOffsets);
             mockconsumer.schedulePollTask(() -> {
	          mockconsumer.subscribe(Arrays.asList(new String[] {topic}));
                  /* Tried this one as well
                  mockconsumer.subscribe(Arrays.asList(new String[] {topic}), (ParallelEoSStreamProcessor)eosStreamProcessor);
                  */
	    	mockconsumer.rebalance(Collections.singletonList(new TopicPartition(topic, 0)) );
	    });

... doesn't work without scheduled task also

            mockconsumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
	    HashMap<TopicPartition, Long> startOffsets = new HashMap<>();
	    TopicPartition tp = new TopicPartition(topic, 0);
	    startOffsets.put(tp, 0L);
	    mockconsumer.updateBeginningOffsets(startOffsets);
 	    mockconsumer.subscribe(Arrays.asList(new String[] {topic}));
            /* Tried this one as well
            mockconsumer.subscribe(Arrays.asList(new String[] {topic}), (ParallelEoSStreamProcessor)eosStreamProcessor);
            */
           mockconsumer.rebalance(Collections.singletonList(new TopicPartition(topic, 0)) );


Above code works fine without ParallelStreamProcessor and done polling directly on consumer.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions