bcquality/custom/knowledge/integration/use-a-framing-record-for-inbound-polling.bad.al
Tharanga Chandrasekara 07140e2223 Add new action skills for AL testing and documentation
- Introduced `al-test-writer` to generate AL test codeunits for production objects based on TDD principles.
- Added `al-userguide-test-writer` to create test codeunits from user guide steps, mapping actions and assertions.
- Implemented `bc-extension-test-guide` to generate a comprehensive TEST_GUIDE.md for Business Central extensions, covering various categories.
- Created `bc-webclient-runner` to automate UI testing of the Business Central web client, capturing screenshots and asserting UI states.
- Developed `page-scripting-e2e` to produce a recording plan for Page Scripting, ensuring a structured approach to browser-level testing.
2026-06-07 12:26:47 +12:00

27 lines
1.2 KiB
AL

// Anti-pattern: no framing record, no watermark, no lock. Every run fetches the whole
// collection, and two overlapping Job Queue runs stage the same records twice.
codeunit 50132 "Inbound Poller Bad"
{
TableNo = "Job Queue Entry";
procedure Poll()
var
Client: HttpClient;
Response: HttpResponseMessage;
begin
// BAD: "fetch all". No last-fetch datetime feeds the request and no window cap bounds it,
// so the cost of every poll grows with the TOTAL data set, not with what is new. Records
// that were already staged and resolved are pulled again and reprocessed every run.
Client.Get('https://svc.contoso.com/api/orders', Response);
// BAD: no lock. The Job Queue can start the next run before this one finishes (a run that
// overruns its recurrence interval overlaps the following one). Both runs fetch the full
// collection concurrently and BOTH stage every order, so each order lands twice and becomes
// a duplicate document downstream.
StageAll(Response);
// There is also no watermark to advance, so even back-to-back runs cannot narrow their
// windows: there is no notion of "where we left off" anywhere in this design.
end;
}