|
9 | 9 | import io.confluent.kafka.schemaregistry.json.JsonSchema;
|
10 | 10 | import io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema;
|
11 | 11 | import kafka.coordinator.group.GroupMetadataManager;
|
| 12 | +import kafka.coordinator.transaction.TransactionLog; |
| 13 | +import kafka.coordinator.transaction.TxnKey; |
12 | 14 | import lombok.*;
|
13 | 15 | import org.akhq.configs.SchemaRegistryType;
|
14 | 16 | import org.akhq.utils.AvroToJsonDeserializer;
|
@@ -191,26 +193,36 @@ private String convertToString(byte[] payload, Integer schemaId, boolean isKey)
|
191 | 193 | return new String(payload);
|
192 | 194 | }
|
193 | 195 | } else if (topic.isInternalTopic() && topic.getName().equals("__consumer_offsets")) {
|
194 |
| - if (isKey) { |
195 |
| - try { |
| 196 | + try { |
| 197 | + if (isKey) { |
196 | 198 | return GroupMetadataManager.readMessageKey(ByteBuffer.wrap(payload)).key().toString();
|
197 |
| - } catch (Exception exception) { |
198 |
| - this.exceptions.add(Optional.ofNullable(exception.getMessage()) |
199 |
| - .filter(msg -> !msg.isBlank()) |
200 |
| - .orElseGet(() -> exception.getClass().getCanonicalName())); |
201 |
| - |
202 |
| - return new String(payload); |
203 |
| - } |
204 |
| - } else { |
205 |
| - try { |
| 199 | + } else { |
206 | 200 | return GroupMetadataManager.readOffsetMessageValue(ByteBuffer.wrap(payload)).toString();
|
207 |
| - } catch (Exception exception) { |
208 |
| - this.exceptions.add(Optional.ofNullable(exception.getMessage()) |
| 201 | + } |
| 202 | + } catch (Exception exception) { |
| 203 | + this.exceptions.add(Optional.ofNullable(exception.getMessage()) |
209 | 204 | .filter(msg -> !msg.isBlank())
|
210 | 205 | .orElseGet(() -> exception.getClass().getCanonicalName()));
|
211 | 206 |
|
212 |
| - return new String(payload); |
| 207 | + return new String(payload); |
| 208 | + } |
| 209 | + } else if (topic.isInternalTopic() && topic.getName().equals("__transaction_state")) { |
| 210 | + try { |
| 211 | + if (isKey) { |
| 212 | + TxnKey txnKey = TransactionLog.readTxnRecordKey(ByteBuffer.wrap(payload)); |
| 213 | + return avroToJsonSerializer.getMapper().writeValueAsString( |
| 214 | + Map.of("transactionalId", txnKey.transactionalId(), "version", txnKey.version()) |
| 215 | + ); |
| 216 | + } else { |
| 217 | + TxnKey txnKey = TransactionLog.readTxnRecordKey(ByteBuffer.wrap(this.bytesKey)); |
| 218 | + return avroToJsonSerializer.getMapper().writeValueAsString(TransactionLog.readTxnRecordValue(txnKey.transactionalId(), ByteBuffer.wrap(payload))); |
213 | 219 | }
|
| 220 | + } catch (Exception exception) { |
| 221 | + this.exceptions.add(Optional.ofNullable(exception.getMessage()) |
| 222 | + .filter(msg -> !msg.isBlank()) |
| 223 | + .orElseGet(() -> exception.getClass().getCanonicalName())); |
| 224 | + |
| 225 | + return new String(payload); |
214 | 226 | }
|
215 | 227 | } else {
|
216 | 228 | if (protobufToJsonDeserializer != null) {
|
|
0 commit comments