SlideShare a Scribd company logo
1 of 21
Custom Policies
In Mule 4 vs Mule 3
Technical Architect, Mulesoft
Sarvesh Kotra
Agenda
1. What is/Why custom policies
2. When they can be used
3. How to develop
4. How to test
5. How to publish
6. How to apply
7. Demo
8. Q&A
What is/Why a custom policy
1. Policies enable you to enforce regulations with no modification to the code
implementation
2. They help manage security, control traffic, and improve adaptability of your
APIs. For example, a policy can control authentication, access, allotted
consumption, and service level access (SLA).
3. Custom policies can be used to apply your specific business/technical
requirements to APIs with no modification to the code implementation.
4. Custom policies will extend the functionality of Mule application at the time of
execution.
5. These can be shared and reused
1. Security - Mutual Auth policy, URL validation
2. Analytics - Custom JSON logging policy
3. Control traffic - Dedupe based on metadata
4. Transformation - Changing response (Headers/Payload)
5. Extending a default policy
When they can be used
How?
1. Develop the policy
2. Test the policy
3. Package the policy
4. Publish policy assets to Exchange.
5. Apply the policy to any API through API Manager.
Steps
1. Configure maven’s settings.xml to use Archtype
2. Use the archetype to create a custom policy project
Prerequisites
● An XML template
It contains the implementation of the policy using Mule’s XML schema
language.
● A YAML file
It defines the configurable parameters of the policy. Anypoint API Manager
uses this file to render the UI to display inputs for the policy.
● The template’s pom.xml file
It defines policy dependencies. The packaging type needs to be mule-policy.
The pom.xml file may define any other Maven plugin that helps to manage the
development lifecycle of the Maven project.
● Resources
Optional files that the policy depends on, such as certificates and
configuration properties files.
● The mule-artifact.json descriptor
Understanding project structure
XML Template structure
Should contain http-policy:source or a
http-policy:operation element
inject instructions before an HTTP Listener event fires
executed before the start of a flow with an HTTP Listener.
trigger other policies or the application flow
executed after the flow completes
Policy A & B are applied on API with with F1
Policy execution order
YAML configuration file
Depending of the type of the parameter, the UI will render a different type of input such as:
○ text boxes
○ radio buttons
○ checkboxes
Some rendered elements require additional configurations. The list of elements that require additional configurations are:
○ String: Any string expected.
○ Expression: A DataWeave expression starting with #[ and finished with ] is expected.
○ Boolean: true or false.
○ Int: A number is expected.
Parameter types
Each policy parameter defined in a YAML Configuration file will be available as a HandleBars variable for resolving the final
policy configuration.
The primitive types can be referenced from the policy template using curly brackets: {{{myproperty}}}
https://handlebarsjs.com/
Handlebars
https://github.com/mulesoft-catalyst/circuit-breaker-policy-mule-4
Sample files
● Place jar file in %MULE_HOME%/policies/policy-templates
● Create below JSON file and place in %MULE_HOME%/policies/offline-policies
○ Policy template information
Specify the Exchange groupId, assetId, and version of the template used to deploy the offline policy definition.
○ IDs of the APIs that the policy will be applied to
○ A list of resources that the policy will be applied to
○ Order of the policy
○ Parameters if the defined template is using handlebars variables
Test - Apply and Test in Offline mode
Below changes are needed for maven to upload policy to exchange
1. Settings.xml
2. Distribution management in pom.xml
Publish to Exchange
Apply
Demo
Q&A
Quiz
Go to menti.com
Code: 6561 6443
Thank You

More Related Content

Similar to Custom policies columbus ohio mulesoft meetup

Enterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin BlockEnterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin Blockmcgurk
 
Bangalore mulesoft meetup#10
Bangalore mulesoft meetup#10Bangalore mulesoft meetup#10
Bangalore mulesoft meetup#10D.Rajesh Kumar
 
Warsaw MuleSoft Meetup #7 - custom policy
Warsaw MuleSoft Meetup #7 - custom policyWarsaw MuleSoft Meetup #7 - custom policy
Warsaw MuleSoft Meetup #7 - custom policyPatryk Bandurski
 
Introduction to Smart Data Models
Introduction to Smart Data ModelsIntroduction to Smart Data Models
Introduction to Smart Data ModelsFIWARE
 
NEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICENEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICEijwscjournal
 
NEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICENEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICEijwscjournal
 
NEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICENEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICEijwscjournal
 
Mule soft Meetup #3
 Mule soft Meetup #3 Mule soft Meetup #3
Mule soft Meetup #3Gaurav Sethi
 
Acquisition of IT Service Management tools
Acquisition of IT Service Management toolsAcquisition of IT Service Management tools
Acquisition of IT Service Management toolsChristian F. Nissen
 
Customizing Ranking Models for Enterprise Search: Presented by Ammar Haris & ...
Customizing Ranking Models for Enterprise Search: Presented by Ammar Haris & ...Customizing Ranking Models for Enterprise Search: Presented by Ammar Haris & ...
Customizing Ranking Models for Enterprise Search: Presented by Ammar Haris & ...Lucidworks
 
Virtual meetup - Exploring the Runtime Fabric deployment model
Virtual meetup - Exploring the Runtime Fabric deployment modelVirtual meetup - Exploring the Runtime Fabric deployment model
Virtual meetup - Exploring the Runtime Fabric deployment modelJimmy Attia
 
ASM Course Content.pdf
ASM Course Content.pdfASM Course Content.pdf
ASM Course Content.pdfviditsir
 
Dynamic modelling best practice recommendation for the SID
Dynamic modelling best practice recommendation for the SIDDynamic modelling best practice recommendation for the SID
Dynamic modelling best practice recommendation for the SIDgtilton
 
Railsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUDRailsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUDFlurry, Inc.
 
Jaipur Mule soft virtual meetup #1
Jaipur Mule soft virtual meetup #1Jaipur Mule soft virtual meetup #1
Jaipur Mule soft virtual meetup #1Lalit Panwar
 
Mule Meetup Calgary- API Governance & Conformance.pdf
Mule Meetup Calgary- API Governance & Conformance.pdfMule Meetup Calgary- API Governance & Conformance.pdf
Mule Meetup Calgary- API Governance & Conformance.pdfNithaJoseph4
 

Similar to Custom policies columbus ohio mulesoft meetup (20)

Enterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin BlockEnterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin Block
 
Bangalore mulesoft meetup#10
Bangalore mulesoft meetup#10Bangalore mulesoft meetup#10
Bangalore mulesoft meetup#10
 
Warsaw MuleSoft Meetup #7 - custom policy
Warsaw MuleSoft Meetup #7 - custom policyWarsaw MuleSoft Meetup #7 - custom policy
Warsaw MuleSoft Meetup #7 - custom policy
 
Introduction to Smart Data Models
Introduction to Smart Data ModelsIntroduction to Smart Data Models
Introduction to Smart Data Models
 
NEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICENEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICE
 
5414ijwsc01
5414ijwsc015414ijwsc01
5414ijwsc01
 
NEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICENEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICE
 
NEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICENEGOTIATION ON A NEW POLICY IN SERVICE
NEGOTIATION ON A NEW POLICY IN SERVICE
 
Mule soft Meetup #3
 Mule soft Meetup #3 Mule soft Meetup #3
Mule soft Meetup #3
 
Hyderabad MuleSoft Meetup
Hyderabad MuleSoft MeetupHyderabad MuleSoft Meetup
Hyderabad MuleSoft Meetup
 
Acquisition of IT Service Management tools
Acquisition of IT Service Management toolsAcquisition of IT Service Management tools
Acquisition of IT Service Management tools
 
Customizing Ranking Models for Enterprise Search: Presented by Ammar Haris & ...
Customizing Ranking Models for Enterprise Search: Presented by Ammar Haris & ...Customizing Ranking Models for Enterprise Search: Presented by Ammar Haris & ...
Customizing Ranking Models for Enterprise Search: Presented by Ammar Haris & ...
 
Virtual meetup - Exploring the Runtime Fabric deployment model
Virtual meetup - Exploring the Runtime Fabric deployment modelVirtual meetup - Exploring the Runtime Fabric deployment model
Virtual meetup - Exploring the Runtime Fabric deployment model
 
ASM Course Content.pdf
ASM Course Content.pdfASM Course Content.pdf
ASM Course Content.pdf
 
Dynamic modelling best practice recommendation for the SID
Dynamic modelling best practice recommendation for the SIDDynamic modelling best practice recommendation for the SID
Dynamic modelling best practice recommendation for the SID
 
DDS-TSN OMG Request for Proposals (RFP)
DDS-TSN OMG Request for Proposals (RFP)DDS-TSN OMG Request for Proposals (RFP)
DDS-TSN OMG Request for Proposals (RFP)
 
The DNA of a great API
The DNA of a great APIThe DNA of a great API
The DNA of a great API
 
Railsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUDRailsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUD
 
Jaipur Mule soft virtual meetup #1
Jaipur Mule soft virtual meetup #1Jaipur Mule soft virtual meetup #1
Jaipur Mule soft virtual meetup #1
 
Mule Meetup Calgary- API Governance & Conformance.pdf
Mule Meetup Calgary- API Governance & Conformance.pdfMule Meetup Calgary- API Governance & Conformance.pdf
Mule Meetup Calgary- API Governance & Conformance.pdf
 

More from MuleSoft Meetup

Prowess_B2B-EDI_Anypoint Partner Manager_Final.pptx
Prowess_B2B-EDI_Anypoint Partner Manager_Final.pptxProwess_B2B-EDI_Anypoint Partner Manager_Final.pptx
Prowess_B2B-EDI_Anypoint Partner Manager_Final.pptxMuleSoft Meetup
 
Mule soft accelerator for retail columbus meetup
Mule soft accelerator for retail   columbus meetupMule soft accelerator for retail   columbus meetup
Mule soft accelerator for retail columbus meetupMuleSoft Meetup
 
Columbus mule soft_meetup_aug2021_Kafka_Integration
Columbus mule soft_meetup_aug2021_Kafka_IntegrationColumbus mule soft_meetup_aug2021_Kafka_Integration
Columbus mule soft_meetup_aug2021_Kafka_IntegrationMuleSoft Meetup
 
MuleSoft Monitoring Meetup
MuleSoft Monitoring MeetupMuleSoft Monitoring Meetup
MuleSoft Monitoring MeetupMuleSoft Meetup
 
mule soft-virtual-meetup-anypoint-service-mesh
mule soft-virtual-meetup-anypoint-service-meshmule soft-virtual-meetup-anypoint-service-mesh
mule soft-virtual-meetup-anypoint-service-meshMuleSoft Meetup
 
Panel meetup with EA leaders
Panel meetup with EA leadersPanel meetup with EA leaders
Panel meetup with EA leadersMuleSoft Meetup
 
Salesforce integration best practices columbus meetup
Salesforce integration best practices   columbus meetupSalesforce integration best practices   columbus meetup
Salesforce integration best practices columbus meetupMuleSoft Meetup
 

More from MuleSoft Meetup (7)

Prowess_B2B-EDI_Anypoint Partner Manager_Final.pptx
Prowess_B2B-EDI_Anypoint Partner Manager_Final.pptxProwess_B2B-EDI_Anypoint Partner Manager_Final.pptx
Prowess_B2B-EDI_Anypoint Partner Manager_Final.pptx
 
Mule soft accelerator for retail columbus meetup
Mule soft accelerator for retail   columbus meetupMule soft accelerator for retail   columbus meetup
Mule soft accelerator for retail columbus meetup
 
Columbus mule soft_meetup_aug2021_Kafka_Integration
Columbus mule soft_meetup_aug2021_Kafka_IntegrationColumbus mule soft_meetup_aug2021_Kafka_Integration
Columbus mule soft_meetup_aug2021_Kafka_Integration
 
MuleSoft Monitoring Meetup
MuleSoft Monitoring MeetupMuleSoft Monitoring Meetup
MuleSoft Monitoring Meetup
 
mule soft-virtual-meetup-anypoint-service-mesh
mule soft-virtual-meetup-anypoint-service-meshmule soft-virtual-meetup-anypoint-service-mesh
mule soft-virtual-meetup-anypoint-service-mesh
 
Panel meetup with EA leaders
Panel meetup with EA leadersPanel meetup with EA leaders
Panel meetup with EA leaders
 
Salesforce integration best practices columbus meetup
Salesforce integration best practices   columbus meetupSalesforce integration best practices   columbus meetup
Salesforce integration best practices columbus meetup
 

Recently uploaded

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Recently uploaded (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Custom policies columbus ohio mulesoft meetup

  • 1. Custom Policies In Mule 4 vs Mule 3 Technical Architect, Mulesoft Sarvesh Kotra
  • 2. Agenda 1. What is/Why custom policies 2. When they can be used 3. How to develop 4. How to test 5. How to publish 6. How to apply 7. Demo 8. Q&A
  • 3. What is/Why a custom policy 1. Policies enable you to enforce regulations with no modification to the code implementation 2. They help manage security, control traffic, and improve adaptability of your APIs. For example, a policy can control authentication, access, allotted consumption, and service level access (SLA). 3. Custom policies can be used to apply your specific business/technical requirements to APIs with no modification to the code implementation. 4. Custom policies will extend the functionality of Mule application at the time of execution. 5. These can be shared and reused
  • 4. 1. Security - Mutual Auth policy, URL validation 2. Analytics - Custom JSON logging policy 3. Control traffic - Dedupe based on metadata 4. Transformation - Changing response (Headers/Payload) 5. Extending a default policy When they can be used
  • 6. 1. Develop the policy 2. Test the policy 3. Package the policy 4. Publish policy assets to Exchange. 5. Apply the policy to any API through API Manager. Steps
  • 7. 1. Configure maven’s settings.xml to use Archtype 2. Use the archetype to create a custom policy project Prerequisites
  • 8. ● An XML template It contains the implementation of the policy using Mule’s XML schema language. ● A YAML file It defines the configurable parameters of the policy. Anypoint API Manager uses this file to render the UI to display inputs for the policy. ● The template’s pom.xml file It defines policy dependencies. The packaging type needs to be mule-policy. The pom.xml file may define any other Maven plugin that helps to manage the development lifecycle of the Maven project. ● Resources Optional files that the policy depends on, such as certificates and configuration properties files. ● The mule-artifact.json descriptor Understanding project structure
  • 9. XML Template structure Should contain http-policy:source or a http-policy:operation element inject instructions before an HTTP Listener event fires executed before the start of a flow with an HTTP Listener. trigger other policies or the application flow executed after the flow completes
  • 10. Policy A & B are applied on API with with F1 Policy execution order
  • 12. Depending of the type of the parameter, the UI will render a different type of input such as: ○ text boxes ○ radio buttons ○ checkboxes Some rendered elements require additional configurations. The list of elements that require additional configurations are: ○ String: Any string expected. ○ Expression: A DataWeave expression starting with #[ and finished with ] is expected. ○ Boolean: true or false. ○ Int: A number is expected. Parameter types
  • 13. Each policy parameter defined in a YAML Configuration file will be available as a HandleBars variable for resolving the final policy configuration. The primitive types can be referenced from the policy template using curly brackets: {{{myproperty}}} https://handlebarsjs.com/ Handlebars
  • 15. ● Place jar file in %MULE_HOME%/policies/policy-templates ● Create below JSON file and place in %MULE_HOME%/policies/offline-policies ○ Policy template information Specify the Exchange groupId, assetId, and version of the template used to deploy the offline policy definition. ○ IDs of the APIs that the policy will be applied to ○ A list of resources that the policy will be applied to ○ Order of the policy ○ Parameters if the defined template is using handlebars variables Test - Apply and Test in Offline mode
  • 16. Below changes are needed for maven to upload policy to exchange 1. Settings.xml 2. Distribution management in pom.xml Publish to Exchange
  • 17. Apply
  • 18. Demo
  • 19. Q&A