...
Section | ||||||
---|---|---|---|---|---|---|
| ||||||
|
Introduction
AMQP stands for Advanced Message Queuing Protocol 1.0, which is the encoding scheme the AMQP Hooks are working with. AMQP Hooks are used to generate messages for the AMQP messaging systems whenever any relevant function is performed. They're instantiated using the URL and credentials for an existing messaging queue. The process flow itself is proceeding at the same time and can not be modified with an AMQP Hook.
Any changes to the AMQP Hook configuration require a restart of the API Gateway.
Main part(s)
This tutorial shows how to set up an AMQP system hook to generate a message when importing a document. We’ll go through an example in which we’ll configure a system hook that sends messages to a messaging system to perform an asynchronous full-text indexing (more about asynchronous full-text indexing can be found here).
Introduction
With an AMQP Hook, messages are sent to a configured messaging system using Advanced Message Queuing Protocol 1.0 (AMPQ). Where and when these messages are sent is defined in the System Hook configuration.
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 | Type | Description |
---|---|---|
enable | boolean | Is this configuration active/enabled? |
predicate | string | Condition that specifies when the system hook is used. Supported scripting languages: Spring Expression Language (SpEL) und Javascript. |
type | string | Defines the processing step for which the system hook is to be used. |
url | string | AMQP server endpoint, e.g. 127.0.0.1:5672. |
user | string | Username for the AMQP server. |
password | string | Password for the AMQP server. |
queue | string | Name of the queue to which the messages are written. |
bulkSize | integer | Maximum bulk size for a message. |
Configuring the AMQP System Hook
...
Example Configuration
The configuration of an AMQP Hook is shown together with an examplary document import. The AMQP hook should send messages to a messaging system when importing compound documents, to perform an asynchronous full-text indexing (more about asynchronous full-text indexing can be found here). For this we use purpose, the following configuration is used. Of course, a the messaging system needs to support AMQP 1.0. Any changes to the AMQP Hook configuration require a restart of the API Gateway.
Code Block | ||||
---|---|---|---|---|
| ||||
{ "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 } ] } } |
...
This configuration has exactly one
...
System Hook, which is an AMQP Hook of the type object.insert.document
.
...
It is relevant to the API-Gateway. If the evaluation of the predicate for a document on import results is true (in our example only for compound documents), the API-Gateway 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
.
Activating the AMQP System Hook
...