Använd trickle loading med Exact Online-webhooks

Den här anteckningen förklarar fördelarna med att använda trickle loading vid replikering av Exact Online-företag, såsom kortare replikeringstider, inklusive stegen för att aktivera trickle loading. Ett annat ämne går närmare in på Trickle Loading vid användning av en OEM-licens för Invantive Data Replicator för att betjäna många kunder.

Trickle Loading

Data Replicator erbjuder en rad olika metoder för att minska belastningen på din infrastruktur, särskilt molnplattformar, genom att replikera data till en central databas. En av de mest populära optimeringarna är att byta från metoden med fullständig kopiering till inkrementell laddning med hjälp av ”trickle loading”.

Trickle loading är en teknik där det först skapas en fullständig replik av dina källor, och därefter tillämpas endast ändringar.

Versionshantering gäller fortfarande vid trickle loading: som en atomär åtgärd växlar dina användare mellan nuvarande och nya versioner av tabellens fullständiga innehåll.

Ändringar från molnapplikationer samlas vanligtvis in med hjälp av Invantive Cloud och görs tillgängliga i en kö för nedladdning av den auktoriserade ägaren. För närvarande stöds endast Exact Online via webhooks. En snabb installationsguide ges nedan.

Ändringar från lokala plattformar (on-premise), såsom databaser, kan samlas in med hjälp av databastriggers eller redo log mining, och kräver manuellt arbete och konsultation från Invantive.

Fördelar

Trickle loading har ett antal fördelar:

  • Trickle loading förkortar varaktigheten av den dagliga laddningsfasen, till exempel från 30 minuter för 100 000 konton i Exact Online till 30 sekunder.
  • Om inga ändringar har registrerats, flyttas versionens utgångsdatum fram utan att versionsnumren ändras.
  • Den minskade mängden CPU- och disk-I/O som krävs minskar resursförbrukningen avsevärt, särskilt när fler än 1 000 partitioner har replikerats till en databas.
  • Vid 24/7-laddningscykler minskar de förkortade laddningsfaserna också det tidsfönster under vilket relaterade tabeller har inkonsekvent innehåll på grund av att främmande nyckel-begränsningar (foreign key constraints) bryts.

Risker

Trickle loading medför också ett antal risker, särskilt eftersom de flesta webhooks som används för trickle-laddningar i allmänhet saknar koncept som heartbeat och hälsostatusindikatorer för tjänsten:

  • Inga uppdateringar tillämpas, när en tabellpartition i repositoryt har konfigurerats för trickle loading, men plattformen inte levererar laddningarna. Rekommenderad åtgärd: aktivera trickle loading på plattformen noggrant och globalt.
  • Förlust av prenumeration, när en tabellpartition i repositoryt har konfigurerats för trickle loading, men plattformen inte levererar laddningarna. Exact Online har vid flera tillfällen förlorat prenumerationer. Rekommenderad åtgärd: aktivera trickle loading på plattformen noggrant och globalt. Använd applikationskontroller för att upptäcka förlust av prenumerationer.
  • Fördröjda laddningar, där de laddningar som ska bearbetas anländer med en betydande fördröjning. Rekommenderad åtgärd: använd applikationskontroller.

Aktivera Trickle Loading

För att aktivera trickle loading för Exact Online konfigurerar du en Data Replicator-anslutningssträng och kör följande satser:

--
-- Välj de partitioner (Exact Online-företag) som ska replikeras.
--
use 123456,345678
 
--
-- Inledande installationssteg.
--
begin
  --
  -- Skapa en första fullständig kopia med hjälp av en enkel 'select count(*)'.
  --
  select count(*) from exactonlinerest..salesinvoices;
  select count(*) from exactonlinerest..salesinvoicelines;
  --
  -- Ändra strategin för tabellerna så att de använder trickle loading.
  --
  -- Tabeller för vilka trickle loading inte är tillgängligt kommer att ge ett fel. Du
  -- kan fortfarande köra en fullständig kopiering.
  --
  alter persistent cache set table exactonlinerest..salesinvoices approach trickle;
  alter persistent cache set table exactonlinerest..salesinvoicelines approach trickle;
  --
  -- Konfigurera ditt lokala Data Replicator-repository med autentiseringsuppgifter för att ladda ner
  -- de mottagna webhook-händelserna.
  --
  -- Hämta din token från Invantive.
  --
  alter persistent cache set token 'secret'
  --
  -- Aktivera nu webhooks för Exact Online på https://data-replicator.cloud.
  -- För volymer över 30 företag, boka ett konsultationssamtal för
  -- att få hjälp med att köra SQL-satserna och säkerställa att du registrerar rätt webhooks
  -- för alla dina företag.
  --
  -- Från och med nu kommer ändringar i Exact Online att registreras och samlas in.
  --
  -- För att säkerställa att inga ändringar har gått förlorade mellan starten av detta PSQL-block och nu,
  -- kör en fullständig omladdning.
  --
  alter persistent cache
  table exactonlinerest.salesinvoice.salesinvoices
  force refresh approach copy
  ;
  alter persistent cache
  table exactonlinerest.salesinvoice.salesinvoicelines
  force refresh approach copy
  ;
end;
 
--
-- Steg för daglig eller mer frekvent replikering.
--
begin
  --
  -- Ladda ner alla insamlade händelser.
  --
  alter persistent cache download feed;
  --
  -- Uppdatera innehållet i två tabeller med den standardstrategi som är konfigurerad
  -- för tabellen.
  --
  -- Även med stora volymer och tillräcklig disk-I/O-kapacitet
  -- tar det här steget i allmänhet mindre än 1 minut.
  --
  alter persistent cache table exactonlinerest.salesinvoice.salesinvoicelines refresh;
  alter persistent cache table exactonlinerest.salesinvoice.salesinvoices refresh;
  --
  -- Eller använd följande sats, som gör en fullständig nedladdning av alla tabeller där
  -- trickle loading inte är konfigurerat. Och använder trickle loading för de tabeller där trickle
  -- loading är konfigurerat.
  --
  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.