Search in sources :

Example 1 with MemoryStateRepository

use of org.apache.camel.impl.MemoryStateRepository in project camel by apache.

the class KafkaConsumerOffsetRepositoryResumeTest method doPreSetup.

@Override
protected void doPreSetup() throws Exception {
    Properties props = getDefaultProperties();
    producer = new org.apache.kafka.clients.producer.KafkaProducer<>(props);
    // Create the topic with 2 partitions + send 10 messages (5 in each partitions)
    kafkaBroker.createTopic(TOPIC, 2);
    for (int i = 0; i < 10; i++) {
        producer.send(new ProducerRecord<>(TOPIC, i % 2, "key", "message-" + i));
    }
    // Create the state repository with some initial offsets
    stateRepository = new MemoryStateRepository();
    stateRepository.setState(TOPIC + "/0", "2");
    stateRepository.setState(TOPIC + "/1", "3");
}
Also used : MemoryStateRepository(org.apache.camel.impl.MemoryStateRepository) Properties(java.util.Properties) MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 2 with MemoryStateRepository

use of org.apache.camel.impl.MemoryStateRepository in project camel by apache.

the class KafkaConsumerOffsetRepositoryEmptyTest method doPreSetup.

// FIXME lifecycle issue here
@Override
protected void doPreSetup() throws Exception {
    // Create the topic with 2 partitions + send 10 messages (5 in each partitions)
    kafkaBroker.createTopic(TOPIC, 2);
    Properties props = getDefaultProperties();
    producer = new org.apache.kafka.clients.producer.KafkaProducer<>(props);
    for (int i = 0; i < 10; i++) {
        producer.send(new ProducerRecord<>(TOPIC, i % 2, "key", "message-" + i));
    }
    stateRepository = new MemoryStateRepository();
}
Also used : MemoryStateRepository(org.apache.camel.impl.MemoryStateRepository) Properties(java.util.Properties) MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Aggregations

Properties (java.util.Properties)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 MemoryStateRepository (org.apache.camel.impl.MemoryStateRepository)2