WebSub provides a common mechanism for communication between publishers of any kind of Web content and their subscribers, based on HTTP web hooks. Subscription requests are relayed through hubs, which validate and verify the request. Hubs then distribute new and updated content to subscribers when it becomes available. WebSub was previously known as PubSubHubbub. For more information, read W3C WebSub.
In MOSIP, WebSub is used to share data with services and partners. Kafka message broker has been used to implement the WebSub APIs. Message brokers are a natural fit for the implementation of WebSub hubs as they serve a similar purpose.
The relationship of WebSub with other services is explained here. NOTE: The numbers do not signify sequence of operations or control flow.
Topic is registered and published or subscribed by MOSIP Services.
Content delivery and Intent Verification is done by WebSub to Mosip Services.
Content delivery and Intent Verification is done by WebSub to Partners.
Topic is registered and published or subscribed by the Partners.
Data and metadata needed for delivery, delivery reports and other functionalities are stored in Kafka.
Refer WebSub repo for further details.
To know more about the developer setup, read WebSub Developers Guide.
WebSub module provides a common mechanism for communication between publishers of any kind of Web content and their subscribers, based on HTTP webhooks.
Below is a list of tools required in WebSub:
Ballerina (Swan-Lake)
Any IDE (like Vs Code)
Kafka
Postman (any HTTP Client)
Git
Download Ballerina and install it as per instructions. (Use bal -v
to ensure installation and version).
Download Kafka and install it.
For the code setup, clone the repository and follow the guidelines mentioned in the Code Contributions.
Open the hub and consolidator folders where Ballerina.toml
is present.
Open the command prompt from the same folder.
Run the command bal build
to build the hub and consolidator.
Open the project in VS Code either by open with vs code
or from File -> Open Folder
.
Run Configure and run Kafka, update KAFKA_BOOTSTRAP_NODE
in Config.toml
to point to your Kafka.
WebSub consists of consolidator and hub.
Consolidator should be started first, Got to consolidator -> java -jar target/bin/<Jarname>
. (Config.toml should be in the same place where you are running this command).
Start WebSub with the same approach.
The APIs can be tried with the help of kernel-websub-api.
Copy websub-service.toml
and websub-consolidator.toml
file from mosip-config repository to hub and consolidator folder respectively and rename both of them as Config.toml
(case-sensitive).