Skip to content

Commit d66d55b

Browse files
authored
Merge pull request #358 from Consdata/IKC-387-resend-event
IKC-387 Resend event
2 parents f606c39 + 4d4721a commit d66d55b

File tree

12 files changed

+48
-23
lines changed

12 files changed

+48
-23
lines changed

kouncil-backend/src/main/java/com/consdata/kouncil/serde/SchemaMessageSerde.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
@Service
1313
public class SchemaMessageSerde {
14+
1415
public DeserializedData deserialize(SchemaAwareCluster schemaAwareCluster, Bytes payload, KouncilSchemaMetadata kouncilSchemaMetadata) {
1516
MessageFormat messageFormat = schemaAwareCluster.getSchemaRegistryFacade().getSchemaFormat(kouncilSchemaMetadata);
1617
MessageFormatter formatter = schemaAwareCluster.getFormatter(messageFormat);
@@ -19,6 +20,12 @@ public DeserializedData deserialize(SchemaAwareCluster schemaAwareCluster, Bytes
1920
.deserialized(formatter.deserialize(DeserializationData.builder()
2021
.value(payload.get())
2122
.topicName(kouncilSchemaMetadata.getSchemaTopic())
23+
.useLogicalTypesConversions(true)
24+
.build()))
25+
.originalValue(formatter.deserialize(DeserializationData.builder()
26+
.value(payload.get())
27+
.topicName(kouncilSchemaMetadata.getSchemaTopic())
28+
.useLogicalTypesConversions(false)
2229
.build()))
2330
.messageFormat(formatter.getFormat())
2431
.schemaId(kouncilSchemaMetadata.getSchemaId())
@@ -35,7 +42,7 @@ public Bytes serialize(SchemaAwareCluster schemaAwareCluster, String payload, Ko
3542
.topicName(kouncilSchemaMetadata.getSchemaTopic())
3643
.schema(schema)
3744
.isKey(kouncilSchemaMetadata.isKey())
38-
.build()
45+
.build()
3946
);
4047
}
4148
}

kouncil-backend/src/main/java/com/consdata/kouncil/serde/deserialization/DeserializationData.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
public class DeserializationData {
99
String topicName;
1010
byte[] value;
11+
boolean useLogicalTypesConversions;
1112
}

kouncil-backend/src/main/java/com/consdata/kouncil/serde/deserialization/DeserializedData.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@Builder
99
public class DeserializedData {
1010
String deserialized;
11+
String originalValue;
1112
MessageFormat messageFormat;
1213
Integer schemaId;
1314
}

kouncil-backend/src/main/java/com/consdata/kouncil/serde/formatter/schema/AvroMessageFormatter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
@Slf4j
2020
public class AvroMessageFormatter implements MessageFormatter {
2121

22-
private final KafkaAvroDeserializer avroDeserializer;
2322
private final KafkaAvroSerializer avroSerializer;
23+
private final SchemaRegistryClient client;
2424

2525
public AvroMessageFormatter(SchemaRegistryClient client) {
26-
this.avroDeserializer = new KafkaAvroDeserializer(client);
2726
this.avroSerializer = new KafkaAvroSerializer(client);
28-
this.configureDeserializer();
27+
this.client = client;
2928
}
3029

3130
@Override
3231
public String deserialize(DeserializationData deserializationData) {
33-
Object deserialized = avroDeserializer.deserialize(deserializationData.getTopicName(), deserializationData.getValue());
34-
return deserialized.toString();
32+
KafkaAvroDeserializer avroDeserializer = new KafkaAvroDeserializer(client);
33+
this.configureDeserializer(avroDeserializer, deserializationData.isUseLogicalTypesConversions());
34+
return avroDeserializer.deserialize(deserializationData.getTopicName(), deserializationData.getValue()).toString();
3535
}
3636

3737
@Override
@@ -64,12 +64,12 @@ private void configureSerializer(SerializationData serializationData) {
6464
);
6565
}
6666

67-
private void configureDeserializer() {
67+
private void configureDeserializer(KafkaAvroDeserializer avroDeserializer, boolean useLogicalTypes) {
6868
avroDeserializer.configure(
6969
Map.of(
7070
AbstractKafkaSchemaSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, "needed_in_runtime_but_not_used",
7171
AbstractKafkaSchemaSerDeConfig.USE_LATEST_VERSION, true,
72-
KafkaAvroDeserializerConfig.AVRO_USE_LOGICAL_TYPE_CONVERTERS_CONFIG, true
72+
KafkaAvroDeserializerConfig.AVRO_USE_LOGICAL_TYPE_CONVERTERS_CONFIG, useLogicalTypes
7373
),
7474
false
7575
);

kouncil-backend/src/main/java/com/consdata/kouncil/topic/TopicMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.consdata.kouncil.topic;
22

33
import com.consdata.kouncil.serde.MessageFormat;
4+
import java.util.List;
45
import lombok.Builder;
56
import lombok.Data;
67

7-
import java.util.List;
8-
98
@Data
109
@Builder
1110
public class TopicMessage {
@@ -14,6 +13,7 @@ public class TopicMessage {
1413
private String key;
1514
private MessageFormat keyFormat;
1615
private String value;
16+
private String originalValue;
1717
private MessageFormat valueFormat;
1818
private long timestamp;
1919
private int partition;

kouncil-backend/src/main/java/com/consdata/kouncil/topic/TopicService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ private void pollMessages(String clusterId, int limit, KafkaConsumer<Bytes, Byte
196196
.key(deserializedMessage.getKeyData().getDeserialized())
197197
.keyFormat(deserializedMessage.getKeyData().getMessageFormat())
198198
.value(deserializedMessage.getValueData().getDeserialized())
199+
.originalValue(deserializedMessage.getValueData().getOriginalValue())
199200
.valueFormat(deserializedMessage.getValueData().getMessageFormat())
200201
.offset(consumerRecord.offset())
201202
.partition(consumerRecord.partition())

kouncil-frontend/apps/kouncil/src/app/topic/json-grid-data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {MessageFormat} from '@app/schema-registry';
33

44
export interface JsonGridData {
55
value: string;
6+
originalValue: string;
67
valueFormat: MessageFormat;
78
valueJson: Record<string, unknown>;
89
partition: number | null;

kouncil-frontend/apps/kouncil/src/app/topic/json-grid.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ describe('JsonGrid', () => {
7373
'kouncilTimestamp',
7474
'kouncilTimestampEpoch',
7575
'kouncilValue',
76+
'kouncilOriginalValue',
7677
'kouncilValueFormat',
7778
'kouncilValueJson',
7879
'headers']);
@@ -124,6 +125,7 @@ describe('JsonGrid', () => {
124125
'kouncilTimestamp',
125126
'kouncilTimestampEpoch',
126127
'kouncilValue',
128+
'kouncilOriginalValue',
127129
'kouncilValueFormat',
128130
'kouncilValueJson',
129131
'headers']);
@@ -174,6 +176,7 @@ describe('JsonGrid', () => {
174176
'kouncilTimestamp',
175177
'kouncilTimestampEpoch',
176178
'kouncilValue',
179+
'kouncilOriginalValue',
177180
'kouncilValueFormat',
178181
'kouncilValueJson',
179182
'headers']);

kouncil-frontend/apps/kouncil/src/app/topic/json-grid.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export class JsonGrid {
102102
row['kouncilTimestamp'] = this.formatTimestamp(object.timestamp);
103103
row['kouncilTimestampEpoch'] = object.timestamp;
104104
row['kouncilValue'] = object.value;
105+
row['kouncilOriginalValue'] = object.originalValue;
105106
row['kouncilValueFormat'] = object.valueFormat;
106107
row['kouncilValueJson'] = object.valueJson;
107108
row['headers'] = object.headers;

kouncil-frontend/apps/kouncil/src/app/topic/topic.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export class TopicComponent extends AbstractTableComponent implements OnInit, On
177177
const messageData = {
178178
value: event.kouncilValueJson && Object.keys(event.kouncilValueJson).length > 0 ?
179179
event.kouncilValueJson : event.kouncilValue,
180+
originalValue: event.kouncilOriginalValue,
180181
valueFormat: event.kouncilValueFormat,
181182
headers: event.headers,
182183
key: event.kouncilKeyJson && Object.keys(event.kouncilKeyJson).length > 0 ?
@@ -212,6 +213,7 @@ export class TopicComponent extends AbstractTableComponent implements OnInit, On
212213
topicMessages.messages.forEach((message: MessageData) =>
213214
values.push({
214215
value: message.value,
216+
originalValue: message.originalValue,
215217
valueFormat: message.valueFormat,
216218
valueJson: TopicComponent.tryParseJson(message.value),
217219
partition: message.partition,

kouncil-frontend/libs/feat-send/src/lib/send/send.component.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ declare let monaco: any;
4545
4646
<div class="drawer-section-title">
4747
Headers
48-
<button type="button" class="small-button" mat-button disableRipple
48+
<button type="button" class="small-button" mat-button [disableRipple]="true"
4949
(click)="addHeader(messageData.headers)">
5050
+
5151
</button>
@@ -59,7 +59,7 @@ declare let monaco: any;
5959
<input class="header" [(ngModel)]="header.value" placeholder="Header value" matInput
6060
type="text" name="header-value-{{ i }}"/>
6161
</mat-form-field>
62-
<button type="button" class="small-button" mat-button disableRipple
62+
<button type="button" class="small-button" mat-button [disableRipple]="true"
6363
(click)="removeHeader(i, messageData.headers)">
6464
-
6565
</button>
@@ -79,11 +79,11 @@ declare let monaco: any;
7979
<mat-form-field [appearance]="'outline'" class="count">
8080
<input matInput type="number" min="1" [formControl]="countControl" name="count"/>
8181
<div matSuffix>
82-
<button type="button" class="small-button" mat-button disableRipple
82+
<button type="button" class="small-button" mat-button [disableRipple]="true"
8383
(click)="decreaseCount()">
8484
-
8585
</button>
86-
<button type="button" class="small-button" mat-button disableRipple
86+
<button type="button" class="small-button" mat-button [disableRipple]="true"
8787
(click)="increaseCount()">
8888
+
8989
</button>
@@ -93,11 +93,11 @@ declare let monaco: any;
9393
<span class="spacer"></span>
9494
9595
<div class="actions">
96-
<button type="button" mat-dialog-close mat-button disableRipple
96+
<button type="button" mat-dialog-close mat-button [disableRipple]="true"
9797
class="action-button-white">
9898
Cancel
9999
</button>
100-
<button mat-button disableRipple
100+
<button mat-button [disableRipple]="true"
101101
class="action-button-black"
102102
type="submit"
103103
[disabled]="isSendButtonDisabled">
@@ -136,13 +136,16 @@ export class SendComponent implements OnDestroy {
136136
map(exampleData => ({
137137
...messageData,
138138
key: messageData.key ?? JSON.stringify(exampleData.exampleKey),
139-
value: messageData.value ? JSON.stringify(messageData.value, null, 2) :
140-
JSON.stringify(exampleData.exampleValue, null, 2)
139+
value: messageData.originalValue
140+
? messageData.originalValue
141+
: (messageData.value
142+
? messageData.value
143+
: JSON.stringify(exampleData.exampleValue, null, 2))
141144
})
142145
)),
143146
of({
144147
...messageData,
145-
value: messageData.value ? JSON.stringify(messageData.value, null, 2) : messageData.value
148+
value: messageData.originalValue ? JSON.stringify(messageData.originalValue, null, 2) : messageData.value
146149
}
147150
));
148151
}
@@ -252,11 +255,15 @@ export class SendComponent implements OnDestroy {
252255
this.countControl.reset(1);
253256
}
254257

255-
addHeader(headers: MessageDataHeader[]): void {
256-
headers.push({key: '', value: ''} as MessageDataHeader);
258+
addHeader(headers: MessageDataHeader[] | undefined): void {
259+
if (headers) {
260+
headers.push({key: '', value: ''} as MessageDataHeader);
261+
}
257262
}
258263

259-
removeHeader(i: number, headers: MessageDataHeader[]): void {
260-
headers.splice(i, 1);
264+
removeHeader(i: number, headers: MessageDataHeader[] | undefined): void {
265+
if (headers) {
266+
headers.splice(i, 1);
267+
}
261268
}
262269
}

kouncil-frontend/libs/message-data/src/lib/message-data/message-data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface MessageData {
55
key: string;
66
keyFormat: MessageFormat;
77
value: string;
8+
originalValue: string;
89
valueFormat: MessageFormat;
910
offset: number | null;
1011
partition: number | null;

0 commit comments

Comments
 (0)