Introducing Payload Vault project Part-1

Overview


The aim of this project is to create a Payload Vault where we can store payloads whenever they are generated or received. For instance, when initiating an API call, we can record both the request sent and the response received, capturing this information for investigative purposes. The Payload Vault also enables us to utilize stored payloads to reprocess transactions when necessary. We will also create a UI to visualize the payload stored in the database and we can keep track of the number of transactions processed.

This project is divided into different parts and we will keep uploading them one by one, once this project is completed, you will get the link to download the source code.

Check out the full project :


Prerequisite


  •  Basics of DSP page, click here to check out our article on DSP page.
  • Basics of JDBC adapter.
  • Basics of flow service.

Architecture


We will design this as an asynchronous model, considering the risk that the database may become unavailable. To ensure that transactions are not failed due to database issues, we will populate payload details and enqueue them into a JMS Queue. Subsequently, a trigger will subscribe to these events and load them into the database. In case the subscriber encounters any failure, audit logging will be implemented to facilitate the reprocessing of transactions from MWS. Please find the high-level architecture diagram below.

We will implement a scheduler to perform housekeeping tasks on transactions stored in the database after a specified number of days. The duration for retaining transactions can be configured using a global variable.

Package Structure


Create a package with the below package structure where we will write our services related to this project.

  • HG_PayloadVault
    • v1
      • Common
        • adapter
        • doc
        • subService
      • PayloadVault_pub
        • adapter
        • doc
        • subService
      • PayloadVault_Sub
        • adapter
        • doc
        • subService
      • UI
        • adapter
        • doc
        • subService

UI Creation


  • Navigate to the pub directory of your package in the backend file system and create a file named index.dsp.
    Ex – C:\SoftwareAG\IntegrationServer\instances\default\packages\HG_PayloadVault\pub
  • Copy below HTML script and put it into the index.dsp file.
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Payload Vault</title>
        <style>
            body {
                font-family: Arial, sans-serif;
                margin: 0;
                padding: 0;
                background-color: #f2f2f2;
            }
            header {
                background-color: #3e7eb0; 
                color: white;
                padding: 20px;
                display: flex;
                justify-content: center;
                align-items: center;
            }
            header img {
                max-width: 160px;
                height: 40px;
                margin-right: auto; /* Pushes the logo to the right */
            }
            h1 {
                margin: 0;
                text-align: center;
                flex-grow: 1; /* Allows the title to take remaining space */
            }
            table {
                width: 80%;
                border-collapse: collapse;
                border-radius: 8px;
                overflow: hidden;
                box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
                margin: 20px auto;
                background-color: #f9f9f9; /* Light gray */
            }
            th, td {
                border: 1px solid #ddd;
                padding: 15px;
                text-align: left;
            }
            th {
                background-color: #4CAF50; /* Green */
                color: white;
            }
            tbody tr:hover {
                background-color: #f5f5f5;
            }
        </style>
    </head>
    <body>
        <header>
            <img src="image\harmonigate.png" alt="Harmonigate.com">
            <h1>Payload Vault</h1>
        </header>
        <table>
            <thead>
                <tr>
                    <th>Interface ID</th>
                    <th>Source</th>
                    <th>Target</th>
    				<th>Interface Name</th>
                    <th>Document Type</th>
                    <th>Document Name</th>
                    <th>Inserted Date</th>
    				<th>Tracking ID</th>
    				<th>Payload Count</th>
                </tr>
            </thead>
            <tbody>
    			<tr>
    				<td>Data 1</td>
    				<td>Data 2</td>
    				<td>Data 3</td>
    				<td>Data 4</td>
    				<td>Data 5</td>
    				<td>Data 6</td>
                    <td>Data 7</td>
                    <td>Data 8</td>
                    <td>Data 9</td>
    			</tr>
                <!-- Add more rows as needed -->
            </tbody>
        </table>
    </body>
    </html>
    

     

  • Navigate to the below URL to view the UI that we have created.
    Url : http://host:port/HG_PayloadVault/index.dsp

Database setup


We are planning to store the payload in a database, so we need to create a table in the database. For this project, we’ll be using a MySQL database, but if you’re using a different database, you can apply the same process.

Execute the below query in your MySql database to create the required table.

CREATE TABLE PAYLOADVAULT (
    DOCUMENTID INT AUTO_INCREMENT PRIMARY KEY,
	INTERFACE_ID VARCHAR(50),
	SOURCE VARCHAR(50),
	TARGET VARCHAR(50),
	INTERFACE_NAME VARCHAR(50),
	TRACKING_ID VARCHAR(50),
	DOCUMENT_TYPE VARCHAR(50),
    DOCUMENT_NAME VARCHAR(100),
	INSERTED_DATE TIMESTAMP,
	TRANSACTION_ID VARCHAR(50),
	IDENTIFIER1 VARCHAR(50),
	IDENTIFIER2 VARCHAR(50),
	IDENTIFIER3 VARCHAR(50),
	IDENTIFIER4 VARCHAR(50),
    PAYLOAD BLOB
);

In the next article, we will focus on creating JMS publisher and subscriber service which will load the data into database. Stay tuned.

Leave a Comment