Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

7

Share

Mule meetup Hyderabad

The content contains all about Mule 4 Error Handling and Iot with MuleSoft Integration.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Mule meetup Hyderabad

  1. 1. [21st Dec 2019] [Exception Handling in Mule 4 & IoT with MuleSoft Demo] [Hyderabad - India]
  2. 2. All contents © MuleSoft Inc. Sensitivity: General Agenda 2  Introductions  What is Exception handling  How to do Exception Handling in Mule 4  Error Handler  On Error Continue , On Error Propagate Try scope  Raise Error  Error handling generate by API-Kit Router IoT with MuleSoft Demo  Networking time
  3. 3. All contents © MuleSoft Inc. Sensitivity: General Introductions 3 • About the organizers: A SHOW OF HANDS: Who is new to this MeetUp?
  4. 4. All contents © MuleSoft Inc. Sensitivity: General Introductions 4 • About the sponsor & Introducing Guests :
  5. 5. All contents © MuleSoft Inc. Sensitivity: General Surprises! 5 • Thanks for your enthusiasm …You earned it .. off course FCFS  • Be geared up for the quiz sessions at the end of each module! 
  6. 6. All contents © MuleSoft Inc. Sensitivity: General Speaker 6
  7. 7. [Exception Handling]
  8. 8. All contents © MuleSoft Inc. Sensitivity: General What is Exception Handling 8 • An exception occurs when an unexpected event happens while processing. • Exception handling is the process of responding to exceptions when a computer program runs. • Exception handling attempts to gracefully handle these situations so that a program (or worse, an entire system) does not crash. • Exception handling can be performed at both the software (as part of the program itself) and hardware levels (using mechanisms built into the design of the CPU).
  9. 9. All contents © MuleSoft Inc. Sensitivity: General Different type of Errors/Exceptions 9 • In General Errors/Exceptions are categorized in 2 groups – Message Exception • Thrown with in a flow when mule event is involved – System Exception • Thrown with in a flow when no mule event is involved • Error that occur – During Mule Start up – When connection to External system fails
  10. 10. [Exception Handling in Mule 4]
  11. 11. All contents © MuleSoft Inc. Sensitivity: General Message Exception Handling in Mule 4 11 • Like any programming language Mule also provide ways to handle exception. • In Mule we can handle the message exception at different level. – At Project level using Default error handler – At Project level using Custom Global error handler – At Flow level in exception handling using On Error Continue and On Error Propagate, Raise Error – With in Flow or at processor level using try scope
  12. 12. All contents © MuleSoft Inc. Sensitivity: General Message Exception Handling in Mule 4 12 • When an event is being processed through a Mule flow that throws an error – Normal flow execution stops – The event is passed to the first processor in the error handler
  13. 13. All contents © MuleSoft Inc. Sensitivity: General Information about error 13 • When a error is thrown, an error object is created • Two of error object properties are – error.description – a string – error.errorType – an object • Error type is identified by namespace and indentifier – HTTP:UNATHORIZED
  14. 14. All contents © MuleSoft Inc. Sensitivity: General Error Type hierarchy 14 • Like in Java class/object follow hierarchy in mule error types also follow hierarchy • Each Error type has a parent • The error type ANY is the most general parent like Object class is the parent class of all the classes in java by default.
  15. 15. All contents © MuleSoft Inc. Sensitivity: General Error Type hierarchy reference 15
  16. 16. [Error Handler]
  17. 17. All contents © MuleSoft Inc. Sensitivity: General Error Handler in Java 17 Try { //Processing //... //... } Catch (err) { //Catch exception and do processing //... //... }
  18. 18. All contents © MuleSoft Inc. Sensitivity: General Default Global Error Handler 18 • If there is no error handling written at any of the levels, the Mule Default Error Handler is used, which stops the execution of the flow and logs the exception. • The Mule Default Error Handler is not configurable but, can be replaced by our Custom Global error handler by creating a Configuration global element.
  19. 19. All contents © MuleSoft Inc. Sensitivity: General Custom Global Error Handler 19 • To handle errors at the application level, we can add an error handler in the global.xml (or simply outside a flow). • Then, create a Configuration element in the global elements, which sets the Global Error Handler as the Default Error Handler.
  20. 20. [On Error Propagate]
  21. 21. All contents © MuleSoft Inc. Sensitivity: General On Error Propagate 21 • All processors within error handling scope are executed • At the end of the flow – Rest of the flow that threw error does not executed – The error is rethrown up to the next level and handled there • An HTTP listener return error response with default status code 500
  22. 22. All contents © MuleSoft Inc. Sensitivity: General Visualize On Error Propagate like Java 22 Try { //Processing //... //... } Catch (err) { //Catch exception and do processing //... //Re-Thorough error }
  23. 23. [On Error Continue]
  24. 24. All contents © MuleSoft Inc. Sensitivity: General On Error Continue 24 • All processor within error handling scope executed • At the end of the flow – Rest of the flow that threw error does not executed – The event is passed up to the next level as if flow execution had completed successfully • An HTTP listener return success response with default status code 200
  25. 25. All contents © MuleSoft Inc. Sensitivity: General Visualize On Error Continue like Java 25 Try { //Processing //... //... } Catch (err) { //Catch exception and do processing //... //Success and continue normal path }
  26. 26. Lets get our hands dirty
  27. 27. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 0 27
  28. 28. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 0 - Execution 28
  29. 29. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 1 29
  30. 30. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 1 - Execution 30
  31. 31. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 2 31
  32. 32. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 2 - Execution 32
  33. 33. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 3 33
  34. 34. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 3 - Execution 34
  35. 35. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 4 35
  36. 36. All contents © MuleSoft Inc. Sensitivity: General Error handling scenario 5 - Execution 36
  37. 37. Let’s Play the Game of Errors! 15- scenarios
  38. 38. How Can we Make a For loop keep Running even if a record fails during looping ?
  39. 39. [Try scope]
  40. 40. All contents © MuleSoft Inc. Sensitivity: General Handling errors with flow – Try Scope 40 • Using try scope we can handle error within a flow • Try scope give us more control to handle error at processor level • One and more processors can be added in try scope • Try scope have its own error handling section
  41. 41. All contents © MuleSoft Inc. Sensitivity: General Handling errors with flow - Execution 41
  42. 42. All contents © MuleSoft Inc. Sensitivity: General Custom error types 42 • When you have same processor which can throw exception in a flow at multiple places we can use custom error types to distinguish/differentiate which component/processor have raised the exception • You assign custom namespace and identifier to differentiate them from other existing types • Do not use existing module namespaces
  43. 43. [Raise Error]
  44. 44. All contents © MuleSoft Inc. Sensitivity: General Raising custom errors 44 • Apart from mapping existing error to custom error mule also provide to raise custom exceptions • Raise error give us freedom to raise custom exception
  45. 45. All contents © MuleSoft Inc. Sensitivity: General Raising custom errors - Execution 45
  46. 46. [Error handling generate by API-Kit Router]
  47. 47. All contents © MuleSoft Inc. Sensitivity: General Error handling generate by API-Kit Router 47 • By default, interfaces created with APIkit have error handlers with multiple On Error Propagate scopes that handle API-kit errors – The error scopes set HTTP status codes and response messages • The main routing flow has six error scopes – APIKIT: BAD_REQUEST > 400 – APIKIT:NOT_FOUND > 404 – APIKIT:METHOD_NOT_ALLOWED > 405 – APIKIT:NOT_ACCEPTABLE > 406 – APIKIT:UNSUPPORTED_MEDIA_TPYE > 415 – APIKIT: NOT_IMPLEMENTED > 501
  48. 48. All contents © MuleSoft Inc. Sensitivity: General Error handling generate by API-Kit Router 48 • In most cases the default generated error scopes are sufficient • You can modify default generated error scopes and even can add new error scopes as per your requirement
  49. 49. All contents © MuleSoft Inc. Sensitivity: General System Exception Handling in Mule 4 49 • System exceptions can be handled in mule using retry/reconnection and Until Successful
  50. 50. All contents © MuleSoft Inc. Sensitivity: General Difference between Error Handling in Mule 3 & 4 50 Mule 4 Mule 3 On Error Continue, On Error Propagate, Try Scope are new options available Catch, Choice and Reference exception strategy are the few option available Error handling can be done at processor level using try scope It was not possible in Mule 3 Error Handling at sub-flow is possible using try scope It was not possible in Mule 3 Transaction are possible using try scope Rollback strategy need to use to undo transaction in case of errors Custom Errors can be raised using Raise Error It was not possible in Mule 3 Custom Error mapping of existing exception is possible It was not possible in Mule 3 Easier and more granular error handling is possible It was little bit difficult to implement error handling
  51. 51. [IoT + MuleSoft]
  52. 52. All contents © MuleSoft Inc. Sensitivity: General What is IoT • The Internet of Things (IoT) is the network of physical devices, vehicles, and other items embedded with electronics, software, sensors, actuators, and network connectivity which enable these objects to collect and exchange data. • The Scope of IoT is not limited to just connecting things (device, appliances,machines) to the Internet. • IoT allows these things to communicate and exchange data (control&information)
  53. 53. All contents © MuleSoft Inc. Sensitivity: General What is IoT + MuleSoft • Mule engine can be embedded directly into IoT devices, which enables data exchange for the devices by connecting to IoT cloud services and backend apps in the cloud. • The Mule Runtime engine can be used to expose APIs on any IoT device. Mule APIs can be deployed on IoT devices and turn them on and off. • In this presentation we will discuss about IOT and how it can be used with Mulesoft and how Mule APIs can be deployed on IoT devices
  54. 54. All contents © MuleSoft Inc. Sensitivity: General 54 IoT – MuleSoft – Use Case
  55. 55. All contents © MuleSoft Inc. Sensitivity: General 55 IoT – MuleSoft – Use Case RESTful Call by passing receiver’s phoneNumber Store The Details Send SMS via Twilio Sense The Temperature
  56. 56. Let’s Cook The Recipe!
  57. 57. All contents © MuleSoft Inc. Sensitivity: General Things Required : IoT – MuleSoft Use Case 57 • Software Requirements: – Rasbian OS - https://www.raspberrypi.org/downloads/raspbian/ – SD formatter - https://www.sdcard.org/downloads/formatter/ – Xming Display Server -https://xming.en.softonic.com/ – PuTTY - https://www.putty.org/ – WinSCP - https://winscp.net/eng/download.php – Mule Standalone Server (4.2.2)
  58. 58. All contents © MuleSoft Inc. Sensitivity: General Things Required : IoT – MuleSoft Use Case 58 • Hardware Requirements:
  59. 59. Raspberry Pi Setup 59
  60. 60. All contents © MuleSoft Inc. Sensitivity: General Procedure Raspberry Pi Setup 60 Installation of Rasbian OS :  Download Rasbian OS from https://www.raspberrypi.org/downloads/raspbian/  Raspbian Buster with desktop and recommended software.  Used 16gb SD card and format it using SD formatter.  Unzip the downloaded OS and paste it in SD card
  61. 61. Network & Sharing 61
  62. 62. All contents © MuleSoft Inc. Sensitivity: General Procedure Network & Sharing 62 Connecting to UI interface:  2 ways to connect: Via HDMI Cable Via Ethernet  We are going with Ethernet for this Demo!  Connect Lan from your Raspberry Pi LAN port to Laptop LAN port. Power up your PI  Open Network and Sharing and do necessary configurations.  Use putty to connect to Rasbian PI  Use Xming for UI  Enable SSH
  63. 63. All contents © MuleSoft Inc. Sensitivity: General Network & Sharing 63
  64. 64. All contents © MuleSoft Inc. Sensitivity: General Network & Sharing 64
  65. 65. All contents © MuleSoft Inc. Sensitivity: General Network & Sharing 65
  66. 66. All contents © MuleSoft Inc. Sensitivity: General Network & Sharing 66 Xming Screen
  67. 67. Mule Standalone Installation 67
  68. 68. All contents © MuleSoft Inc. Sensitivity: General Mule Standalone Installation 68 • Install Java 8 if not present (By default your Rasbian OS has latest version of Java ) • Create a user & a directory with necessary permissions.
  69. 69. All contents © MuleSoft Inc. Sensitivity: General Mule Standalone Installation 69 • Download latest Mule Standalone (4.2.2 in this case) • 2 ways we can : – Download using Linux command : Use mule@raspberrypi:/opt/mule $ tar zxf mule-standalone-4.2.2.tar.gz to unzip – Go to Browser and Download zip directly from : • https://www.mulesoft.com/lp/dl/mule-esb-enterprise • Extract it using below command : • mule@raspberrypi:/opt/mule $ unzip zxf mule-standalone-4.2.2.zip to unzip mule@raspberrypi:~ $ cd /opt/mule mule@raspberrypi:/opt/mule $ wget https://repository- master.mulesoft.org/nexus/content/repositories/releases/org /mule/distributions/mule-standalone/4.1.1/mule-standalone- 4.2.2.tar.gz
  70. 70. All contents © MuleSoft Inc. Sensitivity: General Mule Standalone Installation 70 • Download latest Mule Standalone (4.2.2 in this case) • 2 ways we can : – Download using Linux command : Use mule@raspberrypi:/opt/mule $ tar zxf mule-standalone-4.2.2.tar.gz to unzip – Go to Browser and Download zip directly from : • https://www.mulesoft.com/lp/dl/mule-esb-enterprise • Extract it using below command : • mule@raspberrypi:/opt/mule $ unzip zxf mule-standalone-4.2.2.zip to unzip mule@raspberrypi:~ $ cd /opt/mule mule@raspberrypi:/opt/mule $ wget https://repository- master.mulesoft.org/nexus/content/repositories/releases/org /mule/distributions/mule-standalone/4.1.1/mule-standalone- 4.2.2.tar.gz
  71. 71. All contents © MuleSoft Inc. Sensitivity: General Mule Standalone Installation 71 • Additional Config Files Needed mule@raspberrypi:/opt/mule $ wget https://download.tanukisoftware.c om/wrapper/3.5.34/wrapper-linux-armhf-32-3.5.34.tar.gz tar zxf wrapper-linux-armhf-32-3.5.34.tar.gz mule@raspberrypi:/opt/mule $ cp ./wrapper-linux-armhf-32-3.5.34/lib/l ibwrapper.so ./mule-standalone-4.2.2/lib/boot/libwrapper-linux-armhf- 32.so mule@raspberrypi:/opt/mule $ cp ./wrapper-linux-armhf-32-3.5.34/lib/ wrapper.jar ./mule-standalone-4.2.2/lib/boot/wrapper-3.2.3.jar mule@raspberrypi:/opt/mule $ cp ./wrapper-linux-armhf-32-3.5.34/bin/ wrapper ./mule-standalone-4.2.2/lib/boot/exec/wrapper-linux-armhf-3 2
  72. 72. All contents © MuleSoft Inc. Sensitivity: General Mule Standalone Installation 72 • Edit the files: mule@raspberrypi:/opt/mule $ cd ./mule-standalone-4.2.2/bin mule@raspberrypi:/opt/mule/mule-standalone-4.2.2/bin $ vi mule mule@raspberrypi:/opt/mule/mule-standalone-4.2.2/bin $ cd ../conf mule@raspberrypi:/opt/mule/mule-standalone-4.2.2/conf $ vi wrapper.conf # Initial Java Heap Size (in MB) wrapper.java.initmemory=256 # Maximum Java Heap Size (in MB) wrapper.java.maxmemory=512
  73. 73. All contents © MuleSoft Inc. Sensitivity: General Mule Standalone Installation 73 Deploy : mule@raspberrypi:/opt/mule/mule-standalone-4.2.2/conf $ cd ../bin mule@raspberrypi:/opt/mule/mule-standalone-4.2.2/bin $ ./mule
  74. 74. Develop and Deploy Mule Application 74
  75. 75. All contents © MuleSoft Inc. Sensitivity: General Develop Mule App 75
  76. 76. All contents © MuleSoft Inc. Sensitivity: General Required Python Scripts Develop Mule App 76
  77. 77. All contents © MuleSoft Inc. Sensitivity: General PIN Configuration Develop Mule App 77
  78. 78. All contents © MuleSoft Inc. Sensitivity: General PIN Configuration Develop Mule App 78
  79. 79. All contents © MuleSoft Inc. Sensitivity: General Deploy app: • As the Mule server is up and running, place the snapshot of your application in apps folder. Application is deployed! Deploy Mule App 79 Let’s do a Live Demo
  80. 80. All contents © MuleSoft Inc. Sensitivity: General Pain Points! Points to be remembered! 80 • Make sure you are working on Linux OS and you will need necessary permissions on file to execute them. • Java Installation • Make sure you use Resistors and sensors properly • Network Connectivity • Be familiar with Linux commands
  81. 81. All contents © MuleSoft Inc. Sensitivity: General We are Good! 81
  82. 82. Q & A
  83. 83. All contents © MuleSoft Inc. Sensitivity: General Take a stand ! 83 • Nominate yourself for the next meetup speaker and suggest a topic as well.
  84. 84. All contents © MuleSoft Inc. Sensitivity: General What’s next 84 • Share: – Tweet/share in LinkedIn , facebook, Instagram with your pictures with the hashtag #HyderabadMuleMeetup #MuleSoftMeetup – Also use #BringMuleSoftConnectToHyderabad to reach our wish to MuleSoft  – Invite your network to join: https://meetups.mulesoft.com/hyderabad/ • Feedback: – Please fill out the slips with details like are you new to Mule? If so what technology you are currently working , What makes you to think of adopting MuleSoft and what topic you are expecting in future Meetups – Contact MuleSoft at meetup@mulesoft.com for ways to improve the program – Instagram Page for Hyderabad to be created – Your Feedback is Food for us • Our next meetup: – Date: TBD – Location: Hyderabad – Topic: TBD
  85. 85. Networking time Introduce yourself to your neighbors!
  86. 86. See you next time Please send topic suggestions to the organizer
  87. 87. THANK YOU
  • mail2kumaroaf

    Dec. 30, 2019
  • SumanthKathera

    Dec. 26, 2019
  • SairamHazare

    Dec. 25, 2019
  • madhankumarkancharla

    Dec. 25, 2019
  • MuraliMalli

    Dec. 24, 2019
  • jeevanjoseph

    Dec. 24, 2019
  • venureddymasu

    Dec. 23, 2019

The content contains all about Mule 4 Error Handling and Iot with MuleSoft Integration.

Views

Total views

984

On Slideshare

0

From embeds

0

Number of embeds

695

Actions

Downloads

0

Shares

0

Comments

0

Likes

7

×