October 24th, 2018
Warsaw Group
All contents © MuleSoft Inc.
Our Partners
2
All contents © MuleSoft Inc.
Share
3
• Share the Meetup
• Use Hashtags
– #MuleMeetup
– #WarsawMuleMeetup
Agenda
All contents © MuleSoft Inc.
Agenda
5
6:00 PM Introductions
6:15 PM Topic 1 - Introducing Mule 4
7:00 PM Break
7:15 PM Topic 2 – Encryption Demo
8:00 PM What’s next and Q&A
Introduction
All contents © MuleSoft Inc.
Organiser & Speaker
7
• Senior Integration Developer at PwC Poland
• MuleSoft Meetup Leader for Warsaw, Poland
• Recognized by MuleSoft as one of the top
contributors in the MuleSoft Community
• Doing Mule for over 7 years now
All contents © MuleSoft Inc.
Speaker
8
• Senior Integration Developer at PwC Poland
• 10 years professional experience as a
developer
• 8 years professional experience in integration
Introduction
Mule 4
All contents © MuleSoft Inc.
Mule Runtime Release Notes
10
Anypoint Studio 7
Mule 4
All contents © MuleSoft Inc.
Anypoint Studio 7
12
• Only Mule 4 Runtime's are supported
• All project are mavenized by default
Event-Driven Architecture
Mule 4
All contents © MuleSoft Inc.
Mule Event
Event-Driven Architecture
14
• Core information processed by the
runtime
• Immutable
• New structure
– Message payload
– Message attributes
– Variables
All contents © MuleSoft Inc.
Event Sources
Event-Driven Architecture
15
• First component that receives
triggering event
• Create Mule Event object
Event Processors
• Processes the Mule Event
• Returns new Mule Message
• Available are:
– Operations from connectors
– Core components like router
Mule message
Mule 4
All contents © MuleSoft Inc.
Mule 3 message
Mule message
17
Mule 4 message
All contents © MuleSoft Inc.
Attributes
Mule message
18
• New scope
• Replaces inbound and outbound properties
HTTP
FTP
JMS
All contents © MuleSoft Inc.
Mule 3
Mule message’s attributes
19
• Get query parameter ‚PIN’
#[message.inboudProperties.’http.query
.params’.PIN]
• Get header ‚X-User’
#[message.inboundProperties.’headers’.
’X-User’]
Mule 4
• Get query parameter ‚PIN’
#[attributes.queryParams.PIN]
• Get header ‚X-User’
#[attributes.headers.’X-User’]
All contents © MuleSoft Inc.
Outbound properties?
20
• Headers are set directly by developer
• No implicit get from attributes
• Dedicated forms in GUI
• Set using DataWeave
Data Weave 2.0
Mule 4
All contents © MuleSoft Inc.
Introduction
DataWeave
22
• Entirely replaces everything that MEL does
• Default language
• Syntax changes
• Modularization
• And many more …
MEL
MEL stands for Mule
Expression Language
All contents © MuleSoft Inc.
Subtle changes
DataWeave changes
23
• New version 2.0
• Every directive is written without %
sign
• Functions are now declares using fun
keyword
• Type names
– Without : char
– First upper case letter
• as String
• as Date
as :string
as String
All contents © MuleSoft Inc.
Operators
DataWeave
24
• All operators are functions now
sizeOf payload filter $.age > 30
sizeOf(filter(payload, (value) → value.age > 30)))
sizeOf(payload filter $.age > 30)
All contents © MuleSoft Inc.
Conditional logic
DataWeave changes
25
• If else and else if
WHEN
UNLESS
OTHERWISE
All contents © MuleSoft Inc.
Modules
DataWeave
26
• Functionality grouped within modules
• Similar concept like with Java packages
• Core functions are imported by default
• We may create are own modules
• Importing
– import dw::core::Arrays
– import * from dw::core::Arrays
– import countBy, sumBy from dw::core::Arrays
All contents © MuleSoft Inc.
Java Module
DataWeave
27
• Calling static Java methods
• Import with java! prefix
All contents © MuleSoft Inc.
External scripts
DataWeave
28
• Syntax ${file::filename}
• Send script in dwl file through any XML tag that expects an epxression
• When expression=”${file::extra-logic.dwl}”
Implicit transformations
Mule 4
All contents © MuleSoft Inc.
Mule 3 components
Transformation components
30
• Transform one type into
another
• Needed before DataWeave
transformation or routing
logic
• A lot !
Mule 4 components
• Greatly reduced
number of
transformation
components
• Implicit casting
All contents © MuleSoft Inc.
Not working example
Transformation in Mule 3
31
• Input
– Type: json
– Value:
• Flow
What will happen at
line 4?
All contents © MuleSoft Inc.
What will happen at line 4?
Transformation in Mule 3
32
1. An exception will be thrown
2. Payload.id will evalute to empty value
3. Payload.id will evaluate to value „a-k”
All contents © MuleSoft Inc.
What will happen at line 4?
Transformation in Mule 3
33
1. An exception will be thrown
2. Payload.id will evalute to empty value
3. Payload.id will evaluate to value „a-k”
All contents © MuleSoft Inc.
Working example
Transformation in Mule 3
34
• Inserted transformation at line 3
• Converts JSON byte input stream into an object
• MEL, at line 4, is able to evaluate expression
All contents © MuleSoft Inc.
Working example
Transformation in Mule 4
35
• Input
– Type: json
– Value
Error Handling
Mule 4
All contents © MuleSoft Inc.
Error object
37
• Accessible by using error keyword
• Error introduce abstraction layer
All contents © MuleSoft Inc.
On Error Propagate
Error Handling
38
• Re-throw the error
On Error Continue
• This strategy you can use when you
want to handle an error and process
further flow as if nothing has
happened
• Especially useful in Try-Catch scope
All contents © MuleSoft Inc.
Try-Catch scope
Error Handling
39
• Error handling strategy in the middle of the flow
• Encapsulate at least one event processor
• There is no longer need to create a flow for specific error
Modules
Mule 4
All contents © MuleSoft Inc.
Modularization
41
• Connectors are modularized
• Separated from Mule Server Runtime
• Packaged in deployable archive
• GUI support for adding modules
– Quick find in Mule Palette
– Adding by maven
Break
Networking time
New way of using Secure Property Placeholder
Security in Mule 4
All contents © MuleSoft Inc.
What new in secure placeholder
44
• New way to add secure placeholder into project using Exchange
• New tool responsible for encryption / decryption process
• New secure prefix required to use for secure placeholder
• Ability to share security placeholder via domain project
All contents © MuleSoft Inc.
Demo walkthrough
45
• Create new application and simple flow with http input and logger
• Create property file in yaml
• Generate security key:
– https://asecuritysite.com/encryption/keygen
• Download secure-properties-tool:
– https://docs.mulesoft.com/mule4-user-guide/v/4.1/secure-configuration-properties
• Encrypt property file:
– java -jar secure-properties-tool.jar file encrypt AES CBC key properties.yaml properties2.yaml
• Add secure placeholder from Exchane
• Configure secure placeholder and copy encrypted property file
• Change logger:
– DB Login: ${secure::database.login} Password: ${secure::database.password}
All contents © MuleSoft Inc.
Demo walkthrough
46
• Create new domain project
• Add domain to mule project
• Move secure placeholder dependency to domain pom.xml
• Add empty property configuration
• Move properties.yaml do domain project
All contents © MuleSoft Inc.
Tricky question
47
We would like to use secure property placeholder to read property that
is not encrypted. What is the correct sentence if we assume that the
key name is key1:
1. It is not possible to use secure property to read unencrypted data
2. We can do this using ${key1} syntax because of unencrypted value
3. We need to use 'secure' prefix to read unencrypted data,
${secure::key1}
4. Botha 2 and 3 are correct
All contents © MuleSoft Inc.
Tricky question’s answer
48
We would like to use secure property placeholder to read property that
is not encrypted. What is the correct sentence if we assume that the
key name is key1:
1. It is not possible to use secure property to read unencrypted data
2. We can do this using ${key1} syntax because of unencrypted value
3. We need to use 'secure' prefix to read unencrypted data,
${secure::key1}
4. Botha 2 and 3 are correct
All contents © MuleSoft Inc.
DataWeave question
49
We have a java class MuleMeetup in com.mulesoft.meetup package.
How can I import it within DataWeave
1. It is not possible to import java class in DataWeave
2. Import com::mulesoft::meetup::MuleMeetup
3. Import java!com.mule.mulesoft.meetup.MuleMeetup
4. Import java!com::mule::mulesoft::meetup::MuleMeetup
All contents © MuleSoft Inc.
DataWeave question
50
We have a java class MuleMeetup in com.mulesoft.meetup package.
How can I import it within DataWeave
1. It is not possible to import java class in DataWeave
2. Import com::mulesoft::meetup::MuleMeetup
3. Import java!com.mule.mulesoft.meetup.MuleMeetup
4. Import java!com::mule::mulesoft::meetup::MuleMeetup
All contents © MuleSoft Inc.
DataWeave question
51
We have a java class MuleMeetup with static function open(String
welcom). How we can invoke this function in DataWeave?
The class is import like below
Import java!com.mulesoft.MuleMeetup
1. MuleMeetup.open(„Welcome”)
2. MuleMeetup:open(„Welcome”)
3. MuleMeetup::open(„Welcome”)
4. MuleMeetup::open „Welcome”
All contents © MuleSoft Inc.
DataWeave question
52
We have a java class MuleMeetup with static function open(String
welcom). How we can invoke this function in DataWeave?
The class is import like below
Import java!com::mulesoft::MuleMeetup
1. MuleMeetup.open(„Welcome”)
2. MuleMeetup:open(„Welcome”)
3. MuleMeetup::open(„Welcome”)
4. MuleMeetup::open „Welcome”
What’s next
All contents © MuleSoft Inc.
What’s next
54
• Feedback:
– Contact your organizer Patryk Bandurski to suggest topics
– Contact MuleSoft at meetup@mulesoft.com for ways to improve the program
• Our next meetup:
– Date: January 2019
– Location: PwC Poland
– Topic: DataWeave 2.0
All contents © MuleSoft Inc.
What’s next
55
Invite your network to join
– https://meetups.mulesoft.com/warsaw/
See you next time
Please send topic suggestions to the organizer
MuleSoft  Meetup Warsaw Group #1

MuleSoft Meetup Warsaw Group #1

  • 1.
  • 2.
    All contents ©MuleSoft Inc. Our Partners 2
  • 3.
    All contents ©MuleSoft Inc. Share 3 • Share the Meetup • Use Hashtags – #MuleMeetup – #WarsawMuleMeetup
  • 4.
  • 5.
    All contents ©MuleSoft Inc. Agenda 5 6:00 PM Introductions 6:15 PM Topic 1 - Introducing Mule 4 7:00 PM Break 7:15 PM Topic 2 – Encryption Demo 8:00 PM What’s next and Q&A
  • 6.
  • 7.
    All contents ©MuleSoft Inc. Organiser & Speaker 7 • Senior Integration Developer at PwC Poland • MuleSoft Meetup Leader for Warsaw, Poland • Recognized by MuleSoft as one of the top contributors in the MuleSoft Community • Doing Mule for over 7 years now
  • 8.
    All contents ©MuleSoft Inc. Speaker 8 • Senior Integration Developer at PwC Poland • 10 years professional experience as a developer • 8 years professional experience in integration
  • 9.
  • 10.
    All contents ©MuleSoft Inc. Mule Runtime Release Notes 10
  • 11.
  • 12.
    All contents ©MuleSoft Inc. Anypoint Studio 7 12 • Only Mule 4 Runtime's are supported • All project are mavenized by default
  • 13.
  • 14.
    All contents ©MuleSoft Inc. Mule Event Event-Driven Architecture 14 • Core information processed by the runtime • Immutable • New structure – Message payload – Message attributes – Variables
  • 15.
    All contents ©MuleSoft Inc. Event Sources Event-Driven Architecture 15 • First component that receives triggering event • Create Mule Event object Event Processors • Processes the Mule Event • Returns new Mule Message • Available are: – Operations from connectors – Core components like router
  • 16.
  • 17.
    All contents ©MuleSoft Inc. Mule 3 message Mule message 17 Mule 4 message
  • 18.
    All contents ©MuleSoft Inc. Attributes Mule message 18 • New scope • Replaces inbound and outbound properties HTTP FTP JMS
  • 19.
    All contents ©MuleSoft Inc. Mule 3 Mule message’s attributes 19 • Get query parameter ‚PIN’ #[message.inboudProperties.’http.query .params’.PIN] • Get header ‚X-User’ #[message.inboundProperties.’headers’. ’X-User’] Mule 4 • Get query parameter ‚PIN’ #[attributes.queryParams.PIN] • Get header ‚X-User’ #[attributes.headers.’X-User’]
  • 20.
    All contents ©MuleSoft Inc. Outbound properties? 20 • Headers are set directly by developer • No implicit get from attributes • Dedicated forms in GUI • Set using DataWeave
  • 21.
  • 22.
    All contents ©MuleSoft Inc. Introduction DataWeave 22 • Entirely replaces everything that MEL does • Default language • Syntax changes • Modularization • And many more … MEL MEL stands for Mule Expression Language
  • 23.
    All contents ©MuleSoft Inc. Subtle changes DataWeave changes 23 • New version 2.0 • Every directive is written without % sign • Functions are now declares using fun keyword • Type names – Without : char – First upper case letter • as String • as Date as :string as String
  • 24.
    All contents ©MuleSoft Inc. Operators DataWeave 24 • All operators are functions now sizeOf payload filter $.age > 30 sizeOf(filter(payload, (value) → value.age > 30))) sizeOf(payload filter $.age > 30)
  • 25.
    All contents ©MuleSoft Inc. Conditional logic DataWeave changes 25 • If else and else if WHEN UNLESS OTHERWISE
  • 26.
    All contents ©MuleSoft Inc. Modules DataWeave 26 • Functionality grouped within modules • Similar concept like with Java packages • Core functions are imported by default • We may create are own modules • Importing – import dw::core::Arrays – import * from dw::core::Arrays – import countBy, sumBy from dw::core::Arrays
  • 27.
    All contents ©MuleSoft Inc. Java Module DataWeave 27 • Calling static Java methods • Import with java! prefix
  • 28.
    All contents ©MuleSoft Inc. External scripts DataWeave 28 • Syntax ${file::filename} • Send script in dwl file through any XML tag that expects an epxression • When expression=”${file::extra-logic.dwl}”
  • 29.
  • 30.
    All contents ©MuleSoft Inc. Mule 3 components Transformation components 30 • Transform one type into another • Needed before DataWeave transformation or routing logic • A lot ! Mule 4 components • Greatly reduced number of transformation components • Implicit casting
  • 31.
    All contents ©MuleSoft Inc. Not working example Transformation in Mule 3 31 • Input – Type: json – Value: • Flow What will happen at line 4?
  • 32.
    All contents ©MuleSoft Inc. What will happen at line 4? Transformation in Mule 3 32 1. An exception will be thrown 2. Payload.id will evalute to empty value 3. Payload.id will evaluate to value „a-k”
  • 33.
    All contents ©MuleSoft Inc. What will happen at line 4? Transformation in Mule 3 33 1. An exception will be thrown 2. Payload.id will evalute to empty value 3. Payload.id will evaluate to value „a-k”
  • 34.
    All contents ©MuleSoft Inc. Working example Transformation in Mule 3 34 • Inserted transformation at line 3 • Converts JSON byte input stream into an object • MEL, at line 4, is able to evaluate expression
  • 35.
    All contents ©MuleSoft Inc. Working example Transformation in Mule 4 35 • Input – Type: json – Value
  • 36.
  • 37.
    All contents ©MuleSoft Inc. Error object 37 • Accessible by using error keyword • Error introduce abstraction layer
  • 38.
    All contents ©MuleSoft Inc. On Error Propagate Error Handling 38 • Re-throw the error On Error Continue • This strategy you can use when you want to handle an error and process further flow as if nothing has happened • Especially useful in Try-Catch scope
  • 39.
    All contents ©MuleSoft Inc. Try-Catch scope Error Handling 39 • Error handling strategy in the middle of the flow • Encapsulate at least one event processor • There is no longer need to create a flow for specific error
  • 40.
  • 41.
    All contents ©MuleSoft Inc. Modularization 41 • Connectors are modularized • Separated from Mule Server Runtime • Packaged in deployable archive • GUI support for adding modules – Quick find in Mule Palette – Adding by maven
  • 42.
  • 43.
    New way ofusing Secure Property Placeholder Security in Mule 4
  • 44.
    All contents ©MuleSoft Inc. What new in secure placeholder 44 • New way to add secure placeholder into project using Exchange • New tool responsible for encryption / decryption process • New secure prefix required to use for secure placeholder • Ability to share security placeholder via domain project
  • 45.
    All contents ©MuleSoft Inc. Demo walkthrough 45 • Create new application and simple flow with http input and logger • Create property file in yaml • Generate security key: – https://asecuritysite.com/encryption/keygen • Download secure-properties-tool: – https://docs.mulesoft.com/mule4-user-guide/v/4.1/secure-configuration-properties • Encrypt property file: – java -jar secure-properties-tool.jar file encrypt AES CBC key properties.yaml properties2.yaml • Add secure placeholder from Exchane • Configure secure placeholder and copy encrypted property file • Change logger: – DB Login: ${secure::database.login} Password: ${secure::database.password}
  • 46.
    All contents ©MuleSoft Inc. Demo walkthrough 46 • Create new domain project • Add domain to mule project • Move secure placeholder dependency to domain pom.xml • Add empty property configuration • Move properties.yaml do domain project
  • 47.
    All contents ©MuleSoft Inc. Tricky question 47 We would like to use secure property placeholder to read property that is not encrypted. What is the correct sentence if we assume that the key name is key1: 1. It is not possible to use secure property to read unencrypted data 2. We can do this using ${key1} syntax because of unencrypted value 3. We need to use 'secure' prefix to read unencrypted data, ${secure::key1} 4. Botha 2 and 3 are correct
  • 48.
    All contents ©MuleSoft Inc. Tricky question’s answer 48 We would like to use secure property placeholder to read property that is not encrypted. What is the correct sentence if we assume that the key name is key1: 1. It is not possible to use secure property to read unencrypted data 2. We can do this using ${key1} syntax because of unencrypted value 3. We need to use 'secure' prefix to read unencrypted data, ${secure::key1} 4. Botha 2 and 3 are correct
  • 49.
    All contents ©MuleSoft Inc. DataWeave question 49 We have a java class MuleMeetup in com.mulesoft.meetup package. How can I import it within DataWeave 1. It is not possible to import java class in DataWeave 2. Import com::mulesoft::meetup::MuleMeetup 3. Import java!com.mule.mulesoft.meetup.MuleMeetup 4. Import java!com::mule::mulesoft::meetup::MuleMeetup
  • 50.
    All contents ©MuleSoft Inc. DataWeave question 50 We have a java class MuleMeetup in com.mulesoft.meetup package. How can I import it within DataWeave 1. It is not possible to import java class in DataWeave 2. Import com::mulesoft::meetup::MuleMeetup 3. Import java!com.mule.mulesoft.meetup.MuleMeetup 4. Import java!com::mule::mulesoft::meetup::MuleMeetup
  • 51.
    All contents ©MuleSoft Inc. DataWeave question 51 We have a java class MuleMeetup with static function open(String welcom). How we can invoke this function in DataWeave? The class is import like below Import java!com.mulesoft.MuleMeetup 1. MuleMeetup.open(„Welcome”) 2. MuleMeetup:open(„Welcome”) 3. MuleMeetup::open(„Welcome”) 4. MuleMeetup::open „Welcome”
  • 52.
    All contents ©MuleSoft Inc. DataWeave question 52 We have a java class MuleMeetup with static function open(String welcom). How we can invoke this function in DataWeave? The class is import like below Import java!com::mulesoft::MuleMeetup 1. MuleMeetup.open(„Welcome”) 2. MuleMeetup:open(„Welcome”) 3. MuleMeetup::open(„Welcome”) 4. MuleMeetup::open „Welcome”
  • 53.
  • 54.
    All contents ©MuleSoft Inc. What’s next 54 • Feedback: – Contact your organizer Patryk Bandurski to suggest topics – Contact MuleSoft at meetup@mulesoft.com for ways to improve the program • Our next meetup: – Date: January 2019 – Location: PwC Poland – Topic: DataWeave 2.0
  • 55.
    All contents ©MuleSoft Inc. What’s next 55 Invite your network to join – https://meetups.mulesoft.com/warsaw/
  • 56.
    See you nexttime Please send topic suggestions to the organizer