Brug trickle loading med Exact Online webhooks

Denne note forklarer fordelene ved trickle loading af replikaer af Exact Online-selskaber, såsom kortere replikeringstider, herunder trin til at aktivere trickle loading. Et andet emne uddyber Trickle Loading ved brug af en OEM-licens til Invantive Data Replicator for at betjene mange kunder.

Trickle Loading

Data Replicator tilbyder en række tilgange til at reducere belastningen på din infrastruktur, især cloud-platforme, ved at replikere data til en central database. En af de mest populære optimeringer er at skifte fra den komplette kopieringsmetode til inkrementel indlæsning ved brug af „trickle loading".

Trickle loading er en teknik, hvor der i starten oprettes en fuld replika fra dine kilder, og derefter anvendes kun ændringer.

Versionering gælder stadig ved trickle loading: som en atomisk handling skifter dine brugere mellem nuværende og nye versioner af det fulde indhold i en tabel.

Ændringer fra cloud-applikationer indsamles typisk via Invantive Cloud og gøres tilgængelige i en kø til download af den autoriserede ejer. I øjeblikket understøttes kun Exact Online via webhooks. En hurtig opsætning er vist nedenfor.

Ændringer fra on-premise platforme, såsom databaser, kan indsamles ved hjælp af database-triggere eller redo log mining, og kræver manuelt arbejde og rådgivning fra Invantive.

Fordele

Trickle loading har en række fordele:

  • Trickle loading forkorter varigheden af den daglige indlæsningsfase, for eksempel fra 30 minutter for 100.000 konti på Exact Online til 30 sekunder.
  • Hvis der ikke er registreret nogen ændringer, rykkes versionens udløbsdato frem uden at ændre versionsnumrene.
  • Det reducerede forbrug af CPU og disk I/O mindsker ressourceforbruget betydeligt, især når over 1.000 partitioner er blevet replikeret til en database.
  • Ved 24/7-indlæsningscyklusser reducerer de kortere indlæsningsfaser også tidsvinduet, hvor relaterede tabeller har inkonsistent indhold på grund af krænkelser af fremmednøglebegrænsninger (foreign key constraints).

Risici

Trickle loading introducerer også en række risici, især fordi de fleste webhooks, der bruges til trickle-opdateringer, generelt mangler koncepter som heartbeat og indikatorer for tjenestens tilstand (health of service):

  • Ingen opdateringer bliver anvendt, når en tabelpartition i repositoryet er konfigureret til trickle loading, men platformen ikke leverer opdateringerne. Anbefalet handling: aktiver trickle loading omhyggeligt og globalt på platformen.
  • Tab af abonnement, når en tabelpartition i repositoryet er konfigureret til trickle loading, men platformen ikke leverer opdateringerne. Exact Online har ved flere lejligheder mistet abonnementer. Anbefalet handling: aktiver trickle loading omhyggeligt og globalt på platformen. Anvend applikationskontroller for at opdage tab af abonnementer.
  • Forsinkede opdateringer, hvor de opdateringer, der skal indlæses, ankommer med betydelig forsinkelse. Anbefalet handling: anvend applikationskontroller.

Aktivering af Trickle Loading

For at aktivere trickle loading på Exact Online konfigurerer du en Data Replicator-forbindelsesstreng og udfører følgende udtryk:

--
-- Vælg de partitioner (Exact Online-selskaber), der skal replikeres.
--
use 123456,345678
 
--
-- Indledende opsætningstrin.
--
begin
  --
  -- Opret en indledende komplet kopi ved hjælp af en nem 'select count(*)'.
  --
  select count(*) from exactonlinerest..salesinvoices;
  select count(*) from exactonlinerest..salesinvoicelines;
  --
  -- Skift strategi for tabellerne til at bruge trickle loading.
  --
  -- Tabeller, hvor trickle loading ikke er tilgængeligt, vil give en fejl. Du
  -- kan stadig køre en komplet kopi.
  --
  alter persistent cache set table exactonlinerest..salesinvoices approach trickle;
  alter persistent cache set table exactonlinerest..salesinvoicelines approach trickle;
  --
  -- Konfigurer dit lokale Data Replicator-repository med legitimationsoplysninger til at downloade
  -- de modtagne webhook-hændelser.
  --
  -- Modtag dit token fra Invantive.
  --
  alter persistent cache set token 'secret'
  --
  -- Aktiver nu webhooks for Exact Online på https://data-replicator.cloud.
  -- For mængder over 30 selskaber bedes du arrangere et rådgivningsopkald for
  -- at få hjælp til at køre SQL-udtrykkene for at sikre, at du registrerer de korrekte webhooks
  -- på tværs af dine selskaber.
  --
  -- Fra nu af vil ændringer i Exact Online blive registreret og indsamlet.
  --
  -- For at sikre, at ingen ændringer er gået tabt mellem starten af denne PSQL-blok og nu,
  -- udfør en fuld genindlæsning.
  --
  alter persistent cache
  table exactonlinerest.salesinvoice.salesinvoices
  force refresh approach copy
  ;
  alter persistent cache
  table exactonlinerest.salesinvoice.salesinvoicelines
  force refresh approach copy
  ;
end;
 
--
-- Trin for daglig eller hyppigere replikering.
--
begin
  --
  -- Download alle indsamlede hændelser.
  --
  alter persistent cache download feed;
  --
  -- Opdater indholdet af to tabeller ved hjælp af standardstrategien konfigureret
  -- på tabellen.
  --
  -- Selv med store mængder og tilstrækkelig disk I/O-kapacitet
  -- tager dette trin generelt mindre end 1 minut.
  --
  alter persistent cache table exactonlinerest.salesinvoice.salesinvoicelines refresh;
  alter persistent cache table exactonlinerest.salesinvoice.salesinvoices refresh;
  --
  -- Eller brug følgende udtryk, som udfører en komplet download af alle tabeller, hvor
  -- trickle loading ikke er konfigureret. Og bruger trickle loading for dem, hvor trickle
  -- loading er konfigureret.
  --
  alter persistent cache refresh;
end;

When I use:

alter persistent cache download feed

and then, for instance

alter persistent cache table ExactOnlineREST.SalesOrder.SalesOrdersBulk refresh approach trickle

it ends up saying:

No messages received ever for table ‘ExactOnlineREST.SalesOrder.SalesOrdersBulk’ for partition ‘999’ according to database. Switch from trickle loading to complete replication till the trickle loading loop is closed.

Is there a way to force trickle loading, and if no changes are present, do NOT do a complete replication?

Invantive Data Replicator can use trickle loading, which means that only deltas (changes consisting of insert, update and delete) are applied on the previous table partition version (on Exact Online; a completed load of a table and an Exact Online company) leading to a new table partition version. For instance:

  • old table partition version Exact Online company 123, table TransactionLinesIncremental, ready version 8
  • take deltas and apply on old version
  • make new version 9 and assign it state ‘Ready’.

The trickle loading process is also elaborated on in the topic Enable webhook trickle loading on OEM licenses. More precise, for Exact Online the delivery of webhooks is a sensitive process since Exact Online currently lacks any form of heart beat to report that the loop has been established:

Therefore Data Replicator on Exact Online uses the first delta as a heart beat signal to indicate the loop has been closed.

A request has been registered with Exact for some years to improve the reliability of webhook event delivery, but as of 2021 there is no final plan to add such functionality. As an alternative to reduce loading times, there is an option to resort to the new *Incremental tables such as ItemsIncremental. They combine a reduced API consumption with always consistent data contents. For more background refer to:

Small number of companies

For small numbers of Exact Online companies, the easiest way is to wait a few days and then check in dc_table_partition_versions that the actual approach used is trickle loading (value T).

Note that dc_table_partition_versions contains a column for the request seeding approach and the actual approach used.

For those tables still not using tricke loading, you can ask a key user to create and delete a transaction such as updating the description of a General Ledger Account.

Large number of Exact Online companies

The manual approach to get the first signal over the wire can be labor intensive, especially when replicating hundreds or thousands of Exact Online companies. This holds especially for accounting firms where many Exact Online companies are only updated once per year, such as during the yearly accounting and/or regulatory reporting on holdings. Till the first message is processed, trickle loading on these companies will resort to full copy approach.

There is no supported way to manually force the loading approach for large number of Exact Online companies from Copy to Trickle Loading. However, an Invantive consultant can make the necessary internal changes to the Data Replicator repository on basis of Time & Material to simulate that a message was received. This typically takes 30 minutes per Data Replicator repository.

When I use:

use all;

alter persistent cache table ExactOnlineREST.Financial.GLAccountsBulk force refresh approach copy;

Then I see in the screen that the copy approach is used, and I see that all rows are downloaded. But when I view the dc_table_partition_versions, it still says:

seeding_approach_used = T

Where do I view the actual approach used?

What Invantive SQL release is it?

20.0.143

sau
copy

I am uncertain what release is in use, but probably the queue for trickle loading messages is large. If so, then Data Replicator reverts to full copy.

Please make sure to be running 20.0.142 or newer and read the explanation on Purge obsoleted change events.

The problem is the opposite:

when I explicitly ask for a force refresh approach copy, then verify in the ‘Uitvoeren’ window that there is a Forced copy performed, the seeding_approach_used in the table partition versions is still shown as T.

Version is 20.0.143 as stated.