@Override public String partitionKeyFor(PublishedEvent publishedEvent) { return publishedEvent.getEntityId(); }
private void sendOldPublishedEvent(Producer<String, String> producer, String topicName) { for (int i = 0; i < 10; i++) { PublishedEvent publishedEvent = new PublishedEvent(); publishedEvent.setEntityId(UUID.randomUUID().toString()); String json = JSonMapper.toJson(publishedEvent); producer.send( new ProducerRecord<>(topicName, publishedEvent.getEntityId(), json)); } }
private void floodTopic(Producer<String, String> producer, String binlogFilename, String topicName) { for (int i = 0; i < 10; i++) { PublishedEvent publishedEvent = new PublishedEvent(); publishedEvent.setEntityId(UUID.randomUUID().toString()); publishedEvent.setBinlogFileOffset(new BinlogFileOffset(binlogFilename, (long)i)); String json = JSonMapper.toJson(publishedEvent); producer.send( new ProducerRecord<>(topicName, publishedEvent.getEntityId(), json)); } }
private SerializedEvent toSerializedEvent(ConsumerRecord<String, String> record) { PublishedEvent pe = JSonMapper.fromJson(record.value(), PublishedEvent.class); return new SerializedEvent( Int128.fromString(pe.getId()), pe.getEntityId(), pe.getEntityType(), pe.getEventData(), pe.getEventType(), record.partition(), record.offset(), EtopEventContext.make(pe.getId(), record.topic(), record.partition(), record.offset()), pe.getMetadata()); }
private SerializedEvent toSerializedEvent(ConsumerRecord<String, String> record) { PublishedEvent pe = JSonMapper.fromJson(record.value(), PublishedEvent.class); return new SerializedEvent( Int128.fromString(pe.getId()), pe.getEntityId(), pe.getEntityType(), pe.getEventData(), pe.getEventType(), record.partition(), record.offset(), EtopEventContext.make(pe.getId(), record.topic(), record.partition(), record.offset()), pe.getMetadata()); }