Thursday, March 17, 2016

Create your first Mule application - Hello World


In  this  walkthrough,  you  will  build  your  first  Mule  application.  You  will:  

  • Create  a  new  Mule  project  with  Anypoint  Studio.
  • Add  a  connector  to  receive  requests  at  an  endpoint.
  • Display  a  message  in  the  Anypoint  Studio  console.
  • Set  the  message  payload.

  

Launch  Anypoint  Studio  

  • Open  Anypoint  Studio.
  • In  the  Workspace  Launcher  dialog  box,  look  at  the  location  of  the  default  workspace; change   the  workspace  location  if  you  want.
  • Click  OK  to  select  the  workspace; Anypoint  Studio  should  open.
  • If  you  get  a  Welcome  Page,  click  the  X  on  the  tab  to  close  it. 
  • If  you  get  an  Updates  Available  pop-­up  in  the  lower-­right  corner  of  the  application,  click  it  and   install  the  available  updates.  

Create  a  project  
  • Select  File  >  New  >  Mule  Project.
  • Set  the  Project  Name  to  helloworld.
  • Ensure  the  Runtime  is  set  to  the  latest  version  of  the  Mule  Server.
  • Click  Finish.  

Create  an  HTTP  connector  endpoint  to  receive  requests  
  • Drag  an  HTTP  connector  from  the  palette  to  the  canvas.
  • Double-­click  the  HTTP  connector  endpoint.
  • In  the  Mule  Properties  view,  click  the  Add  button  next  to  connector  configuration.
  • In  the  Global  Element  Properties  dialog  box,  look  at  the  default  values  and  click  OK.
  • Save the application.  
Display  data   
  • Drag  a  Set  Payload  transformer  from  the  palette  into  the  process  section  of  the  flow. 
  • Drag  in  a  Logger  component  and  drop  it  after  the  Set  Payload  transformer.  

Configure  the  Set  Payload  transformer 
  • Double-­click  the  Set  Payload  transformer.
  • In  the  Properties  view,  set  the  value  field  to  Hello  World.
  • Click  the  Configuration  XML  tab  at  the  bottom  of  the  canvas  and  examine  the  corresponding   XML.  
  • Click  the  Message  Flow  tab  to  return  to  the  canvas.
  • Click  the  Save  button  or  press  Ctrl+S  to  save  the  file.  

Run, test, and debug an application

In  this  walkthrough,  you  will  run,  test,  and  debug  your  first  Mule  application.  You  will:   •  
  • Run  a  Mule  application  using  the  embedded  Mule  runtime. 
  • Make  an  HTTP  request  to  the  endpoint  via  a  web  browser  or  a  tool  like  cURL  or  Postman. 
  • Receive  a  response  with  the  text  Hello  World. 
  • Use  the  Mule  Debugger  to  debug  an  application.
Run  the  application  
  • From  the  main  menu  bar,  select  Run  >  Run  As  >  Mule  Application.
  • Watch  the  Console  view;;  it  should  display  information  letting  you  know  that  both  the  Mule   runtime  and  the  apessentials  application  started.  

Test  the  application  

  • Send  an  HTTP  request  to  http://localhost:8081  through  a  browser  or  tool  like  cURL  or  Postman;;   you  should  see  Hello  World  displayed. 
  • Return  to  the  console  in  Anypoint  Studio. 
  • See the  last  entry.  

That's it. Thank you for visiting our blog. Keep visiting our blog will post more details Mule Studio.












3 comments: