Versions Compared

Key

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


Page Properties


Status

Status
colourYellow
titlePROGRESS

Priority2
Note
AssigneeMax

Ressources

Event = System Hooks (Frage) What is the difference?

Remarks

This tutorial should eventually replace the System Hooks page in this directory, as the content of that page will be moved to a concept page.

Technical Review of Example Webhook Consumer Server needed.

...

Excerpt

An example Webhook consumer service set up using Java and Spring Boot. 


Section
bordertrue


Column

Table of Contents

Table of Contents
exclude(Table of Contents|Read on|Events|Webhooks|Messaging when Importing Documents)


Requirements

In this tutorial, we'll create a Spring Boot Service using Java, meaning the requirements for the project are derived from Spring Boot. Thus, a JDK version 1.8 or later and Maven 3.2 or later are required. 

Setup of the Consumer Service

To implement processing of incoming update metadata using our webhook service, we need to configure an endpoint within a controller class of our Example Webhook Service, in this instance ExampleRestController. The URL we define between the RequestMapping annotation of the controller class and the PostMapping annotation of the endpoint method will need to find its way into the System Hook configuration of our yuuvis® Momentum System. We'll also define a stub method for working with the incoming metadata, which we'll call from within our endpoint method, the Object Map provided by the System Hook. 

Code Block
titleController Class with Endpoint for Webhook Consumption
@RestController
@RequestMapping("/api/dms/request")
public class ExampleRestController
{
    @PostMapping(value = "/update/metadata", produces = {"application/json"})
    public Map<String, Object> updateDmsObjectMetadata(@RequestBody Map<String, Object> dmsApiObjectList, 
                                                       @RequestHeader(value = "Authorization", required = true) String authorization)
    {
        doSomething(dmsApiObjectList, authorization);
        return dmsApiObjectList;
    }
    private void doSomething(Map<String, Object> dmsApiObjectList, String authorization)
    {
        // do something with the metadata
    }
}

Run Configuration

Running the Java application to register the service must include a number of parameters to communicate the services' existance and contact information to the Discovery Service. Find the full list of required parameters below:

NameValueDescription
spring.profile.active<active profiles>Profiles available and running within your system, defining in which Profiles the Interceptor will be active 
spring.cloud.config.uri<protocol>://<config url>URL of the Configuration service endpoint where the service can recieve system information
eureka.instance.prefer-ip-addresstrueDecides whether the Webhook service will register using its host name or its host ip. 
eureka.instance.ip-adress<your host ip>Define host ip, and host base url when used in conjunction with the previous parameter.

Configuring the Webhook

To use the webhook service for the intended purpose of intercepting metadata when updating objects, we need to create a new entry in the Webhook list within our systems' SystemHookConfiguration.json file, whereafter the API gateway (API Service) needs to be restarted.  

Code Block
titleExample SystemHookConfiguration.json
{
  "systemhooks": {
    "webhooks": [
      {
        "enable": true,
        "predicate": "spel:true",
        "type": "dms.request.update.metadata",
        "url": "<your host base url>/api/dms/request/update/metadata",
        "useDiscovery": true
      }
    ]
  }
}

Summary

In this tutorial, a Java-based method for Webhook consumption is outlined. The code presented, including the project structure and additional webhook management, can be found here


Info
iconfalse

Read on

Section


Column
width25%

Events 

Insert excerpt
Events
Events



Column
width25%

Webhooks

Insert excerpt
Webhooks
Webhooks


Column
width25%

Messaging when Importing Documents

Insert excerpt
Messaging when Importing Documents
Messaging when Importing Documents



...