Skip to content

Commit

Permalink
FINERACT-1971: Event sequence id int overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kulminsky authored and galovics committed Jan 14, 2025
1 parent 2151b19 commit c22844d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fineract-avro-schemas/src/main/avro/BulkMessageItemV1.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "id",
"doc": "The ID of the message to be sent",
"type": "int"
"type": "long"
},
{
"name": "type",
Expand Down
2 changes: 1 addition & 1 deletion fineract-avro-schemas/src/main/avro/MessageV1.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "id",
"doc": "The ID of the message to be sent",
"type": "int"
"type": "long"
},
{
"name": "source",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private ExternalEvent handleBulkBusinessEvent(BulkBusinessEvent bulkBusinessEven
List<BusinessEvent<?>> events = bulkBusinessEvent.get();
for (int i = 0; i < events.size(); i++) {
BusinessEvent<?> event = events.get(i);
int id = i + 1;
long id = (long) i + 1;
BulkMessageItemV1 message = bulkMessageItemFactory.createBulkMessageItem(id, event);
messages.add(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class BulkMessageItemFactory {
private final ByteBufferConverter byteBufferConverter;
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);
ByteBufferSerializable avroDto = dataEnricherProcessor.enrich(eventSerializer.toAvroDTO(event));
ByteBuffer buffer = avroDto.toByteBuffer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
@Getter
public class MessageId {

private final int id;
private final long id;
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void givenBatchSize2WhenTaskExecutionThenSend2Events() throws Exception {
createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L),
createExternalEventView("aType", "aCategory", "aSchema", new byte[0], "aIdempotencyKey", 1L));
// 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));

when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events);
Expand All @@ -166,7 +166,7 @@ public void givenBatchSize2WhenEventSendFailsThenExecutionStops() throws Excepti
List<ExternalEventView> events = Arrays.asList(
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));
when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events);
when(messageFactory.createMessage(Mockito.any())).thenReturn(dummyMessage);
Expand All @@ -185,7 +185,7 @@ public void givenOneEventWhenEventSentThenEventStatusUpdates() throws Exception
// given
List<ExternalEventView> events = Arrays
.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));
when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events);
when(messageFactory.createMessage(Mockito.any())).thenReturn(dummyMessage);
Expand All @@ -206,7 +206,7 @@ public void testExecuteShouldHandleNullAggregateId() throws Exception {
// given
List<ExternalEventView> events = Arrays
.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));
when(repository.findByStatusOrderByBusinessDateAscIdAsc(Mockito.any(), Mockito.any())).thenReturn(events);
when(messageFactory.createMessage(Mockito.any())).thenReturn(dummyMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void testPostEventShouldWorkWithBulkEvent() throws IOException {

String idempotencyKey = "key";
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));
byte[] data = new byte[0];

Expand Down

0 comments on commit c22844d

Please sign in to comment.