Skip to content

Publisher (Deprecated)

This publisher has been deprecated and replaced with the Webhook Publisher.

Publisher allows for external consumers to receive transactions from Commerce.

Publishers rely on a job to read events from a simple queue and push the payload out through a configured publisher implementation. The default configuration is to run the job and publish the messages from the Central Office but it can also be configured to publish from the store.

Config

Currently there are 3 services that publish events using a specific job bean and specific event types.

Event Type Codes

Event type are specific to the message being published. These messages and their definitions can be found in the swagger api Webhook definition.

Commerce

The Commerce publisher uses the transPublishJob bean and needs to be created and configured in the Commerce App with the type of publisher to use and the MessageTypeCode to be sent.

  jobs:
    schedule:
      transPublisher:
        beanName: transPublishJob
        enabled: true
        type: periodic
        initialDelayInMs: 5000
        expression: 5000
    config:
        transPublisher:
            publisher: webhookPublisher
            messageTypeCode: ORDER

Inventory

The Inventory publisher uses the inventoryTransPublishJob bean and needs to be created and configured in the Inventory App with the type of publisher to use.

jobs:
    enabled: true
    schedule:
        publishInventory:
            beanName: inventoryTransPublishJob
            enabled: true
            type: periodic
            initialDelayInMs: 5000
            expression: 60000
    config:
        publishInventory:
            publisher: webhookPublisher

Clienteling

The Clienteling publisher uses the clientelingPublishJob bean and needs to be created and configured in the Clienteling App with the type of publisher to use.

jobs:
    enabled: true
    schedule:
        publishClienteling:
            beanName: clientelingPublishJob
            enabled: true
            type: periodic
            initialDelayInMs: 5000
            expression: 60000
    config:
        publishClienteling:
            publisher: webhookPublisher

Supported Publisher Implementations

Webhook

openpos.jobs.config.%s.publisher=webhookPublisher

The webhook publisher provides an out of the box PubSub mechanism that doesn't require and external message bus. To use the webhook entries need to be added to ctx_webhook_subscriber to subscribe a rest endpoint for a particular EventTypeCode. The EventTypeCode is send as an http header eventTypeCode and the body is the json serialized payload.

Azure Service Bus

openpos.jobs.config.%s.publisher=serviceBusPublisher

The service bus publisher utilizes Azure service bus to transmit the messages.

openpos:
  azure:
    serviceBus:
      compressionEnabled: true
      publishIndividually: false
      <jobName>:
        transQueueName: <queueName>
        connectionString: <connectionString>

Log

openpos.jobs.config.%s.publisher=logPublisher

The log publisher is primarily use for development purposes and just publishes the message to the log output.

Extending

New publishers are easily added by creating a bean that implements IPublisher.

public interface IPublisher {
    /**
     * Publish messages.
     *
     * @param jobName Name of Job that invoked publisher
     * @param toPublish Messages to Publish
     * @return List of Messages that were published
     */
    List<PublishableItem> publish(String jobName, List<PublishableItem> toPublish);
}