Use Webhook to subscribe events

Webhook usage process

Configuration:

  1. # Webhook HTTP payload listening port
  2. eventMesh.server.http.port=10105
  3. # Webhook config admin port
  4. eventMesh.server.admin.http.port=10106
  5. # Whether to start the Webhook admin service
  6. eventMesh.webHook.admin.start=true
  7. # Webhook event configuration storage mode. But currently only supports file and nacos
  8. eventMesh.webHook.operationMode=file
  9. # The file path of fileMode. If you write #{eventMeshHome}, in the eventMesh root directory
  10. eventMesh.webHook.fileMode.filePath= #{eventMeshHome}/webhook
  11. # The nacos storage mode. The configuration naming rule is eventMesh.webHook.nacosMode.{nacos native configuration key} For the specific configuration, please see [nacos github api](https://github.com/alibaba/nacos/blob/develop/api/src/main/java /com/alibaba/nacos/api/SystemPropertyKeyConst.java)
  12. ## address of nacos
  13. eventMesh.webHook.nacosMode.serverAddr=127.0.0.1:8848
  14. # Webhook CloudEvent sending mode. This property is the same as the eventMesh.storage.plugin.type configuration.
  15. eventMesh.webHook.producer.connector=standalone

The second step: Add Webhook configuration information

Configuration information description:

  1. /**
  2. * The path called by the manufacturer. Manufacturer event call address, [http or https]://[domain or IP]:[port]/webhook/[callbackPath]
  3. * for example: http://127.0.0.1:10105/webhook/test/event , The full url needs to be filled in the manufacturer call input
  4. * callbackPath is the only
  5. */
  6. private String callbackPath;
  7. /**
  8. * manufacturer name, like github
  9. */
  10. private String manufacturerName;
  11. /**
  12. * manufacturer domain name, like www.github.com
  13. */
  14. private String manufacturerDomain;
  15. /**
  16. * Webhook event name, like rep-push
  17. */
  18. private String manufacturerEventName;
  19. /**
  20. * http header content type
  21. */
  22. private String contentType = "application/json";
  23. /**
  24. * description of this WebHookConfig
  25. */
  26. private String description;
  27. /**
  28. * secret key, for authentication
  29. */
  30. private String secret;
  31. /**
  32. * userName, for HTTP authentication
  33. */
  34. private String userName;
  35. /**
  36. * password, for HTTP authentication
  37. */
  38. private String password;
  39. /**
  40. * roll out event name, like topic to mq
  41. */
  42. private String cloudEventName;
  43. /**
  44. * roll out data format -> CloudEvent serialization mode
  45. * If HTTP protocol is used, the request header contentType needs to be marked
  46. */
  47. private String dataContentType = "application/json";
  48. /**
  49. * id of cloudEvent, like uuid/manufacturerEventId
  50. */
  51. private String cloudEventIdGenerateMode;

Add WebHook config

path: /webhook/insertWebHookConfig

method: POST

contentType: application/json

input params:

fielddesctypenecessarydefault
callbackPathcall address, unique addressstringYnull
manufacturerNamemanufacturer namestringYnull
manufacturerDomainmanufacturer domain namestringYnull
manufacturerEventNamemanufacturer event namestringYnull
contentTypehttp connettypestringNapplication/json
descriptionconfiguration instructionsstringNnull
secretsignature stringstringNnull
userNameusernamestringNnull
passwordpasswordstringNnull
cloudEventNamecloudEvent namestringYnull
cloudEventIdGenerateModecloudEvent event object identification method, uuid or event idstringNmanufacturerEventId

E.g:

  1. {
  2. "callbackPath":"/webhook/github/eventmesh/all",
  3. "manufacturerName":"github",
  4. "manufacturerDomain":"www.github.com",
  5. "manufacturerEventName":"all",
  6. "cloudEventName":"github-eventmesh"
  7. }

Output params: 1 for success, 0 for failure

Query WebHook config by callback path

path: /webhook/queryWebHookConfigById

method: POST

contentType: application/json

input params:

fielddesctypenecessarydefault
callbackPathcall address, unique addressstringYnull
manufacturerNamethe caller of this callbackPath belongs tostringYnull

E.g:

  1. {
  2. "callbackPath":"/webhook/github/eventmesh/all",
  3. "manufacturerName":"github"
  4. }

Output params:

fielddesctypenecessarydefault
callbackPathcall address, unique addressstringYnull
manufacturerNamemanufacturer namestringYnull
manufacturerDomainmanufacturer domain namestringYnull
manufacturerEventNamemanufacturer event namestringYnull
contentTypehttp connettypestringNapplication/json
descriptionconfiguration instructionsstringNnull
secretsignature keystringNnull
userNameuser namestringNnull
passwordpasswordstringNnull
cloudEventNamecloudEvent namestringYnull
cloudEventIdGenerateModecloudEvent event object identification method, uuid or event idstringNmanufacturerEventId

Query WebHook config by manufacturer

path: /webhook/queryWebHookConfigByManufacturer

method: POST

contentType: application/json

input params:

fielddesctypenecessarydefault
manufacturerNamemanufacturer namestringYnull
pageNumpage number of paging querystringYnull
pageSizepage size of each pagestringYnull

E.g:

  1. {
  2. "manufacturerName":"github",
  3. "pageNum":1,
  4. "pageSize":2
  5. }

Output params:

fielddesctypenecessarydefault
callbackPathcall address, unique addressstringYnull
manufacturerNamemanufacturer namestringYnull
manufacturerDomainmanufacturer domain namestringYnull
manufacturerEventNamemanufacturer event namestringYnull
contentTypehttp connettypestringNapplication/json
descriptionconfiguration instructionsstringNnull
secretsignature keystringNnull
userNameuser namestringNnull
passwordpasswordstringNnull
cloudEventNamecloudEvent namestringYnull
cloudEventIdGenerateModecloudEvent event object identification method, uuid or event idstringNmanufacturerEventId

Update WebHook config

path: /webhook/updateWebHookConfig

method: POST

contentType: application/json

input params:

fielddesctypenecessarydefault
callbackPathcall address, unique addressstringYnull
manufacturerNamemanufacturer namestringYnull
manufacturerDomainmanufacturer domain namestringYnull
manufacturerEventNamemanufacturer event namestringYnull
contentTypehttp connettypestringNapplication/json
descriptionconfiguration instructionsstringNnull
secretsignature stringstringNnull
userNameusernamestringNnull
passwordpasswordstringNnull
cloudEventNamecloudEvent namestringYnull
cloudEventIdGenerateModecloudEvent event object identification method, uuid or event idstringNmanufacturerEventId

E.g:

  1. {
  2. "callbackPath":"/webhook/github/eventmesh/all",
  3. "manufacturerName":"github",
  4. "manufacturerDomain":"www.github.com",
  5. "manufacturerEventName":"all",
  6. "cloudEventName":"github-eventmesh"
  7. }

Output params: 1 for success, 0 for failure

Delete WebHook config

path: /webhook/deleteWebHookConfig

method: POST

contentType: application/json

input params:

fielddesctypenecessarydefault
callbackPathcall address, unique addressstringYnull
manufacturerNamethe caller of this callbackPath belongs tostringYnull

E.g:

  1. {
  2. "callbackPath":"/webhook/github/eventmesh/all",
  3. "manufacturerName":"github"
  4. }

Output params: 1 for success, 0 for failure

The third step: Check if the configuration is successful

  1. file storage mode. Please go to the eventMesh.webHook.fileMode.filePath directory to view. The Filename is callbackPath.
  2. nacos storage mode. Please go to the nacos service configured by eventMesh.webHook.nacosMode.serverAddr to see this.

The fourth step: Configure the consumer of cloudevent

For manufacturer’s operation, please refer to Manufacturer’s Webhook operation instructions.

Manufacturer’s Webhook operation instructions

GitHub sign up

The first step: Enter the corresponding project

The second step: click setting

Use Webhook to subscribe events - 图1

The third step: click Webhooks

Use Webhook to subscribe events - 图2

The fourth step: Click on Add Webhook

Use Webhook to subscribe events - 图3

The fifth step: Fill in the Webhook information

Use Webhook to subscribe events - 图4

Payload URL: EventMesh service address and callbackPath, which must include the protocol header. For example, when the callback address callbackPath is /webhook/github/eventmesh/all, the Payload URL is http://www.example.com:10105/webhook/github/eventmesh/all.

[http or https]://[domain or IP]:[port]/webhook/[callbackPath]

Content type: http header content type

Secret: signature string