Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/api/src/archive/service/backfill_ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const backfillLedger = async (archiveId: string): Promise<void> => {
id: record.recordId,
body: JSON.stringify(message),
attributes: { Entity: "record", Action: "create" },
messageGroupId: "admin",
})
.catch((err: unknown) => {
logger.error(err);
Expand Down
1 change: 1 addition & 0 deletions packages/event_send/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const sendEvents = async (): Promise<void> => {
body: event.body,
}),
attributes: { Entity: event.entity, Action: event.action },
messageGroupId: event.actorId,
}));

for (const event of events.rows) {
Expand Down
32 changes: 32 additions & 0 deletions packages/publisher-utils/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,38 @@ describe("batchPublishMessages", () => {
process.env["AWS_ENDPOINT_URL"] = originalEndpoint;
}
});

test("should set MessageGroupId only on messages that provide one", async () => {
mockSend.mockResolvedValue({ Failed: [] });

const messages = [
{ id: "1", body: "message 1", messageGroupId: "tenant-a" },
{ id: "2", body: "message 2" },
];

await publisherClient.batchPublishMessages("topic", messages);

const {
mock: {
calls: [firstCallArguments],
},
} = mockSend as {
mock: { calls: Array<Array<{ __input: PublishBatchInput }>> };
};
expect(firstCallArguments).toBeDefined();
if (firstCallArguments !== undefined) {
expect(firstCallArguments[0]).toBeDefined();
if (firstCallArguments[0] !== undefined) {
expect(firstCallArguments[0].__input).toEqual({
TopicArn: "topic",
PublishBatchRequestEntries: [
{ Id: "1", Message: "message 1", MessageGroupId: "tenant-a" },
{ Id: "2", Message: "message 2" },
],
});
}
}
});
});

describe("publishMessage", () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/publisher-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Message {
id: string;
body: string;
attributes?: Record<string, string>;
messageGroupId?: string;
}

const CHUNK_SIZE = 10;
Expand Down Expand Up @@ -50,6 +51,9 @@ const batchPublishMessages = async (
]),
);
}
if (message.messageGroupId !== undefined) {
entry.MessageGroupId = message.messageGroupId;
}
return entry;
}),
});
Expand Down
Loading