Skip to content

Publisher

Publishers are used to send data to external systems. JMC Base includes a webhook publisher that can be configured based on the needs of the consuming service.

All published data is staged to the device that originated it, then SymmetricDS will move it to the corp instance where the publisher application will then queue the published item for each subscriber to that topic.

All publishers will publish items individually and expect consumers to process them as such.

Configuration

A publisher application will need to be deployed to handle publishing. This is done by creating a new container with publisher-base. This project will contain the data load for pubeng_subscriber and pubeng_subscriber-webhook.

Database

The publisher application is expected to connect to the corp database and be able to create tables and read, write, and delete data for the tables it manages.

Subscriber

The subscriber defines a subscription to a specific topic and what subscriberType it is. The default and supported subscriberType is webhookSubscriber. This would also then require an entry in the subscriber webhook table.

The webhook configuration requires:

Field Description Default
url URL used to send the payload.
http_method HTTP Method that will be used to send the payload.
request_strategy Definition of how to build the HTTP request. This can give access to adjust headers, body, etc. DefaultRequestStrategy
response_strategy Definition of how to handle the response from the webhook. DefaultResponseStrategy

DefaultRequestStrategy

To build requests the default strategy will only set the Content-Type header to application/json and the body.

DefaultResponseStrategy

For responses the default strategy is to account for all errors and handle successes.

Response Scenario Outcome
2xx Success
4xx Mark as failed and do not retry
5xx Retry if the max attempts has not been passed, otherwise mark as failed and do not retry.
Unexpected Exception Retry if the max attempts has not been passed, otherwise mark as failed and do not retry.

Diagrams

Flow of data being queued and published to subscribers

sequenceDiagram
    POS Device ->> POS Device: Publish new sale, inventory, etc.
    POS Device ->> Business Unit: Symmetric DS Sync staged data
    Business Unit ->> Corp: Symmetric DS Sync staged data
    create participant Publisher
    Corp ->> Publisher: Queue staged data
    loop while new staged data exists
        Publisher ->> Publisher: Queue staged data for all subscribers
        Publisher ->> Publisher: Removed staged data that has been queued
    end
    loop for each queued item
        create actor Webhook Subscriber
        Publisher ->> Webhook Subscriber: Send data to subscriber
        destroy Webhook Subscriber
        Webhook Subscriber ->> Publisher: Acknowledge data received
    end
    destroy Publisher
    Publisher ->> Corp: Removed staged data that has been queued
    Corp ->> Business Unit: Symmetric DS Removed old staged data
    Business Unit ->> POS Device: Symmetric DS Removed old staged data

Deployment

Publisher requires a separate deployment from the corp commerce deployment. This will contain the database load scripts for configuring subscribers.

The publisher-base project should then contain the same zipArchive project configurations as commerce and can be bundled into a Docker container with that and deployed via helm.