Creatio development guide
PDF
This documentation is valid for Creatio version 7.10.0. We recommend using the newest version of Creatio documentation.

ClientMessageBridge . Message history save mechanism

Glossary Item Box

General information

In a best-case scenario a handler is located within the system at the time of publication of the message (Fig. 1).

Fig. 1.  Perfect interaction mechanism

However, there may be situations when a handler is not yet loaded (Fig. 2).

Fig. 2. The process of interaction with an absent handler

In order to not lose unprocessed messages, you can wait for a listener before publication. If a listener is absent, the messages are saved in history. Before publication, each message is checked for a listener. When the listener is loaded, all stored messages are published in the order they were received. After the messages have been published, the history is cleared.

Configuring the processing of messages stored in the history example

To implement the described feature, you have to set the isSaveHistory checkbox to true.

init: function() {
   // Calling the init() parent method.
   this.callParent(arguments);
   // Adding a new configuration object to the configuration object collection.
   this.addMessageConfig({
       // sender — name of the message received via WebSocket.
       sender: "OrderStepCalculated",
       // Name of the message sent within the system.
       messageName: "OrderStepCalculated",
       // isSaveHistory — checkbox indicating that the history must be saved.
       isSaveHistory: true
    });
},

History saving mechanism

The ClientMessageBridge class is the heir of the BaseMessageBridge abstract class, which contains abstract methods (saveMessageToHistory, getMessagesFromHistory, deleteSavedMessages). In ClientMessageBridge message history saving is implemented with the use of the localStorage of the browser, and the implementation of abstract methods enables you to manipulate data in storage. To work with the localStorage class, use the Terrasoft.LocalStore class.

Methods:

  • saveMessageToHistory — ensures that new messages are saved in the message collection
  • getMessagesFromHistory — provides an array of messages based on the transferred name
  • deleteSavedMessages — deletes all messages based on the transferred name

If there is a need to implement another type of storage, you must create an heir class of the BaseMessageBridge class and implement all abstract methods (saveMessageToHistory, getMessagesFromHistory, deleteSavedMessages).

 

© bpm'online 2002-2017.

Did you find this information useful?

How can we improve it?