SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
 Validation of data in ESB application at
different layers of message processing is a
requirement which is quite frequent. Often,
the validation logic is implemented at
different layers which is time consuming and
also prone to errors. Therefore, it is
necessary to separate domain model and the
validation logic, further to it, it also has to be
aimed for reuse with the help of framework.
This blog post focuses to bring the goodness of JSR303 Bean
Validation model [Hibernate RI], Spring framework’s support for
custom validation and a blend on how it will work in MuleSoft ESB.
From an ESB point of view, the validation requirements are:
 Provide uniform approach to validate different type of payloads
supporting REST, SOAP, XML, Java VO and other types of
payloads
 Provide support for field level validations (example: validate
inbound message attributes)
 Provide support for custom validations (based on business logic)
 Support context specific messages for validation errors from
configuration files
 Raise validation errors for handling alternate flow of execution
 Inject validators as pluggable components in flow
Mule supports validations to an extent but that is
not sufficient; for example
 The validator pattern from Mule supports
validation using MEL which is barely sufficient;
forcing to write MEL for every attribute and has
no option to wire to an error code/message
 The JSON validator checks whether the input
JSON is formatted. It does not support features to
apply a constraint like checking the length of an
attribute, for null value or for an empty string,
etc.
 Java Bean Validation (JSR303) is a framework
as part of Java EE. The bean validation
defines meta model and API for data
validation. The implementation is done
through annotations and is extensible, which
can be reused by simply adding annotations
to the domain model.
// Example – define constraints to a bean
public class Person {
@NotNull (message=’ERR-BS-001’)
public class Person {
@NotNull (message=’ERR-BS-001’)
@Size(min=1, max=16)
private String firstName;
@NotNull (message=’ERR-BS-002’)
@Size(min=1, max=16)
private String lastName;
Spring framework supports JSR303 bean validations and
support for custom validation. Some of the advantages upon
using Spring Validators are mentioned below:
 Spring framework is a natural choice of Mule for DI – No
additional set-up is required
 Custom Spring Validators can be injected to a Mule ESB
flow so as to validate business logic
 Supports JSR 303 validation by making use of a reference
implementation like Hibernate Validator API or Apache
BVal API
 Link validation errors using Spring property placeholders
for error messages which are context specific
 A validation framework is necessary, which
binds annotation validators, custom
validators and error message handler.
To validate annotations, JSR303 RI is required in the
library. Hibernate Validator or Apache’s BVal can be
used to support annotation based validations.
 To validate concrete domain models, Spring
framework’s ValidationUtils class should be used
(from springframework.validation package). The
ValidationUtil’s method should invoke a custom
validator thus providing FieldErrors.
 The ExceptionFactory consolidates the FieldErrors
from different validators, fetches the attribute name
and message ID and loads the message from the
message source.
 Custom validators to the ValidationUtils should be
injected as Spring beans in Mule.
 Exception factory should use Spring’s
PropertiesFactoryBean to load error messages at
runtime.
 It might be possible to use annotations in
order to validate REST requests by using
@Valid annotation. Mule ESB 6.1 has
upgraded Jersey version 2.11 (RI) which
supports validation using @Valid annotation
prior to a REST method invocation (like in
Spring MVC).
// update user profile after validation
@POST
@Consumes( MediaType.APPLICATION_JSON_VALUE
)
public boolean updateProfile( @Valid UserProfile m
Profile )
//…
}

Contenu connexe

Tendances

Testing mule
Testing   muleTesting   mule
Testing muleSindhu VL
 
Mule esb for beginners
Mule esb for beginnersMule esb for beginners
Mule esb for beginnersSindhu VL
 
Overview of Mule
Overview of MuleOverview of Mule
Overview of Mulemdfkhan625
 
Mule message structure
Mule message structureMule message structure
Mule message structureSrilatha Kante
 
Core concepts in mule
Core concepts in muleCore concepts in mule
Core concepts in muleSindhu VL
 
Introduction to mule Esbs
Introduction to mule EsbsIntroduction to mule Esbs
Introduction to mule EsbsPrabhat gangwar
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introductionSon Nguyen
 
Cloud hub architecture
Cloud hub architectureCloud hub architecture
Cloud hub architectureShanky Gupta
 
Mule and web services
Mule and web servicesMule and web services
Mule and web servicesManav Prasad
 
Mule message structure and varibles scopes
Mule message structure and varibles scopesMule message structure and varibles scopes
Mule message structure and varibles scopesRamakrishna kapa
 

Tendances (17)

Testing mule
Testing   muleTesting   mule
Testing mule
 
Mule esb for beginners
Mule esb for beginnersMule esb for beginners
Mule esb for beginners
 
Mule esb2
Mule esb2Mule esb2
Mule esb2
 
Mule message
Mule messageMule message
Mule message
 
Overview of Mule
Overview of MuleOverview of Mule
Overview of Mule
 
Mule message structure
Mule message structureMule message structure
Mule message structure
 
Mule technology
Mule technologyMule technology
Mule technology
 
Mule overview
Mule overviewMule overview
Mule overview
 
Mule esb
Mule esbMule esb
Mule esb
 
Mulesoft ppt
Mulesoft pptMulesoft ppt
Mulesoft ppt
 
Core concepts in mule
Core concepts in muleCore concepts in mule
Core concepts in mule
 
Introduction to mule Esbs
Introduction to mule EsbsIntroduction to mule Esbs
Introduction to mule Esbs
 
Webservice vm in mule
Webservice vm in muleWebservice vm in mule
Webservice vm in mule
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introduction
 
Cloud hub architecture
Cloud hub architectureCloud hub architecture
Cloud hub architecture
 
Mule and web services
Mule and web servicesMule and web services
Mule and web services
 
Mule message structure and varibles scopes
Mule message structure and varibles scopesMule message structure and varibles scopes
Mule message structure and varibles scopes
 

En vedette

Dockerized tests with dockerized jenkins
Dockerized tests with dockerized jenkinsDockerized tests with dockerized jenkins
Dockerized tests with dockerized jenkinsFernando Valverde
 
Integration Testing with Docker Containers with DockerCompose
Integration Testing with Docker Containers  with DockerComposeIntegration Testing with Docker Containers  with DockerCompose
Integration Testing with Docker Containers with DockerComposeMike Holdsworth
 
How to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker ComposeHow to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker ComposeEvoke Technologies
 
Dockerize it all
Dockerize it allDockerize it all
Dockerize it allPuneet Behl
 
DEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOS
DEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOSDEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOS
DEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOSJulia Mateo
 
SDLC Using Docker for Fun and Profit
SDLC Using Docker for Fun and ProfitSDLC Using Docker for Fun and Profit
SDLC Using Docker for Fun and Profitdantheelder
 
Monitoring docker container and dockerized applications
Monitoring docker container and dockerized applicationsMonitoring docker container and dockerized applications
Monitoring docker container and dockerized applicationsAnanth Padmanabhan
 
Docker Practical Use Cases
Docker Practical Use CasesDocker Practical Use Cases
Docker Practical Use CasesAlexei Yuzhakov
 
Dockerize WordPress on Mac/Windows
Dockerize WordPress on Mac/WindowsDockerize WordPress on Mac/Windows
Dockerize WordPress on Mac/WindowsKite Koga
 
Modern DevOps with Docker
Modern DevOps with DockerModern DevOps with Docker
Modern DevOps with DockerShippable
 
I tried to dockerize my app but I had to PaaS
I tried to dockerize my app but I had to PaaSI tried to dockerize my app but I had to PaaS
I tried to dockerize my app but I had to PaaSJorge Morales
 
How Docker Fits into DevOps Ecosystem
How Docker Fits into DevOps EcosystemHow Docker Fits into DevOps Ecosystem
How Docker Fits into DevOps EcosystemEdureka!
 
CI/CD with Docker, DC/OS, and Jenkins
CI/CD with Docker, DC/OS, and JenkinsCI/CD with Docker, DC/OS, and Jenkins
CI/CD with Docker, DC/OS, and JenkinsKarl Isenberg
 
Docker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker, Inc.
 
Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXNGINX, Inc.
 
Dockerizing Ruby Applications - The Best Practices
Dockerizing Ruby Applications - The Best PracticesDockerizing Ruby Applications - The Best Practices
Dockerizing Ruby Applications - The Best PracticesKontena, Inc.
 
12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM DeploymentJoe Kutner
 

En vedette (18)

Dockerized tests with dockerized jenkins
Dockerized tests with dockerized jenkinsDockerized tests with dockerized jenkins
Dockerized tests with dockerized jenkins
 
Integration Testing with Docker Containers with DockerCompose
Integration Testing with Docker Containers  with DockerComposeIntegration Testing with Docker Containers  with DockerCompose
Integration Testing with Docker Containers with DockerCompose
 
How to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker ComposeHow to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker Compose
 
Dockerize it all
Dockerize it allDockerize it all
Dockerize it all
 
DEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOS
DEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOSDEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOS
DEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOS
 
SDLC Using Docker for Fun and Profit
SDLC Using Docker for Fun and ProfitSDLC Using Docker for Fun and Profit
SDLC Using Docker for Fun and Profit
 
Monitoring docker container and dockerized applications
Monitoring docker container and dockerized applicationsMonitoring docker container and dockerized applications
Monitoring docker container and dockerized applications
 
Docker Practical Use Cases
Docker Practical Use CasesDocker Practical Use Cases
Docker Practical Use Cases
 
Dockerize All The Things
Dockerize All The ThingsDockerize All The Things
Dockerize All The Things
 
Dockerize WordPress on Mac/Windows
Dockerize WordPress on Mac/WindowsDockerize WordPress on Mac/Windows
Dockerize WordPress on Mac/Windows
 
Modern DevOps with Docker
Modern DevOps with DockerModern DevOps with Docker
Modern DevOps with Docker
 
I tried to dockerize my app but I had to PaaS
I tried to dockerize my app but I had to PaaSI tried to dockerize my app but I had to PaaS
I tried to dockerize my app but I had to PaaS
 
How Docker Fits into DevOps Ecosystem
How Docker Fits into DevOps EcosystemHow Docker Fits into DevOps Ecosystem
How Docker Fits into DevOps Ecosystem
 
CI/CD with Docker, DC/OS, and Jenkins
CI/CD with Docker, DC/OS, and JenkinsCI/CD with Docker, DC/OS, and Jenkins
CI/CD with Docker, DC/OS, and Jenkins
 
Docker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup Slides
 
Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINX
 
Dockerizing Ruby Applications - The Best Practices
Dockerizing Ruby Applications - The Best PracticesDockerizing Ruby Applications - The Best Practices
Dockerizing Ruby Applications - The Best Practices
 
12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment
 

Similaire à Mule soft esb – data validation best practices

Take Your Web Development To The Next Level With These Top 2 Libraries
Take Your Web Development To The Next Level With These Top 2 LibrariesTake Your Web Development To The Next Level With These Top 2 Libraries
Take Your Web Development To The Next Level With These Top 2 LibrariesPolyxer Systems
 
Railsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUDRailsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUDFlurry, Inc.
 
06_DP_300T00A_Automate.pptx
06_DP_300T00A_Automate.pptx06_DP_300T00A_Automate.pptx
06_DP_300T00A_Automate.pptxKareemBullard1
 
Testing mule
Testing   muleTesting   mule
Testing muleSindhu VL
 
Mule testing
Mule   testingMule   testing
Mule testingSindhu VL
 
Flowsinmule 160517130818
Flowsinmule 160517130818Flowsinmule 160517130818
Flowsinmule 160517130818ppts123456
 
WinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSC
WinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSCWinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSC
WinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSCWinOps Conf
 
Flows in mule
Flows in muleFlows in mule
Flows in muleSindhu VL
 
Different Types of Test Automation Frameworks .pptx
Different Types of Test Automation Frameworks .pptxDifferent Types of Test Automation Frameworks .pptx
Different Types of Test Automation Frameworks .pptxHeadspin INC
 
Azure Design Review Checklist Availabilityの巻
Azure Design Review Checklist Availabilityの巻Azure Design Review Checklist Availabilityの巻
Azure Design Review Checklist Availabilityの巻Toru Makabe
 
Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Ilio Catallo
 
Uunit 5-xml&web security
Uunit 5-xml&web securityUunit 5-xml&web security
Uunit 5-xml&web securityssuser3a47cb
 
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar SeriesImproving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar SeriesAmazon Web Services
 
Azure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web ServicesAzure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web ServicesBob German
 
Azure Day 2.pptx
Azure Day 2.pptxAzure Day 2.pptx
Azure Day 2.pptxmasbulosoke
 
Design patterns and plan for developing high available azure applications
Design patterns and plan for developing high available azure applicationsDesign patterns and plan for developing high available azure applications
Design patterns and plan for developing high available azure applicationsHimanshu Sahu
 
Improving Infrastructure Governance on AWS
Improving Infrastructure Governance on AWSImproving Infrastructure Governance on AWS
Improving Infrastructure Governance on AWSAmazon Web Services
 

Similaire à Mule soft esb – data validation best practices (20)

Mule ESB- Data Validation- Best Practices
Mule ESB-  Data Validation- Best PracticesMule ESB-  Data Validation- Best Practices
Mule ESB- Data Validation- Best Practices
 
Take Your Web Development To The Next Level With These Top 2 Libraries
Take Your Web Development To The Next Level With These Top 2 LibrariesTake Your Web Development To The Next Level With These Top 2 Libraries
Take Your Web Development To The Next Level With These Top 2 Libraries
 
Railsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUDRailsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUD
 
Mule ESB
Mule ESBMule ESB
Mule ESB
 
06_DP_300T00A_Automate.pptx
06_DP_300T00A_Automate.pptx06_DP_300T00A_Automate.pptx
06_DP_300T00A_Automate.pptx
 
Testing mule
Testing   muleTesting   mule
Testing mule
 
Mule testing
Mule   testingMule   testing
Mule testing
 
Flowsinmule 160517130818
Flowsinmule 160517130818Flowsinmule 160517130818
Flowsinmule 160517130818
 
Flows in mule
Flows in muleFlows in mule
Flows in mule
 
WinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSC
WinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSCWinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSC
WinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSC
 
Flows in mule
Flows in muleFlows in mule
Flows in mule
 
Different Types of Test Automation Frameworks .pptx
Different Types of Test Automation Frameworks .pptxDifferent Types of Test Automation Frameworks .pptx
Different Types of Test Automation Frameworks .pptx
 
Azure Design Review Checklist Availabilityの巻
Azure Design Review Checklist Availabilityの巻Azure Design Review Checklist Availabilityの巻
Azure Design Review Checklist Availabilityの巻
 
Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3
 
Uunit 5-xml&web security
Uunit 5-xml&web securityUunit 5-xml&web security
Uunit 5-xml&web security
 
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar SeriesImproving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
 
Azure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web ServicesAzure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web Services
 
Azure Day 2.pptx
Azure Day 2.pptxAzure Day 2.pptx
Azure Day 2.pptx
 
Design patterns and plan for developing high available azure applications
Design patterns and plan for developing high available azure applicationsDesign patterns and plan for developing high available azure applications
Design patterns and plan for developing high available azure applications
 
Improving Infrastructure Governance on AWS
Improving Infrastructure Governance on AWSImproving Infrastructure Governance on AWS
Improving Infrastructure Governance on AWS
 

Dernier

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 

Dernier (20)

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 

Mule soft esb – data validation best practices

  • 1.
  • 2.  Validation of data in ESB application at different layers of message processing is a requirement which is quite frequent. Often, the validation logic is implemented at different layers which is time consuming and also prone to errors. Therefore, it is necessary to separate domain model and the validation logic, further to it, it also has to be aimed for reuse with the help of framework.
  • 3.
  • 4. This blog post focuses to bring the goodness of JSR303 Bean Validation model [Hibernate RI], Spring framework’s support for custom validation and a blend on how it will work in MuleSoft ESB. From an ESB point of view, the validation requirements are:  Provide uniform approach to validate different type of payloads supporting REST, SOAP, XML, Java VO and other types of payloads  Provide support for field level validations (example: validate inbound message attributes)  Provide support for custom validations (based on business logic)  Support context specific messages for validation errors from configuration files  Raise validation errors for handling alternate flow of execution  Inject validators as pluggable components in flow
  • 5. Mule supports validations to an extent but that is not sufficient; for example  The validator pattern from Mule supports validation using MEL which is barely sufficient; forcing to write MEL for every attribute and has no option to wire to an error code/message  The JSON validator checks whether the input JSON is formatted. It does not support features to apply a constraint like checking the length of an attribute, for null value or for an empty string, etc.
  • 6.  Java Bean Validation (JSR303) is a framework as part of Java EE. The bean validation defines meta model and API for data validation. The implementation is done through annotations and is extensible, which can be reused by simply adding annotations to the domain model. // Example – define constraints to a bean public class Person { @NotNull (message=’ERR-BS-001’) public class Person { @NotNull (message=’ERR-BS-001’) @Size(min=1, max=16) private String firstName; @NotNull (message=’ERR-BS-002’) @Size(min=1, max=16) private String lastName;
  • 7. Spring framework supports JSR303 bean validations and support for custom validation. Some of the advantages upon using Spring Validators are mentioned below:  Spring framework is a natural choice of Mule for DI – No additional set-up is required  Custom Spring Validators can be injected to a Mule ESB flow so as to validate business logic  Supports JSR 303 validation by making use of a reference implementation like Hibernate Validator API or Apache BVal API  Link validation errors using Spring property placeholders for error messages which are context specific
  • 8.  A validation framework is necessary, which binds annotation validators, custom validators and error message handler.
  • 9. To validate annotations, JSR303 RI is required in the library. Hibernate Validator or Apache’s BVal can be used to support annotation based validations.  To validate concrete domain models, Spring framework’s ValidationUtils class should be used (from springframework.validation package). The ValidationUtil’s method should invoke a custom validator thus providing FieldErrors.  The ExceptionFactory consolidates the FieldErrors from different validators, fetches the attribute name and message ID and loads the message from the message source.  Custom validators to the ValidationUtils should be injected as Spring beans in Mule.  Exception factory should use Spring’s PropertiesFactoryBean to load error messages at runtime.
  • 10.  It might be possible to use annotations in order to validate REST requests by using @Valid annotation. Mule ESB 6.1 has upgraded Jersey version 2.11 (RI) which supports validation using @Valid annotation prior to a REST method invocation (like in Spring MVC). // update user profile after validation @POST @Consumes( MediaType.APPLICATION_JSON_VALUE ) public boolean updateProfile( @Valid UserProfile m Profile ) //… }