Page Properties | Status | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Status | ||||||||||||||
colour | Yellow | |||||||||||||
title | PROGRESS | |||||||||||||
Priority | 1 | |||||||||||||
Note | content in tutorial System Hooks | |||||||||||||
Assignee | Antje | |||||||||||||
Page Properties | ||||||||||||||
| ||||||||||||||
Resources & Remarks
Modification History
|
Excerpt |
---|
System Hooks, that allow for messaging triggered by function calls under specified conditions. |
Section | ||||||
---|---|---|---|---|---|---|
| ||||||
|
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 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.
...
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
...
predicate
...
Condition that specifies when the system hook is used. Supported scripting languages: Spring Expression Language (SpEL) und Javascript.
...
type
...
url
...
user
...
password
...
queue
...
bulkSize
...
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
{
"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
}
]
}
}
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
...
Any changes to the System Hook configuration will not apply until the affected services have been restarted.
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 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.
Types of AMQP Hooks
AMQP Hook Type | Description | 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 | |
Object update events and tag operations can trigger this AMQP Hook with the corresponding object properties in its body. | 300 - OBJECT_METADATA_CHANGED |
Configuring AMQP Hooks
As a type of system hooks, AMQP Hooks are configured in the \service-manager\config\system\systemHookConfiguration.json
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
...
Subsection(s)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
for (int i = 0; i < 10; i++)
{
System.out.println("Hello World " + i);
} |
...
and provide a list of all AMQP Hooks available. Check out Webhooks which are the second type of System Hooks in yuuvis® Momentum.
Info | ||||||
---|---|---|---|---|---|---|
| ||||||
Read on
|
...
Another Tutorial
...
width | 25% |
---|
Another interesting Tutorial
...
|
...
Another Concept Article
Brief summary of the article linked.
|