Table of Contents
Introduction
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).
Requirements
This tutorial requires:
- Basic knowledge of importing documents
- A messaging system supporting AMQP 1.0
Table of Contents
Introduction
With an AMQP system hook, messages are sent to a configured messaging system using Advanced Message Queuing Protocol 1.0. Where and when these messages are sent is defined in the system hook configuration.
System hooks are configured in the file \service-manager\config\system\systemHookConfiguration.json
in json format. 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
We configure an AMQP system hook to send messages to a messaging system when importing compound documents. For this we use the following configuration:
systemHookConfiguration.json
1 |
|
For AMQP, this configuration has exactly one system hook of type object.insert.document
relevant to the API-Gateway. If the evaluation of the predicate for a document on import results in 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
In our example of asynchronous full-text indexing, the API-Gateway is responsible for evaluating the system hook. To apply the configuration, the API-Gateway must be restarted after saving the configuration file. Messages will then be send to the messaging system for the import of compound documents.
Conclusion
In this tutorial, we covered the AMQP system hook configuration using the example of asynchronous full text indexing.
Subsection(s)
for (int i = 0; i < 10; i++) { System.out.println("Hello World " + i); }