CommitCallback and SyncQueue

Goal: Send REST request to an external system whenever a customer Entry is created or modified.

You can download the whole Kickstarter-based sample application from our GitLab repository: um-public/tutorial-syncqueue

Start a new Kickstarter project

umkickstarter -n de.pinuts.tutorial cd umkickstarter # Copy your partner license file to env/devel/cmsbs-conf/cmsbs.license

Include dependency

Edit build.gradle and add the following dependency:

dependencies { [...] runtime('de.pinuts.cmsbs:SyncQueue:1.3.5') }

 

Now, setup and restart:

gradle setup run

Implement and register CommitCallback

Create a new (M)JS file: cmsbs-conf/cse/plugins/de.pinuts.tutorial/shared/CommitCallback.mjs:

Open http://localhost:8080/cmsbs, login as admin / admin and create, edit and delete a Customer entry.

Take a look at the console / shell where you started the UM: For each transaction the according Entry should be logged.

Setup a SyncQueue instance

Create a new file cmsbs-conf/cse/plugins/de.pinuts.tutorial/shared/queue.mjs:

Queue Entry updates

Now that we have a SyncQueue set up and a handler function in place to propagate any Customer updates, we can update our CommitUpdate to actually use the Queue:

Test run

Now, edit or create a Customer entry and go to Tools / SyncQueue Dashboard.

You will notice a waiting (or failed) request for each creation or update operation you did. The HTTP requests will all fail with a 404 because there actually is no endpoint to receive our POST requests.

To make this work, you could implement a REST endpoint as a mockup and change the URL accordingly.