DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Microservices With .NET Core: Building Scalable and Resilient Applications
  • Self-Hosted Gateway Design Patterns Discussion
  • Integrating Pub/Sub With MuleSoft
  • How To Make a Windows Keylogger By Yourself

Trending

  • The Modern Data Stack Is Overrated — Here’s What Works
  • Rethinking Recruitment: A Journey Through Hiring Practices
  • Segmentation Violation and How Rust Helps Overcome It
  • Doris: Unifying SQL Dialects for a Seamless Data Query Ecosystem
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Generic and Dynamic API: MuleSoft

Generic and Dynamic API: MuleSoft

This article demonstrates the definition of a generic and dynamic data model that can be used for various publisher-generated events.

By 
Ankur Bhuyan user avatar
Ankur Bhuyan
·
Dec. 11, 24 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
3.8K Views

Join the DZone community and get the full member experience.

Join For Free

Requirements

An organization's employee journey will involve a number of events, some of which need to be updated in various systems within the company.

Workday will notify downstream systems, such as D365, DocuSign, and Salesforce, of events such as: ON_BOARDING, OFF_BOARDING, DEPARTMENT_CHANGE, OFFICE_LOCATION, MANAGER_CHANGE, and INDIVIDUAL_LEAVE.

Some of the events on the list are necessary for particular downstream systems, while others are not. Here, learn how to design a flow that can guarantee 100% delivery to the necessary systems.

Generic Data Model

A generic data model is as follows:

  • A set of data that can be reused across systems for various reasons
  • It offers relation types that are standardized.
  • Any object can be classified using generic data models, and part-whole relations can be specified for any object
  • An infinite number of facts can be expressed by generic data models

Dynamic Data Model

Consistency within an organization can be ensured by sharing dynamic data between platforms and departments. A flexible data structure is one that doesn't have to be predefined in a strict schema and can change to accommodate evolving needs or data kinds.

Workday Events

Workday can generate a number of events related to an employee. For example, ON_BOARDING, OFF_BOARDING, DEPARTMENT_CHANGE, OFFICE_LOCATION, MANAGER_CHANGE, INDIVIDUAL_LEAVE, etc.

Based on downstream system requirements (i.e., D365, DocuSign, Salesforce), they can adapt all the events or part of the events.

To design a generic, dynamic, simple, and easily adaptable data model, workday publishes events with the same message structure:

  1. action
  2. companyCode
  3. employeeId
  4. email
  5. customField1, customField2, etc.

Event Data Model

Event Data Model

Examples

Onboarding Event

JSON
 
{      
    "action": "ON_BOARDING",        
    "companyCode": "ANKURAN",      
    "employeeId": "ABC125",    
    "email": "bhuyan@ankur-online.com",
    "customField1": {      
        "Name": "firstName",        
        "Value": "Ankur"        
    },      
    "customField2": {      
        "Name": "lastName",    
        "Value": "Bhuyan"      
    },      
    "customField3": {      
        "Name": "status",      
        "Value": "Active"      
    }      
}


Offboarding Event

JSON
 
{
    "action": "OFF_BOARDING",
    "companyCode": "ANKURAN",
    "employeeId": "ABC125",
    "email": "bhuyan@ankur-online.com",
    "customField1": {
        "Name": "status",
        "Value": "Close"
    },
    "customField2": {
        "Name": "terminationDate",
        "Value": "21-08-2024"
    }
}


Individual Leave

JSON
 
{
    "action": "INDIVIDUAL_LEAVE",
    "companyCode": "ANKURAN",      
    "employeeId": "ABC125",    
    "email": "bhuyan@ankur-online.com",
    "customField1": {
        "Name": "managerId",
        "Value": "XYZ123"
    },
    "customField2": {
        "Name": "managerEmail",
        "Value": "manager@ankur-online.com"
    },
    "customField3": {
        "Name": "leaveType",
        "Value": "private"
    },
    "customField4": {
        "Name": "effectiveDate",
        "Value": "21-08-2024"
    },
    "customField5": {
        "Name": "durationInHour",
        "Value": "8"
    }
}


Solution Design

Solution Design

Workday Experience API

Capture the "action" from workday input data and add as anypoint-mq:properties along with "correlationId" while publishing.

XML
 
<sub-flow name="update-user" doc:id="3e7ee53b-be64-45e9-93c8-c2fc1cf71a52">
    <ee:transform doc:name="Prepare request parameter" doc:id="3ed4576c-6234-4053-b23e-c80a3733d53e" >
        <ee:variables >
            <ee:set-variable variableName="userProperties" >
                <![CDATA[%dw 2.0 
output application/java
---
{
	"correlationId" : vars.baselogger.correlationId default "",
	"action" : payload.action default ""
}]]>
            </ee:set-variable>
        </ee:variables>
    </ee:transform>
    <logger level="INFO" doc:name="INFO : Published data" doc:id="33b3a36c-4cce-4133-885d-fa90e5265318" message="Published data : #[payload]"/>
    <logger level="INFO" doc:name="INFO : Published user properties" doc:id="82252294-19a3-4bdb-af58-b0409348198d" message="Published user properties : #[vars.userProperties]"/>
    <anypoint-mq:publish doc:name="Publish to X-USER-DEACTIVATE" doc:id="8fd1aebc-93e8-4d30-a77a-4dae339f7d27" config-ref="Anypoint_MQ_Config" destination="${anypoint.exchange}">
        <anypoint-mq:body >
            <![CDATA[#[%dw 2.0
output application/json
---
payload]]]>
        </anypoint-mq:body>
        <anypoint-mq:properties >
            <![CDATA[#[vars.userProperties]]]>
        </anypoint-mq:properties>
    </anypoint-mq:publish>
</sub-flow>


Anypoint MQ Exchange Configuration

Configure the routing rules based on user properties. For example: action.

Based on configured rules the data will be filtered/routed to respective downstream systems.

Anypoint MQ Exchange Configuration

Matcher Configuration

Property Type: String

  • Equals: The value in this rule exactly matches the value in the message property.
  • Prefix: The value in this rule is the first value in the message property.
  • Any of: Any of the values in this rule correspond to the value of the message property.
  • None of: None of the values in this rule correspond to the value of the message property.
  • Exists: A property in the message has the same name as the property in this rule.

Property Type: Number

  • Equals: The value in this rule is equivalent to the value of the message property.
  • Less than: The value in the message property is lower than the value in this rule.
  • Less than or equal: The value in the message property is lower than or equal to the value in this rule.
  • Greater than: The value in the message property is greater than the value in this rule.
  • Greater than or equal: The value in the message property is greater than or equal to the value in this rule.
  • Range: The value of the message property falls into the range of values allowed by this rule.
  • None of: None of the values in this rule correspond to the value of the message property.
  • Exists: A property in the message has the same name as the property in this rule.

Conclusion

The purpose of this article is to demonstrate the definition of a generic and dynamic data model that can be used for various publisher-generated events. Both the source and destination systems must agree on the specified data model in order to implement this strategy.

Adopting this event-driven strategy can be simple, and the organization's development effort can be decreased without relying on one another.

Recognize how to configure rules on message exchanges in Anypoint MQ to route messages.

API Data (computing) Downstream (software development) Event MuleSoft

Opinions expressed by DZone contributors are their own.

Related

  • Microservices With .NET Core: Building Scalable and Resilient Applications
  • Self-Hosted Gateway Design Patterns Discussion
  • Integrating Pub/Sub With MuleSoft
  • How To Make a Windows Keylogger By Yourself

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!