简体   繁体   中英

Replay messages in Kafka

I am working with kafka in spring boot, and I am trying to add a functionality that will allow us to start up a service and have it replay messages back to a certain time.

The consumer is setup like this

public interface ProductScenarioStream {
    String SERVICE_REQUESTS_PRODUCT_PRICE = "serviceRequestsProductPrice";
    String SERVICE_CONCLUDES_PRODUCT_SCENARIO = "serviceConcludesProductScenario";

    @Output(SERVICE_REQUESTS_PRODUCT_PRICE)
    MessageChannel serviceRequestsProductPrice();

    @Input(SERVICE_CONCLUDES_PRODUCT_SCENARIO)
    SubscribableChannel serviceConcludesProductScenario();
}

And

@Service
@EnableBinding(ProductScenarioStream.class)
@Profile("stream")
public class ProductStreamServiceImpl implements ProductStreamService 
{
    @Resource
    private ProductScenarioStream productScenarioStream;

    @Override
    public void send(final ServiceRequestsProductPrice event) {
     ...
    }
 }

Do you know where I could find the settings to allow me to rewind the offset on the stream in this scenario?

I assume you mean replay not reply - I have edited your question.

Spring Cloud Stream does not currently expose a mechanism to seek the offsets.

You can use spring-kafka's @KafkaListener instead; implement ConsumerSeekAware which gives you the mechanism to seek during startup (or any time).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM