SlideShare a Scribd company logo
1 of 10
 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 )
//…
}

More Related Content

What's hot (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
 

Viewers also liked

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
NGINX, Inc.
 

Viewers also liked (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
 

Similar to Mule soft esb – data validation best practices

Similar to 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
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

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 ) //… }