Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
   3	
  
Classroom...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Session	
  Surv...
How to Thrive on REST/
WebSocket-based Microservices
	
  
	
  
Pavel	
  Bucek	
  (pavel.bucek@oracle.com)	
  
Michal	
  Ga...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Safe	
  Harbor	...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
IntroducFon	
  ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Why	
  are	
  w...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
What’s	
  alrea...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
QUESTION	
  
Ty...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Sample	
  appli...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
DEMO	
  
How	
 ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
QUESTION	
  
Wh...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
DEMO	
  
+CDI	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
QUESTION	
  
Do...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Micro-­‐service...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
<<Placeholder>>...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
<<Placeholder>>...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
DEMO	
  
<<Plac...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
QUESTION	
  
Ex...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Summary	
  
•  ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
What	
  do	
  w...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Java	
  8	
  +	...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
QUESTION	
  
Ja...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
OpFonal	
  in	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
OpFonal	
  in	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
OpFonal	
  in	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
ReacFve	
  Clie...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
ReacFve	
  Clie...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
ReacFve	
  Clie...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
ProgrammaFc	
  ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Lambdas	
  in	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Lambdas	
  in	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Lambdas	
  in	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Lambdas	
  in	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Streams	
  in	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Contacts	
  
• ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
Q	
  &	
  A	
  ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
  
	
  	
  
	
  	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  |	
   40	
  
How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based Microservices
Upcoming SlideShare
Loading in …5
×

How to Thrive on REST/WebSocket-Based Microservices

683 views

Published on

Presented on JavaOne 2015.

Take JAX-RS, WebSocket, and the idea of microservices; put the ingredients into a pressure cooker; raise the temperature; and let the experiments begin. In this session, you’ll witness a core foundation being cooked for building (micro-)applications using REST (JAX-RS) and WebSocket together, a foundation that is memory-efficient, fast, and easy to work with. And as a cherry on top, new features (lambdas) and types (streams, optionals, dates, and more) of Java 8 will be added into the mix of these Java EE technologies. Last but not least, the presenters want to hear about your encounters with running WebSocket and JAX-RS together. Do you run microservices-like deployments and have some unresolved issues or ideas about how that experience can be improved?

Github repo: https://github.com/pavelbucek/placeholder

Published in: Software
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
683
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
4
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

How to Thrive on REST/WebSocket-Based Microservices

  1. 1. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   3   Classroom  Training   Learning  SubscripFon   Live  Virtual  Class   Training  On  Demand   Keep  Learning  with  Oracle  University   educa7on.oracle.com   Cloud   Technology   ApplicaFons   Industries  
  2. 2. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Session  Surveys   Help  us  help  you!!   •  Oracle  would  like  to  invite  you  to  take  a  moment  to  give  us  your  session   feedback.  Your  feedback  will  help  us  to  improve  your  conference.     •  Please  be  sure  to  add  your  feedback  for  your  aQended  sessions  by  using   the  Mobile  Survey  or  in  Schedule  Builder.     4
  3. 3. How to Thrive on REST/ WebSocket-based Microservices     Pavel  Bucek  (pavel.bucek@oracle.com)   Michal  Gajdoš  (michal@sapho.com)     Oracle/Sapho   October  27,  2015   Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |  
  4. 4. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Safe  Harbor  Statement   The  following  is  intended  to  outline  our  general  product  direcFon.  It  is  intended  for   informaFon  purposes  only,  and  may  not  be  incorporated  into  any  contract.  It  is  not  a   commitment  to  deliver  any  material,  code,  or  funcFonality,  and  should  not  be  relied  upon   in  making  purchasing  decisions.  The  development,  release,  and  Fming  of  any  features  or   funcFonality  described  for  Oracle’s  products  remains  at  the  sole  discreFon  of  Oracle.   6  
  5. 5. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   IntroducFon   7  
  6. 6. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Why  are  we  doing  this?   •  Proof  of  concept   – Micro  is  the  new  black   – Very  small  runFme  can  deliver  key  funcFonality   •  JAX-­‐RS  (Jersey)  +  WebSocket  (Tyrus)   •  Java  SE  8  adopFon   •  ReacFve  APIs     8  
  7. 7. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   What’s  already  there?   •  Vert.x   •  Dropwizard   – JeQy,  Jersey,  Jackson,  …   – No  WebSocket   •  Glassfish  /  Payara   – JAX-­‐RS,  WebSocket,  Servlet,  JSF,  BV,  CDI,  …   – ~60MB     9  
  8. 8. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   QUESTION   Typical  produc7on  deployment  in  my  company  is:   Micro-­‐service  (small  containers,  dynamic  up/down  scaling)   Monolithic  applicaFon  (big  containers,  staFc  resources,  acFve/ passive  backup)   CombinaFon  of  previous   A   B   C   10  
  9. 9. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Sample  applicaFon   •  Simple  poll   – Jersey  MVC   •  Results  are  updated  based  on  new  votes   – WebSocket  connecFon  (could  be  SSE..)   •  Simple  filtering  (websocket  based)   – InteracFve  part  of  the  app   – WebSocket  are  more  efficient  to  use   11  
  10. 10. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   DEMO   How  does  the  Survey  app  works?   12  
  11. 11. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   QUESTION   Which  Java  framework  do  you  use  in  produc7on?   Java  EE  6+   Spring   Java  EE  5  (and  older)  +  Java  SE   Something  else,  text  us  what!   A   B   C   13   D  
  12. 12. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   DEMO   +CDI   14  
  13. 13. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   QUESTION   Do  you  use  WebSocket  in  produc7on?   Yes.   Not  yet,  but  we  plan  to.   No  (we  don’t  need  bi-­‐direcFonal  communicaFon).   No  (we  use  something  else).   A   B   C   15   D  
  14. 14. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Micro-­‐services   •  Simple,  small,  decoupled  standalone  “applicaFons”   – They  don’t  do  (and  provide)  anything  else  than  they  should   – Easy  to  develop  and  test   •  Fast  startup  Fme,  Fault  tolerant   – Dynamic  scaling   – CaQle  vs  Pet   16  
  15. 15. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   <<Placeholder>>   17  
  16. 16. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   <<Placeholder>>   •  Grizzly   – HTTP  container   •  HK2   – Dependency  InjecFon   •  Tyrus   – WebSocket  RI   •  Jersey   – JAX-­‐RS  RI   18  
  17. 17. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   DEMO   <<Placeholder>>   19  
  18. 18. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   QUESTION   Executable  JAR  size  (<<Placeholder>>  +  poll  app)  is:   ~100  MB   ~50  MB   ~20  MB   ~10  MB   ~5  MB   A   B   C   20   D   E  
  19. 19. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Summary   •  Glassfish   – Footprint:  >200  M   – Startup  Fme:  ~10  s   •  JeQy  +  Weld   – Footprint:  ~28  M   – Startup  Fme:  ~5  s   •  <<Placeholder>>   – Footprint:  ~11  M   – Startup  Fme:  ~1s   21  
  20. 20. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   What  do  we  miss?   22  
  21. 21. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Java  8  +  ReacFve  APIs   •  Lots  of  new  features  in  Java  8   •  Frameworks  slowly  up-­‐taking  new  APIs   •  OpFonal,  Lambdas,  Streams,  …   •  ReacFve  APIs  are  very  handy  when  you  are  accessing  more  services   – You  don’t  need  to  wait  (block)  for  the  answer   – Processing  hooked  to  “response(s)  received”   23  
  22. 22. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   QUESTION   Java  version  in  produc7on:   Java  5  (and  older)   Java  6   Java  7   Java  8   Java  9  (for  cuwng-­‐edge  enthusiasts)   A   B   C   24   D   E  
  23. 23. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   OpFonal  in  Jersey   •  Server   – Incoming  enFFes   – Return  values  (Outgoing  enFFes)   – @*Param  values   •  Client   – Outgoing  enFFes   25  
  24. 24. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   OpFonal  in  Jersey   26  
  25. 25. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   OpFonal  in  Jersey   27  
  26. 26. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   ReacFve  Client  API  in  Jersey/JAX-­‐RS  2.1   •  UFlize  the  reacFve  programming  model  when  using  Jersey/JAX-­‐RS  Client   •  Already  in  Jersey   – Java  8  –  CompleFonStage   – RxJava   – Guava   •  Will  be  in  JAX-­‐RS  2.1   28  
  27. 27. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   ReacFve  Client  API  –  Jersey  &  RxJava   29  
  28. 28. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   ReacFve  Client  API  –  JAX-­‐RS  2.1  &  CompleFonStage   30  
  29. 29. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   ProgrammaFc  Resources  in  Jersey   31  
  30. 30. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Lambdas  in  Tyrus   •  Endpoint  is  just  a  set  of  lambda  funcFons   – @OnOpen,  @OnMessage,  @OnError,  @OnClose   – WebSocket  API  already  has  programmaFc  version  in  the  specificaFon  –  see   javax.websocket.Endpoint   •  It  can  be  applied  to  server  side  as  well   – AnnotaFon  way  is  o{en  preferred  for  server-­‐side  deployment   – Easier  to  read  +  integrate  with  other  frameworks  (DI,  ..)   32  
  31. 31. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Lambdas  in  Tyrus   33  
  32. 32. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Lambdas  in  Tyrus   34  
  33. 33. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Lambdas  in  Tyrus   35  
  34. 34. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Streams  in  Tyrus   •  Stream  processing  is  another  bigger  and  more  notable  feature  of  the  Java  8   •  MessageHanders  (in  general  -­‐  any  event  handler)  can  be    modeled  as   endless  stream   – there  are  some  issues  with  “terminators”,  but  that  could  be  solved  -­‐  terminator   would  unregister  current  “message  handler”;  push  vs  pull..   – streams  can  easily:  filter,  map  (encode/decode)   36  
  35. 35. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Contacts   •  Pavel  Bucek  (pavel.bucek@oracle.com)   •  Michal  Gajdoš  (michal@sapho.com)     Github  repo:  hQps://github.com/pavelbucek/placeholder   •  Jersey  –  hQp://jersey.java.net   •  Tyrus  –  hQp://tyrus.java.net     37  
  36. 36. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   Q  &  A   38  
  37. 37. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |           39  
  38. 38. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |   40  

×