Você está na página 1de 9

1)Expect everyone new to mule...shud ve java background...

better
2)what is mule and why mule....
3)challenges of not using mule
4)What is ESB
simple scenario
third party exposing web service using soap
dev app consume webservice u get wsdl...generate stub and use
api jaxws to consume soap ws...client app needs to know what is endpoint
url..and knws who is the service provider...thats what point to point
integration.
Point to Point integration
serv prov has changed the endpoint url...client need
modification...there is form of tight coupling bw client and server.client needs
to know who is serv provider.

third party is saying stop WS soap but use REST service...client code
rewritten using rest api...
whenever there is change in server side client needs to get updated...

What is the solution.


connected directly point to point problems
v ll talk abt messaging
MOM message oriented middleware.ex:activemq,ibmmq
conf dest in mom..
app2 creates jms msg and kept inside dest..
app1 waiting for msg in same dest and pick process the message
2 appls logicaly coupled to each other.. app2 need not know who is the
reciever of msg.
App1 using soap over jms ...exposing ws using jms.logicaly coupled...

App2 posting jms msg... jms msg will have some headers and payload it shud
be soap envelope(xml )needs to know how to create soap msg using soap
api.soap api is encapsulated in jms msg...
client need to know how to use jms api and soap api....
if third party i will exposing service using REst.. now client needs to use rest
api.. now problem still persist using broker....
Now last solution
App1 exposing soap ws
App2 conf dest in memory(jvm)... instead of dest in broker
App2 create msg in some format (propreitary) .. msg(headers and
payload)...kept in inmemory destination....some kind of adapter which knows
how take msg from dest and may invoke soap ws. i.e soap adapter...create
soap msg and send it to soap app...
app2 need not worry abt soap...becoz adapter converting proprietary msg to
soap msg..
client api need not know soap api...need to know how to create msg and
keeping in dest...
what is the adv?
1)if endpoint url is changed .. i will change the conf of adapter...client code is
nto changed
2)third party says if its exposed as rest ws...i will replace soap adapter with
rest adapter...client code not changed.. if am using in memory destination

assume
System expecting data in xml format.....
Application conf in memory dest .. keep in msg proprietary format...payload is
csv format....
csv has to be converted to xml ....so need to do transformation csv to xml...
on my machine... 2 destination....myapp over dest1 then configure comp
transformer will take csv to xml data then payload posted to dest2 then
adapter wil post it third party app.

one more requirment


App my thread posting msg into channel....(channel and adapter )to sap
app,salesforce app,facebook app
based on some prop of my msg it shud get routed to sap or salesforce or
facebook or twitter
so need comp which do routing ..called as router....

on more requirement
app posting msg on in memory dest.... and one more dest with adapter...
all msgs shudnt go to the third party app.. so i need filter which can filter
msgs based on some criteria...

Some framework which can provide adapter,transformer,filters,routes...


in Enterprise Integration Pattern...
In memory dest is called as msg channel..
adapter called as msg processor...
confi num of channels which r connected using message processors...
thread put msg on channel ..message processor wil pick it from channel then
process and send it next MP...

combination of channel and Message Processor is called Bus..


msg travelling from one location to other location using bus...

Then what is ESB..


u knw abt what is enterprise service like ejb...
container provide like transaction,security,remoting etc to normal java
classes...so u need not write code ..

similarly bus provides enterprise service called ESB

Our tool Mule as ESB....


ur logic require db transaction,u dont want to write the code.... these
transaction service provided by esb...no need to know whether it is local
service or remote service...

Why the name Mule?


Founder of Mule is Ross Masson... he wants name product as donkey
Donkey takes luggage from one location to location
Esb is carrier of data from one location to anth location.. so masson wants to
name as donkey..but this name was somewhat not good...so named as MULE

MULE ESB is framework which has readymade ...which avoids point to point
integration...
Anypoint platform third party communicate which contains mule esb
server..or mule app deployed inside cloudhub....
mule esb work with connector which can connect third party
fb,twitter,google...

create mule conf file with somename -1mulebasicdemo which is deployed on


muleserver..tak all def and finish
create diagram of one example...http endpoint will use http connector...will
listen on port..
http msg will be given to one more msg processor..i.e append string
transformer...browser will send hello.. and this append string srinivasa to
payload..and send it back

add some java code ..in present flow.....priceComponent..explain with paint...

for one flow v can have one message source...in one conf v can have multiple
flow....
httpinbound endpoint is message source....

is connector is same as adapter?


..
MuleMessage explain with diagram....
msgsrc(HIBE) channel mp channel mp channel mp
IBE is converting http message to Mule Message..
inbound properties... httpheaders...into inboud properties..immutable
outbound properties... show diagram
IBE mp mp mp OBE(outbound properties) ->transport specific header SOAP
WS
now show debuggin in anypoint..
message is of type DefaultMuleMessage...check inbound and outbound
properties of java component which is toggled break point.. then resume f8
go to next comp.
MEL show an example using debugger mode...stop at java component..u can
see x+y..
then type #[message.payload] #[payload]
#[message.inboundProperties['http.method']

same can be done #[header:inbound:http.method]


now show expression transformer example bcoz localhost:8081/bos payload
is /bos
which will convert to bos and use #[payload.substring(1)]

now if localhost:8081/hello?name=srini&city=blr
expression => appendstring
after the expression it shud be array... go to advanced return arguments
check thru debug mode

response application/atom-xml... browser understand mime type...


last mp make mime type text/plain
mule is built on top of spring..
whenever app deployed... spring object are created and kept in mule registry
mule startup it creates mule registry(key/value pairs).....with name ,
springobject...
spring bean is global element which dont belong to flow...which could be
referred by multiple flows..
Java method only accept payload...how to acccess inbound properties
,outbound inside method...
make javaclass implement callable. write logic inside oncall method ..
muleeventcontext object...
but business logic is mixed with mule api....java is not independent....
avoid mulespecific interfaces...
go for annotatedcomponent.
dependency injection ..annotated comp on pricecomponent
lookup using springbean which is available in mule registry...
lookup isnt reconized in spring bean

Testing ... Functional Testing


Dont write big flow...split into multiple flow.. so testing flow is easy
explain when muleserver by calling getconfigfile....
vm endpoint listen on in memory queue...
queue inside same jvm...thru testcase put message on queue.
vm is protocol independent endpoint which will listen message in inmemory
messages.
vmoutbound vs flowreference

vmbound puts copy of messsage on queue...outbound prop becomes inbound


of prop of msg
flowreference will use thesame msg......
if payload is xml doc...u can evaluate regex()

FIlter
testing flow... calc expects integer but if u pass string as payload.
whenever excption in flow...exceptionpayload in response..
payload filter before square java component with expected type Integer
when filter filtering msg return null if condition null...
if filter rejects msg will i get exception rather it return null....
to throw an exceptio from filter... use messagefilter->nested filter payload
filter expected type is integer throw on unaccepted...

Mule Variables...
MuleEvent contains mulemessage,mulevariables(flow var and session)
inbound prop set by message source...
flow var after inbound end point
Msgsrc will add inbound prop which are immutable....
outbound prop
comp will invoke third party ws....result of the ws within the flow use flow
scoped var...if u want for all scopes use session scoped var...if u put it in
outbound prop...its available in 2nd flow as inbound prop....
http

vm->

vm

vm>

vm

vm>

use an example property transformer copy inboud to outbound


copy all property *...

Message property transformer...delete,add,update multiple props...


flowreference is connecting 2nd flow from first flow..
read static file ..parseTemplate it gives plain code of html... so use mime
1)use property to set content-type text/html..becomes protocol specific
headerw
2)in http endpoint under http settings set contenttype text/html
how to deploy webapp in mule server..and content based routingy

connector endpoint
connector is diff... endpoint is diff..
IEP use connector internally

accessing database
select * from currentFlights where destination='SFO'
how to use database endpoint and make it global element
http endpoint -> database endpoint->connector conf - mysql confg give
parameter port 3306
mysql drive is on the path...
mysql conf is global element...
conns r not pooled....
then select operation ... then give the query
how to convert query result to string use object to string transfomer and
contetype is text/html
i got list of maps..for each and every row...

query is not reusable.. type is ....use template query...destination=:dest


input parameter dest #[payload.substing(1)]

dbpooling?
TransformerReference to global transformer

Consume SOAP Web Service.


HTTP->Soapwebservice consumer->dblclk->connector confi-> give wsdl
location ->enable datasense

add setpayload as plain text copy and paste soapui soap message to value

avoid hardcoding ...use datamapper


grf groovy file

op of datamapper is bytearray use ByteArrayToString


to remove mapping use script
main flow is waiting for subflow to finish it is synch call..to make it asynch put
flow reference in asynch scope

Você também pode gostar