FINERACT-1971: Event sequence id int overflow

This commit is contained in:
Andrii Kulminskyi
2025-01-14 18:56:27 +01:00
committed by Arnold Gálovics
parent 2151b19e27
commit c22844d432
7 changed files with 10 additions and 10 deletions
@@ -6,7 +6,7 @@
{ {
"name": "id", "name": "id",
"doc": "The ID of the message to be sent", "doc": "The ID of the message to be sent",
"type": "int" "type": "long"
}, },
{ {
"name": "type", "name": "type",
@@ -6,7 +6,7 @@
{ {
"name": "id", "name": "id",
"doc": "The ID of the message to be sent", "doc": "The ID of the message to be sent",
"type": "int" "type": "long"
}, },
{ {
"name": "source", "name": "source",
@@ -84,7 +84,7 @@ public class ExternalEventService {
List<BusinessEvent<?>> events = bulkBusinessEvent.get(); List<BusinessEvent<?>> events = bulkBusinessEvent.get();
for (int i = 0; i < events.size(); i++) { for (int i = 0; i < events.size(); i++) {
BusinessEvent<?> event = events.get(i); BusinessEvent<?> event = events.get(i);
int id = i + 1; long id = (long) i + 1;
BulkMessageItemV1 message = bulkMessageItemFactory.createBulkMessageItem(id, event); BulkMessageItemV1 message = bulkMessageItemFactory.createBulkMessageItem(id, event);
messages.add(message); messages.add(message);
} }
@@ -38,7 +38,7 @@ public class BulkMessageItemFactory {
private final ByteBufferConverter byteBufferConverter; private final ByteBufferConverter byteBufferConverter;
private final DataEnricherProcessor dataEnricherProcessor; private final DataEnricherProcessor dataEnricherProcessor;
public BulkMessageItemV1 createBulkMessageItem(int id, BusinessEvent<?> event) throws IOException { public BulkMessageItemV1 createBulkMessageItem(long id, BusinessEvent<?> event) throws IOException {
BusinessEventSerializer eventSerializer = serializerFactory.create(event); BusinessEventSerializer eventSerializer = serializerFactory.create(event);
ByteBufferSerializable avroDto = dataEnricherProcessor.enrich(eventSerializer.toAvroDTO(event)); ByteBufferSerializable avroDto = dataEnricherProcessor.enrich(eventSerializer.toAvroDTO(event));
ByteBuffer buffer = avroDto.toByteBuffer(); ByteBuffer buffer = avroDto.toByteBuffer();
@@ -25,5 +25,5 @@ import lombok.RequiredArgsConstructor;
@Getter @Getter
public class MessageId { public class MessageId {
private final int id; private final long id;
} }
@@ -144,7 +144,7 @@ class SendAsynchronousEventsTaskletTest {
createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L), createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L),
createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L)); createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L));
// Dummy Message // Dummy Message
MessageV1 dummyMessage = new MessageV1(1, "aSource", "aType", "nocategory", "aCreateDate", "aBusinessDate", "aTenantId", MessageV1 dummyMessage = new MessageV1(1L, "aSource", "aType", "nocategory", "aCreateDate", "aBusinessDate", "aTenantId",
"anidempotencyKey", "aSchema", Mockito.mock(ByteBuffer.class)); "anidempotencyKey", "aSchema", Mockito.mock(ByteBuffer.class));
when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events); when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events);
@@ -166,7 +166,7 @@ class SendAsynchronousEventsTaskletTest {
List<ExternalEventView> events = Arrays.asList( List<ExternalEventView> events = Arrays.asList(
createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L), createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L),
createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L)); createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L));
MessageV1 dummyMessage = new MessageV1(1, "aSource", "aType", "nocategory", "aCreateDate", "aBusinessDate", "aTenantId", MessageV1 dummyMessage = new MessageV1(1L, "aSource", "aType", "nocategory", "aCreateDate", "aBusinessDate", "aTenantId",
"anidempotencyKey", "aSchema", Mockito.mock(ByteBuffer.class)); "anidempotencyKey", "aSchema", Mockito.mock(ByteBuffer.class));
when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events); when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events);
when(messageFactory.createMessage(Mockito.any())).thenReturn(dummyMessage); when(messageFactory.createMessage(Mockito.any())).thenReturn(dummyMessage);
@@ -185,7 +185,7 @@ class SendAsynchronousEventsTaskletTest {
// given // given
List<ExternalEventView> events = Arrays List<ExternalEventView> events = Arrays
.asList(createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L)); .asList(createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L));
MessageV1 dummyMessage = new MessageV1(1, "aSource", "aType", "nocategory", "aCreateDate", "aBusinessDate", "aTenantId", MessageV1 dummyMessage = new MessageV1(1L, "aSource", "aType", "nocategory", "aCreateDate", "aBusinessDate", "aTenantId",
"anidempotencyKey", "aSchema", Mockito.mock(ByteBuffer.class)); "anidempotencyKey", "aSchema", Mockito.mock(ByteBuffer.class));
when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events); when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events);
when(messageFactory.createMessage(Mockito.any())).thenReturn(dummyMessage); when(messageFactory.createMessage(Mockito.any())).thenReturn(dummyMessage);
@@ -206,7 +206,7 @@ class SendAsynchronousEventsTaskletTest {
// given // given
List<ExternalEventView> events = Arrays List<ExternalEventView> events = Arrays
.asList(createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", null)); .asList(createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", null));
MessageV1 dummyMessage = new MessageV1(1, "aSource", "aType", "nocategory", "aCreateDate", "aBusinessDate", "aTenantId", MessageV1 dummyMessage = new MessageV1(1L, "aSource", "aType", "nocategory", "aCreateDate", "aBusinessDate", "aTenantId",
"anidempotencyKey", "aSchema", Mockito.mock(ByteBuffer.class)); "anidempotencyKey", "aSchema", Mockito.mock(ByteBuffer.class));
when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events); when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events);
when(messageFactory.createMessage(Mockito.any())).thenReturn(dummyMessage); when(messageFactory.createMessage(Mockito.any())).thenReturn(dummyMessage);
@@ -180,7 +180,7 @@ class ExternalEventServiceTest {
String idempotencyKey = "key"; String idempotencyKey = "key";
BusinessEvent event = mock(BusinessEvent.class); BusinessEvent event = mock(BusinessEvent.class);
BulkMessageItemV1 messageItem = new BulkMessageItemV1(1, "", "", "", ByteBuffer.wrap(new byte[0])); BulkMessageItemV1 messageItem = new BulkMessageItemV1(1L, "", "", "", ByteBuffer.wrap(new byte[0]));
BulkBusinessEvent bulkEvent = new BulkBusinessEvent(List.of(event)); BulkBusinessEvent bulkEvent = new BulkBusinessEvent(List.of(event));
byte[] data = new byte[0]; byte[] data = new byte[0];