Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Statusstatus

Ressources

  • Xxx
Page Properties
hiddentrue
id
DONE

colour
Product Version
Yellow
titlePROGRESS
Priority1
Note
AssigneeAntje

Report Notepresentable
Assignee

Resources & Remarks

  • concept article linking to the respective tutorials

Modification History

NameDateProduct VersionAction
Antje08 FEB 20212.4New page properties macro.



Excerpt

System Hooks, that allow for messaging triggered by function calls under specified conditions.

...

The AMQP Hooks allow for asynchronous reactions to events like object creation, update or deletion. There are different types of AMQP Hooks available, each of them specialized for selected function calls. The messages contain the properties of the object (question)metadata which object metadata which is the target of the function call triggering the AMQP Hook. The action code is included in the message as well as the history code that is added to the audit trail. The AMQP Hook can be triggered by any endpoint that induced the characteristic history codes of the AMQP Hook.

AMQP Hook Configuration

Parameters

The AMQP configuration is located in the amqp key under the systemhooks top-level key. It is represented as a list of one or more System Hooks whose parameters are described in the table below:

...

Parameter

Types of AMQP Hooks

AMQP Hook Type

Description

enable
booleanis this configuration active/enabled
predicate
string

condition that specifies when the system hook is used
supported scripting languages: SpEL (Spring Expression Language) and Javascript. 

type
stringdefines the processing step for which the system hook is to be used
url
stringAMQP server endpoint, e.g. 127.0.0.1:5672
user
stringusername for the AMQP server
password
stringpassword for the AMQP server
queue
stringname of the queue to which the messages are written
bulkSize
integermaximum bulk size for a message

Example Configuration

...

Action / History Codes
Object deletion events can trigger this AMQP Hook with the corresponding object properties in its body.200 - OBJECT_DELETED
202 - OBJECT_FLAGGED_FOR_DELETE

Object creation events can trigger this AMQP Hook with the corresponding object properties in its body.

101 - OBJECT_CREATED_WITH_CONTENT
100 - OBJECT_CREATED

dms.response.update

Object update events and tag operations can trigger this AMQP Hook with the corresponding object properties in its body.

300 - OBJECT_METADATA_CHANGED
301 - OBJECT_DOCUMENT_CHANGED
325 - OBJECT_RESTORED_FROM_VERSION (as of 2022 Spring)
303 - OBJECT_UPDATE_CONTENT_MOVED
110 - OBJECT_TAG_CREATED
310 - OBJECT_TAG_UPDATED
210 - OBJECT_TAG_DELETED

Configuring AMQP Hooks

As a type of system hooks, AMQP Hooks are configured in the \service-manager\config\system\systemHookConfiguration.json configuration file, multiple AMQP Hooks can be defined in a list called amqp. It must however be observed that only one messaging queue can be used. The messaging queue specified for the first defined AMQP Hook will apply to all following AMQP Hook definitions as well. Of course, the messaging system needs to support AMQP 1.0. Any changes to the AMQP Hook configuration require a restart of the API-gateway service.

The example code below configures an AMQP Hook triggered by a document import. This configuration has exactly one System Hook, which is an AMQP Hook of the type object.insert.document. If the evaluation of the predicate for a document on import results is true (in our example only for compound documents), the API-gateway service sends a message with the metadata of the document to the defined messaging system. In addition, the configuration specifies a bulkSize of 10, i.e. for a batch import of 100 documents matching the predicate, 10 messages with 10 metadata entries per message are written to the queue named lc.textextraction.

Code Block
titlesystemHookConfiguration.json
linenumberstrue
{
    "systemhooks": {
        "amqp": [
            {
                "enable": true,
                "predicate": "spel:(contentStreams != null && contentStreams.size() > 0 && contentStreams[0]['range'] != null && contentStreams[0]['range'].length() > 0) ? true : false",
                "type": "object.insert.document",
                "url": "127.0.0.1:5672",
                "user": "admin",
                "password": "admin_pwd",
                "queue": "lc.textextraction",
                "bulkSize": 10
            }
        ]
    }
}

Activating the AMQP Hook

In our example of asynchronous full-text indexing, the API-gateway service is responsible for evaluating the system hook. To apply the configuration, the API-gateway service must be restarted after saving the configuration file. Messages will then be send to the messaging system (question) haben wir hier was zur Installation for the import of compound documents.

Types of AMQP Hooks

...

 configuration file within the service manager in JSON format. Any changes to the system hook configuration will not apply until the affected services have been restarted.

>> systemHookConfiguration.json

Summary

In this article, we gave an introduction to AMQP Hooks, covered the configuration using the example of asynchronous full text indexing and provide a list of all AMQP Hooks available. Check out Webhooks which are the second type of System Hooks in yuuvis® Momentum.

...