As mentioned above, good solution is add id to every consumed message add store indexes of last n messages on consumer database.This solution is described in the book Microservices Patterns by Chris Richardson in Chapter 3.3.6
https://www.amazon.com/Microservices-Patterns-examples-Chris-Richardson/dp/1617294543