SlideShare a Scribd company logo
1 of 39
2021-07-21
MuleSoft for Java Devs - Meetup
Group
Building APIs with Mule and SpringBoot
2
● Introductions
● Mule & Java
● API Lifecycle
○ Building MuleSoft API
○ Building SpringBoot API
● Wrap-up
● Trivia - Win a MuleSoft Course
Agenda
Sponsor:
Integration Architect at Infomentum
● More than 13 years working with
development. Start with Java in 2008!
● Since 2014 working with MuleSoft
● MuleSoft Ambassador & Meetup Leader
Guilherme Pereira
•Enterprise Architect / Mulesoft Technical Instructor
•EMEA (Milan, Italy)
•Background:
–25+ yrs exp. Software Engineer, Developer, Trainer, Translator
–MuleSoft, Java, .NET, Python, Node.Js, Oracle Cloud, Google Cloud,
AWS, CNCF Kubernetes Specialist, UML/SysML Certified Expert, PMI
PMP, TOGAF 9.1
•Certified MuleSoft Developer (MCD), Certified MuleSoft Integration Architect (MCIA), Cert
Mule Platform Architect (MCPA)
Thimoty Barbieri, PhD
https://www.linkedin.com/in/thimoty/
Better together
Mule & Java
6
● Mule started as an open-source project later in 2003
○ A powerful & lightweight ESB runtime
○ Implemented several features to send, publish, route, transform messages
○ Had a great adoption with thousands of downloads and improvements during the years
○ The Mule core stills as an open-source project until nowadays
Mule is based on Java
7
From open-source to the Anypoint Platform
● Mule Runtime:
○ Java under the hoods
○ Lightweight ESB
○ Scalable
○ EDA
○ Automatic thread controls
○ Streaming
○ Batch
○ Persistent queues
○ Cache
Mule
8
From open-source to the Anypoint Platform
● Connectors & modules
○ 200+ connectors
○ Salesforce, SAP, Workday and
more...
○ Plug & Play
○ Databases, Queues, File and
more...
○ Connect everything
○ Extend with the SDK
Mule
Anypoint Connectors
9
From open-source to the Anypoint Platform
● Design & Portals
○ Design your APIs first
○ Mock and console
○ Publish your assets
○ Create API Portals
○ Discover APIs and fragments
Anypoint Design Center
Anypoint Exchange
Studio
API
Designer
Connector
DevKit
Mule
Anypoint Connectors
10
From open-source to the Anypoint Platform
● Management & Monitoring
○ Manage your APIs & Integrations
○ Monitoring
○ Alerts
○ Secure APIs
○ Out-of-the box policies
○ Custom policies
Anypoint Design Center Anypoint Management Center
Anypoint Exchange
Studio
API
Designer
Connector
DevKit
Runtime
Manager
API
Manager
Analytics
Mule
Anypoint Connectors
11
From open-source to the Anypoint Platform
Anypoint Design Center Anypoint Management Center
Anypoint Exchange
Studio
API
Designer
Connector
DevKit
Runtime
Manager
API
Manager
Analytics
Runtime Services
Mule
Anypoint Connectors
● Run & Scale
○ Run on Cloud, On-Prem or Hybrid
○ Easy to deploy
○ Scale
○ Run with Kubernetes
○ Object Store and Queues
○ Cloud MQ Message Broker
Building APIs
API Lifecycle
Use case
13
● Create an API to integrate with Salesforce
● Query Contacts and return as JSON format
“Doing It All” with MuleSoft
(clone full working demo from:
https://github.com/gui1207/sfdc-contacts-sys-api)
15
API Lifecycle
Step 1: Design the API Contract
16
Step 2: Implement & Test locally
17
Step 3: Deploy
18
Step 4: Operate
19
“Doing It All” with Spring Boot
(clone full working demo from:
https://github.com/thimotyb/salesforce-springboot-demo)
Step 1: Connecting to SalesForce
21
- We will use the Enterprise SOAP API with the approach described at
- https://developer.salesforce.com/docs/atlas.en-
us.api.meta/api/sforce_api_quickstart_steps.htm
- There are other you can use, e.g. Bulk API 2.0 https://developer.salesforce.com/docs/atlas.en-
us.api_asynch.meta/api_asynch/api_asynch_introduction_bulk_api.htm
- Or Streaming API https://developer.salesforce.com/docs/atlas.en-
us.api_streaming.meta/api_streaming/intro_stream.htm
- Download Enterprise WSDL for correct Salesforce Version from DevPortal
- Use WSC tool to generate Java skeletons and Data Models of the entire
Enterprise API
- java –classpath pathToJAR/wsc-22.jar com.sforce.ws.tools.wsdlc
pathToWsdl/WsdlFilename​ pathToOutputJar/OutputJarFilename
- The WSDL is huge, lots of problems trying to auto-generate in-line with the maven jax2
tooling
- An enterprise.jar system dependency specific for your Salesforce version is
created, to be included in the project
22
23
- Service as a
Singleton can be
Autowired in
implementation
- Configuration is
separated in
application.proper
ties and injected
at service boot
Step 1: Connection @Service
24
- The OAS YAML definition was provided and integrated in the project
manually
- Endpoint Controller Interface and Data Model are auto generated with
openapi-generator-maven-plugin
- Several other maven dependencies are necessary to make it properly work
Step 2: Integrating the API Design
25
- The interface is
generated in
maven’s target dir
and cannot be
modified
- Implementation
should be done as
separate @Service
implementing this
interface
- Spring’s IOC will
take care of the rest
Step 2: Auto-generated Interface
26
- Each Endpoint is implemented as a Service
- Implement the Auto-Generated Interface
- Inject the Connector
- Perform (Hard-code?) the query
- Fetch the resulting Record
- Handle Errors
- Prepare the Response
- DTO Mapping
- From the Enteprise.jar library -> Data Model from the OAS Spec
- Manually?!
Step 3: Implementing the Endpoints
27
Step 3: Implementation
Implement auto-
generated interface
Override interface
default methods
28
Streaming/Paging?
Use Bulk API 2.0 or
Streaming API
(CornetD)
1:1 Data Mapping
across DTO’s?
Hard-Coded
Query?
29
- We use the following maven plugins
- surefire for unit testing / spring mocks
- springboot for packaging as single jar
- docker plugin for containerization with Dockerfile
- Package, install, create container with
- mvn clean install docker:build (-DskipTests=true to skip tests?)
- Also useful
- maven release (auto-manage package versions / Release / Snapshot)
- use push goal to push container to Docker Registry
Step 4: DevOps
30
- We will use a Minikube free instance at
https://katacoda.com/javajon/courses/kubernetes-fundamentals/minikube
- Create a deployment, expose as a LoadBalanced service, check the status:
- kubectl create deployment salesforce-service --image=thimoty/salesforce-service
- kubectl expose deployment salesforce-service --port=80 --target-port=8080 --
type=LoadBalancer
- kubectl get po,svc -o wide
- The service is now reachable and deployment can be scaled up/down
- Need a Service Mesh (e.g. Istio) for Proxy Handling
Step 5: Deploy
31
- k8s Dashboard
- Need to setup Prometheus/Graphana
- Need to setup ELK Stack
- Config Backup: Velero
- Security? Certificates?
- … LOTS of additional stuff on top of plain vanilla k8s!!!
Step 6: Observability/Monitoring/Operations
Final considerations
Wrap up
Task Comparison Table
33
Task SpringBoot MuleSoft
Salesforce Connector: Prepare WSDL,
Stub/Skeleton
Download Enterprise API WSDL, use wsc
to create dependency
Just use the Salesforce Connector
API Design Use OAS Maven endpoint generator plugin API Kit from Design Center
Service Implementation
Need to implement the interface, prepare
the query, iterate the records, create ad-
hoc error handling. No OOTB
Paging/Streaming
Just leverage Mule’s Streaming Saleforce
connector, use Query, Trasform and Mule
3-tier error handling
DTO Mapping
Need to explicitly write “glue code” for each
combination, choose the correct API
typology (Enterprise, Partner, Batch,
Streaming…)
Use DataWeave!!!
DevOps / Containerization
Use Maven plugins and Dockerization with
Dockerfile
Just upload the Mule app to CloudHub!!!
What is missing?
34
Task SpringBoot MuleSoft
Security Add Spring Security, roll your own Load
Balancers, install a Vault...
Anypoint Platform provides integrated services such
as: Vault, Secret Management, Safely Hidden
Properties
API Gateway Proxy - External API Manager Anypoint Platform provides integrated API Manager
capabilities and out of the box policies
Performance / Throughput Current implementation is pretty much
sequential
MuleSoft uses OTTB Spring Flux and Streaming
under the hood and
Logging Properly use log4j and Logstash (TBD) Anypoint Platform Logging
Monitoring If running in a container, use the orchestrator’s
monitoring facilities
Anypoint Platform Monitoring
Docker Image Maintenance Need to keep checking security of base images
of containers. Implement Registry Scanner.
Anypoint Runtime Fabric
35
● Final thoughts:
○ Pain points:
■ Difficult to implement just using plain code
■ Need user libs to create skeleton
■ Implement auth methods
○ Implementing with Mule
■ Out of box Connectors
■ CloudHub / Monitoring / API Manager
■ Drag and drop
Wrap up
36
● Register to the Free MuleSoft Course:
○ https://mule.is/LearnMule
● Share:
○ Tweet using the hashtag #MuleSoftMeetups
○ Invite your network to join: https://meetups.mulesoft.com/mulesoft-for-java-developers/
● Feedback:
○ Fill out the survey feedback and suggest topics for upcoming events
○ Contact MuleSoft at meetups@mulesoft.com for ways to improve the program
What’s next?
Your chance to win an Instructor-led MuleSoft course
Trivia
38
● You can win only 1 voucher per month, across all Meetups. If you already won 1 voucher in
the month from another event, you will not receive a new one.
● The first 3 ranked in the game win a voucher
● Use your name in the game - avoid nicknames
● To request the voucher you should send a email to gui1207@gmail.com or use the "contact
the organizer form" on the meetup group page
● If using Kahoot, go to kahoot.com with your browser on desktop or smartphone
○ Select “Play”
○ Type the Game PIN you are given during the session
○ The contest with kahoot could be capped, so only the first 100 users that log in get to participate
Rules
Thank you

More Related Content

What's hot

What's hot (20)

Manchester MuleSoft Meetup #6 - Runtime Fabric with Mulesoft
Manchester MuleSoft Meetup #6 - Runtime Fabric with Mulesoft Manchester MuleSoft Meetup #6 - Runtime Fabric with Mulesoft
Manchester MuleSoft Meetup #6 - Runtime Fabric with Mulesoft
 
Singapore MuleSoft Meetup - 24 Aug 2022
Singapore MuleSoft Meetup - 24 Aug 2022Singapore MuleSoft Meetup - 24 Aug 2022
Singapore MuleSoft Meetup - 24 Aug 2022
 
Kubernetes Docker Container Implementation Ppt PowerPoint Presentation Slide ...
Kubernetes Docker Container Implementation Ppt PowerPoint Presentation Slide ...Kubernetes Docker Container Implementation Ppt PowerPoint Presentation Slide ...
Kubernetes Docker Container Implementation Ppt PowerPoint Presentation Slide ...
 
Open Source MANO(OSM)
Open Source MANO(OSM)Open Source MANO(OSM)
Open Source MANO(OSM)
 
Mass Migrate Virtual Machines to Kubevirt with Tool Forklift 2.0
Mass Migrate Virtual Machines to Kubevirt with Tool Forklift 2.0Mass Migrate Virtual Machines to Kubevirt with Tool Forklift 2.0
Mass Migrate Virtual Machines to Kubevirt with Tool Forklift 2.0
 
MuleSoft Anypoint Platform and Three Tier Architecture
MuleSoft Anypoint  Platform and Three Tier ArchitectureMuleSoft Anypoint  Platform and Three Tier Architecture
MuleSoft Anypoint Platform and Three Tier Architecture
 
MuleSoft Architecture Presentation
MuleSoft Architecture PresentationMuleSoft Architecture Presentation
MuleSoft Architecture Presentation
 
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
 
Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...
Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...
Mule 4 migration + Common Integration Challenges : MuleSoft Virtual Muleys Me...
 
Custom policies in mule 4 and a circuit breaker example
Custom policies in mule 4 and a circuit breaker exampleCustom policies in mule 4 and a circuit breaker example
Custom policies in mule 4 and a circuit breaker example
 
Mulesoft ppt
Mulesoft pptMulesoft ppt
Mulesoft ppt
 
Azure DevOps - Azure Guatemala Meetup
Azure DevOps - Azure Guatemala MeetupAzure DevOps - Azure Guatemala Meetup
Azure DevOps - Azure Guatemala Meetup
 
Introduction to CloudHub 2.0
Introduction to CloudHub 2.0Introduction to CloudHub 2.0
Introduction to CloudHub 2.0
 
Build CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation Slides
 
End-to-End CI/CD at scale with Infrastructure-as-Code on AWS
End-to-End CI/CD at scale with Infrastructure-as-Code on AWSEnd-to-End CI/CD at scale with Infrastructure-as-Code on AWS
End-to-End CI/CD at scale with Infrastructure-as-Code on AWS
 
Best Practices in Implementing a Center for Enablement (C4E) within Your Orga...
Best Practices in Implementing a Center for Enablement (C4E) within Your Orga...Best Practices in Implementing a Center for Enablement (C4E) within Your Orga...
Best Practices in Implementing a Center for Enablement (C4E) within Your Orga...
 
Managing APIs with MuleSoft
Managing APIs with MuleSoftManaging APIs with MuleSoft
Managing APIs with MuleSoft
 
OpenShift Virtualization- Technical Overview.pdf
OpenShift Virtualization- Technical Overview.pdfOpenShift Virtualization- Technical Overview.pdf
OpenShift Virtualization- Technical Overview.pdf
 
Modern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOpsModern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOps
 
Introduction à la plateforme Anypoint de MuleSoft
Introduction à la plateforme Anypoint de MuleSoftIntroduction à la plateforme Anypoint de MuleSoft
Introduction à la plateforme Anypoint de MuleSoft
 

Similar to Building APIs with Mule and Spring Boot

Similar to Building APIs with Mule and Spring Boot (20)

Brisbane MuleSoft Meetup 2023-03-22 - Anypoint Code Builder and Splunk Loggin...
Brisbane MuleSoft Meetup 2023-03-22 - Anypoint Code Builder and Splunk Loggin...Brisbane MuleSoft Meetup 2023-03-22 - Anypoint Code Builder and Splunk Loggin...
Brisbane MuleSoft Meetup 2023-03-22 - Anypoint Code Builder and Splunk Loggin...
 
Anypoint Tools and MuleSoft Automation (DRAFT).pptx
Anypoint Tools and MuleSoft Automation (DRAFT).pptxAnypoint Tools and MuleSoft Automation (DRAFT).pptx
Anypoint Tools and MuleSoft Automation (DRAFT).pptx
 
MuleSoft Meetup #9 - Anypoint Tools and MuleSoft Automation (FINAL).pptx
MuleSoft Meetup #9 - Anypoint Tools and MuleSoft Automation (FINAL).pptxMuleSoft Meetup #9 - Anypoint Tools and MuleSoft Automation (FINAL).pptx
MuleSoft Meetup #9 - Anypoint Tools and MuleSoft Automation (FINAL).pptx
 
Mulesoft KL Meetup 2
Mulesoft KL Meetup 2Mulesoft KL Meetup 2
Mulesoft KL Meetup 2
 
London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023
 
London MuleSoft Meetup
London MuleSoft Meetup London MuleSoft Meetup
London MuleSoft Meetup
 
Warsaw MuleSoft Meetup #13.pptx
Warsaw MuleSoft Meetup #13.pptxWarsaw MuleSoft Meetup #13.pptx
Warsaw MuleSoft Meetup #13.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Sustainability Challenge, Postman, Rest sheet and Anypoint provider : MuleSof...
Sustainability Challenge, Postman, Rest sheet and Anypoint provider : MuleSof...Sustainability Challenge, Postman, Rest sheet and Anypoint provider : MuleSof...
Sustainability Challenge, Postman, Rest sheet and Anypoint provider : MuleSof...
 
Ahmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICDAhmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICD
 
Manchester MuleSoft Meetup #7
Manchester MuleSoft Meetup #7 Manchester MuleSoft Meetup #7
Manchester MuleSoft Meetup #7
 
Mulesoft Connections to different companies, and different services
Mulesoft Connections to different companies, and different servicesMulesoft Connections to different companies, and different services
Mulesoft Connections to different companies, and different services
 
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
 
CI CD Daridabad MuleSoft meetup
CI CD Daridabad MuleSoft meetupCI CD Daridabad MuleSoft meetup
CI CD Daridabad MuleSoft meetup
 
Pitfalls of machine learning in production
Pitfalls of machine learning in productionPitfalls of machine learning in production
Pitfalls of machine learning in production
 
Azure DevOps Pipeline setup for Mule APIs #36
Azure DevOps Pipeline setup for Mule APIs #36Azure DevOps Pipeline setup for Mule APIs #36
Azure DevOps Pipeline setup for Mule APIs #36
 
MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...
MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...
MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...
 
Warsaw MuleSoft Meetup #6 - CI/CD
Warsaw MuleSoft Meetup  #6 - CI/CDWarsaw MuleSoft Meetup  #6 - CI/CD
Warsaw MuleSoft Meetup #6 - CI/CD
 
Mule soft step up session
Mule soft step up sessionMule soft step up session
Mule soft step up session
 
Learn mulesoft from scratch
Learn mulesoft from scratchLearn mulesoft from scratch
Learn mulesoft from scratch
 

More from Guilherme Pereira Silva

More from Guilherme Pereira Silva (13)

Extending the Mule Runtime - Building a Circuit Breaker Component.pptx
Extending the Mule Runtime - Building a Circuit Breaker Component.pptxExtending the Mule Runtime - Building a Circuit Breaker Component.pptx
Extending the Mule Runtime - Building a Circuit Breaker Component.pptx
 
#2 Building your first connector extending the Mule Java SDK
#2 Building your first connector extending the Mule Java SDK#2 Building your first connector extending the Mule Java SDK
#2 Building your first connector extending the Mule Java SDK
 
MuleSoft Composer - Online Portuguese Meetup Group
MuleSoft Composer - Online Portuguese Meetup GroupMuleSoft Composer - Online Portuguese Meetup Group
MuleSoft Composer - Online Portuguese Meetup Group
 
MuleSoft MuleSoft Meetup - Shared Flows
MuleSoft MuleSoft Meetup -  Shared FlowsMuleSoft MuleSoft Meetup -  Shared Flows
MuleSoft MuleSoft Meetup - Shared Flows
 
São Paulo MuleSoft Meetup - Messaging patterns
São Paulo MuleSoft Meetup - Messaging patternsSão Paulo MuleSoft Meetup - Messaging patterns
São Paulo MuleSoft Meetup - Messaging patterns
 
São Paulo MuleSoft Meetup - Unwired API Led & Custom Polices
São Paulo MuleSoft Meetup - Unwired API Led & Custom PolicesSão Paulo MuleSoft Meetup - Unwired API Led & Custom Polices
São Paulo MuleSoft Meetup - Unwired API Led & Custom Polices
 
São Paulo MuleSoft Meetups - DevOps
São Paulo MuleSoft Meetups - DevOpsSão Paulo MuleSoft Meetups - DevOps
São Paulo MuleSoft Meetups - DevOps
 
Mulesoft Meetup Latam Summit Brazil
Mulesoft Meetup Latam Summit BrazilMulesoft Meetup Latam Summit Brazil
Mulesoft Meetup Latam Summit Brazil
 
São Paulo MuleSoft Meetup - Deployments Models
São Paulo MuleSoft Meetup - Deployments ModelsSão Paulo MuleSoft Meetup - Deployments Models
São Paulo MuleSoft Meetup - Deployments Models
 
São Paulo MuleSoft Meetup #5 - Runtime Fabric
São Paulo MuleSoft Meetup #5 - Runtime FabricSão Paulo MuleSoft Meetup #5 - Runtime Fabric
São Paulo MuleSoft Meetup #5 - Runtime Fabric
 
MuleSoft Meetup São Paulo #4 - November
MuleSoft Meetup São Paulo #4 - NovemberMuleSoft Meetup São Paulo #4 - November
MuleSoft Meetup São Paulo #4 - November
 
MuleSoft São Paulo Meetup #3 - 18 Jun
MuleSoft São Paulo Meetup #3 - 18 JunMuleSoft São Paulo Meetup #3 - 18 Jun
MuleSoft São Paulo Meetup #3 - 18 Jun
 
São Paulo MuleSoft Meetup - 31 Jan
São Paulo MuleSoft Meetup - 31 JanSão Paulo MuleSoft Meetup - 31 Jan
São Paulo MuleSoft Meetup - 31 Jan
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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 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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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...
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Building APIs with Mule and Spring Boot

  • 1. 2021-07-21 MuleSoft for Java Devs - Meetup Group Building APIs with Mule and SpringBoot
  • 2. 2 ● Introductions ● Mule & Java ● API Lifecycle ○ Building MuleSoft API ○ Building SpringBoot API ● Wrap-up ● Trivia - Win a MuleSoft Course Agenda Sponsor:
  • 3. Integration Architect at Infomentum ● More than 13 years working with development. Start with Java in 2008! ● Since 2014 working with MuleSoft ● MuleSoft Ambassador & Meetup Leader Guilherme Pereira
  • 4. •Enterprise Architect / Mulesoft Technical Instructor •EMEA (Milan, Italy) •Background: –25+ yrs exp. Software Engineer, Developer, Trainer, Translator –MuleSoft, Java, .NET, Python, Node.Js, Oracle Cloud, Google Cloud, AWS, CNCF Kubernetes Specialist, UML/SysML Certified Expert, PMI PMP, TOGAF 9.1 •Certified MuleSoft Developer (MCD), Certified MuleSoft Integration Architect (MCIA), Cert Mule Platform Architect (MCPA) Thimoty Barbieri, PhD https://www.linkedin.com/in/thimoty/
  • 6. 6 ● Mule started as an open-source project later in 2003 ○ A powerful & lightweight ESB runtime ○ Implemented several features to send, publish, route, transform messages ○ Had a great adoption with thousands of downloads and improvements during the years ○ The Mule core stills as an open-source project until nowadays Mule is based on Java
  • 7. 7 From open-source to the Anypoint Platform ● Mule Runtime: ○ Java under the hoods ○ Lightweight ESB ○ Scalable ○ EDA ○ Automatic thread controls ○ Streaming ○ Batch ○ Persistent queues ○ Cache Mule
  • 8. 8 From open-source to the Anypoint Platform ● Connectors & modules ○ 200+ connectors ○ Salesforce, SAP, Workday and more... ○ Plug & Play ○ Databases, Queues, File and more... ○ Connect everything ○ Extend with the SDK Mule Anypoint Connectors
  • 9. 9 From open-source to the Anypoint Platform ● Design & Portals ○ Design your APIs first ○ Mock and console ○ Publish your assets ○ Create API Portals ○ Discover APIs and fragments Anypoint Design Center Anypoint Exchange Studio API Designer Connector DevKit Mule Anypoint Connectors
  • 10. 10 From open-source to the Anypoint Platform ● Management & Monitoring ○ Manage your APIs & Integrations ○ Monitoring ○ Alerts ○ Secure APIs ○ Out-of-the box policies ○ Custom policies Anypoint Design Center Anypoint Management Center Anypoint Exchange Studio API Designer Connector DevKit Runtime Manager API Manager Analytics Mule Anypoint Connectors
  • 11. 11 From open-source to the Anypoint Platform Anypoint Design Center Anypoint Management Center Anypoint Exchange Studio API Designer Connector DevKit Runtime Manager API Manager Analytics Runtime Services Mule Anypoint Connectors ● Run & Scale ○ Run on Cloud, On-Prem or Hybrid ○ Easy to deploy ○ Scale ○ Run with Kubernetes ○ Object Store and Queues ○ Cloud MQ Message Broker
  • 13. Use case 13 ● Create an API to integrate with Salesforce ● Query Contacts and return as JSON format
  • 14. “Doing It All” with MuleSoft (clone full working demo from: https://github.com/gui1207/sfdc-contacts-sys-api)
  • 16. Step 1: Design the API Contract 16
  • 17. Step 2: Implement & Test locally 17
  • 20. “Doing It All” with Spring Boot (clone full working demo from: https://github.com/thimotyb/salesforce-springboot-demo)
  • 21. Step 1: Connecting to SalesForce 21 - We will use the Enterprise SOAP API with the approach described at - https://developer.salesforce.com/docs/atlas.en- us.api.meta/api/sforce_api_quickstart_steps.htm - There are other you can use, e.g. Bulk API 2.0 https://developer.salesforce.com/docs/atlas.en- us.api_asynch.meta/api_asynch/api_asynch_introduction_bulk_api.htm - Or Streaming API https://developer.salesforce.com/docs/atlas.en- us.api_streaming.meta/api_streaming/intro_stream.htm - Download Enterprise WSDL for correct Salesforce Version from DevPortal - Use WSC tool to generate Java skeletons and Data Models of the entire Enterprise API - java –classpath pathToJAR/wsc-22.jar com.sforce.ws.tools.wsdlc pathToWsdl/WsdlFilename​ pathToOutputJar/OutputJarFilename - The WSDL is huge, lots of problems trying to auto-generate in-line with the maven jax2 tooling - An enterprise.jar system dependency specific for your Salesforce version is created, to be included in the project
  • 22. 22
  • 23. 23 - Service as a Singleton can be Autowired in implementation - Configuration is separated in application.proper ties and injected at service boot Step 1: Connection @Service
  • 24. 24 - The OAS YAML definition was provided and integrated in the project manually - Endpoint Controller Interface and Data Model are auto generated with openapi-generator-maven-plugin - Several other maven dependencies are necessary to make it properly work Step 2: Integrating the API Design
  • 25. 25 - The interface is generated in maven’s target dir and cannot be modified - Implementation should be done as separate @Service implementing this interface - Spring’s IOC will take care of the rest Step 2: Auto-generated Interface
  • 26. 26 - Each Endpoint is implemented as a Service - Implement the Auto-Generated Interface - Inject the Connector - Perform (Hard-code?) the query - Fetch the resulting Record - Handle Errors - Prepare the Response - DTO Mapping - From the Enteprise.jar library -> Data Model from the OAS Spec - Manually?! Step 3: Implementing the Endpoints
  • 27. 27 Step 3: Implementation Implement auto- generated interface Override interface default methods
  • 28. 28 Streaming/Paging? Use Bulk API 2.0 or Streaming API (CornetD) 1:1 Data Mapping across DTO’s? Hard-Coded Query?
  • 29. 29 - We use the following maven plugins - surefire for unit testing / spring mocks - springboot for packaging as single jar - docker plugin for containerization with Dockerfile - Package, install, create container with - mvn clean install docker:build (-DskipTests=true to skip tests?) - Also useful - maven release (auto-manage package versions / Release / Snapshot) - use push goal to push container to Docker Registry Step 4: DevOps
  • 30. 30 - We will use a Minikube free instance at https://katacoda.com/javajon/courses/kubernetes-fundamentals/minikube - Create a deployment, expose as a LoadBalanced service, check the status: - kubectl create deployment salesforce-service --image=thimoty/salesforce-service - kubectl expose deployment salesforce-service --port=80 --target-port=8080 -- type=LoadBalancer - kubectl get po,svc -o wide - The service is now reachable and deployment can be scaled up/down - Need a Service Mesh (e.g. Istio) for Proxy Handling Step 5: Deploy
  • 31. 31 - k8s Dashboard - Need to setup Prometheus/Graphana - Need to setup ELK Stack - Config Backup: Velero - Security? Certificates? - … LOTS of additional stuff on top of plain vanilla k8s!!! Step 6: Observability/Monitoring/Operations
  • 33. Task Comparison Table 33 Task SpringBoot MuleSoft Salesforce Connector: Prepare WSDL, Stub/Skeleton Download Enterprise API WSDL, use wsc to create dependency Just use the Salesforce Connector API Design Use OAS Maven endpoint generator plugin API Kit from Design Center Service Implementation Need to implement the interface, prepare the query, iterate the records, create ad- hoc error handling. No OOTB Paging/Streaming Just leverage Mule’s Streaming Saleforce connector, use Query, Trasform and Mule 3-tier error handling DTO Mapping Need to explicitly write “glue code” for each combination, choose the correct API typology (Enterprise, Partner, Batch, Streaming…) Use DataWeave!!! DevOps / Containerization Use Maven plugins and Dockerization with Dockerfile Just upload the Mule app to CloudHub!!!
  • 34. What is missing? 34 Task SpringBoot MuleSoft Security Add Spring Security, roll your own Load Balancers, install a Vault... Anypoint Platform provides integrated services such as: Vault, Secret Management, Safely Hidden Properties API Gateway Proxy - External API Manager Anypoint Platform provides integrated API Manager capabilities and out of the box policies Performance / Throughput Current implementation is pretty much sequential MuleSoft uses OTTB Spring Flux and Streaming under the hood and Logging Properly use log4j and Logstash (TBD) Anypoint Platform Logging Monitoring If running in a container, use the orchestrator’s monitoring facilities Anypoint Platform Monitoring Docker Image Maintenance Need to keep checking security of base images of containers. Implement Registry Scanner. Anypoint Runtime Fabric
  • 35. 35 ● Final thoughts: ○ Pain points: ■ Difficult to implement just using plain code ■ Need user libs to create skeleton ■ Implement auth methods ○ Implementing with Mule ■ Out of box Connectors ■ CloudHub / Monitoring / API Manager ■ Drag and drop Wrap up
  • 36. 36 ● Register to the Free MuleSoft Course: ○ https://mule.is/LearnMule ● Share: ○ Tweet using the hashtag #MuleSoftMeetups ○ Invite your network to join: https://meetups.mulesoft.com/mulesoft-for-java-developers/ ● Feedback: ○ Fill out the survey feedback and suggest topics for upcoming events ○ Contact MuleSoft at meetups@mulesoft.com for ways to improve the program What’s next?
  • 37. Your chance to win an Instructor-led MuleSoft course Trivia
  • 38. 38 ● You can win only 1 voucher per month, across all Meetups. If you already won 1 voucher in the month from another event, you will not receive a new one. ● The first 3 ranked in the game win a voucher ● Use your name in the game - avoid nicknames ● To request the voucher you should send a email to gui1207@gmail.com or use the "contact the organizer form" on the meetup group page ● If using Kahoot, go to kahoot.com with your browser on desktop or smartphone ○ Select “Play” ○ Type the Game PIN you are given during the session ○ The contest with kahoot could be capped, so only the first 100 users that log in get to participate Rules