Java Code Examples for org.apache.kafka.clients.consumer.ConsumerRecord#NO_TIMESTAMP
The following examples show how to use
org.apache.kafka.clients.consumer.ConsumerRecord#NO_TIMESTAMP .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseRecordWeigherTest.java From kafka-workers with Apache License 2.0 | 5 votes |
private WorkerRecord<byte[], byte[]> workerRecordWithBytes(int keyLength, int valueLength) { ConsumerRecord<byte[], byte[]> consumerRecord = new ConsumerRecord<>(EMPTY_TOPIC, SOME_PARTITION, SOME_OFFSET, ConsumerRecord.NO_TIMESTAMP, TimestampType.NO_TIMESTAMP_TYPE, ConsumerRecord.NULL_CHECKSUM, keyLength, valueLength, new byte[keyLength], new byte[valueLength]); return new WorkerRecord<>(consumerRecord, SOME_SUBPARTITION); }
Example 2
Source File: BaseRecordWeigherTest.java From kafka-workers with Apache License 2.0 | 5 votes |
private WorkerRecord<String, String> workerRecordWithStrings(int keyLength, int valueLength) { String key = StringUtils.repeat(SOME_CHAR, keyLength); String value = StringUtils.repeat(SOME_CHAR, valueLength); ConsumerRecord<String, String> consumerRecord = new ConsumerRecord<>(EMPTY_TOPIC, SOME_PARTITION, SOME_OFFSET, ConsumerRecord.NO_TIMESTAMP, TimestampType.NO_TIMESTAMP_TYPE, ConsumerRecord.NULL_CHECKSUM, key.getBytes(UTF_8).length, value.getBytes(UTF_8).length, key, value); return new WorkerRecord<>(consumerRecord, SOME_SUBPARTITION); }
Example 3
Source File: BaseRecordWeigherTest.java From kafka-workers with Apache License 2.0 | 5 votes |
private WorkerRecord<byte[], byte[]> emptyWorkerRecordWithHeaders(String[] headers) { RecordHeaders recordHeaders = new RecordHeaders(); for (String headerStr: headers) { String[] split = headerStr.split(":"); recordHeaders.add(new RecordHeader(split[0], split[1].getBytes(ISO_8859_1))); } ConsumerRecord<byte[], byte[]> consumerRecord = new ConsumerRecord<>(EMPTY_TOPIC, SOME_PARTITION, SOME_OFFSET, ConsumerRecord.NO_TIMESTAMP, TimestampType.NO_TIMESTAMP_TYPE, (long) ConsumerRecord.NULL_CHECKSUM, 0, 0, new byte[0], new byte[0], recordHeaders); return new WorkerRecord<>(consumerRecord, SOME_SUBPARTITION); }
Example 4
Source File: RenameTopicHandler.java From mirrormaker_topic_rename with Apache License 2.0 | 5 votes |
public List<ProducerRecord<byte[], byte[]>> handle(BaseConsumerRecord record) { String targetTopic = null; if (topicMap.containsKey(record.topic())) { // for this topic the name should be substituted by something else, so return a new record with the changed name targetTopic = topicMap.get(record.topic()); } else { // no substitution necessary, return the record with unchanged properties targetTopic = record.topic(); } Long timestamp = record.timestamp() == ConsumerRecord.NO_TIMESTAMP ? null : record.timestamp(); // topic is set correctly at this point, return a list containing the new record with updated parameters return Collections.singletonList(new ProducerRecord<byte[], byte[]>(targetTopic, null, timestamp, record.key(), record.value(), record.headers())); }