SlideShare a Scribd company logo
1 of 32
Download to read offline
Reac%ve	
  Jersey	
  Client	
  
Michal	
  Gajdos	
  
michal.gajdos@oracle.com	
  
	
  
January,	
  2015	
  
Copyright	
  ©	
  2014,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Safe	
  Harbor	
  Statement	
  
The	
  following	
  is	
  intended	
  to	
  outline	
  our	
  general	
  product	
  direc%on.	
  It	
  is	
  intended	
  for	
  
informa%on	
  purposes	
  only,	
  and	
  may	
  not	
  be	
  incorporated	
  into	
  any	
  contract.	
  It	
  is	
  not	
  a	
  
commitment	
  to	
  deliver	
  any	
  material,	
  code,	
  or	
  func%onality,	
  and	
  should	
  not	
  be	
  relied	
  upon	
  
in	
  making	
  purchasing	
  decisions.	
  The	
  development,	
  release,	
  and	
  %ming	
  of	
  any	
  features	
  or	
  
func%onality	
  described	
  for	
  Oracle’s	
  products	
  remains	
  at	
  the	
  sole	
  discre%on	
  of	
  Oracle.	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
The	
  Problem	
  
A	
  Travel	
  Agency	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
A	
  Travel	
  Agency	
  Service	
  
Orchestra%ng	
  Services	
  
Weather	
  
Customers	
  
Des%na%ons	
  
Quo%ng	
  
Travel	
  Agency	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
The	
  Why	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
The	
  Why	
  
•  Client	
  specific	
  API	
  
– Different	
  needs	
  for	
  various	
  devices:	
  screen	
  size,	
  payment	
  methods,	
  ...	
  
•  Single	
  Entry	
  Point	
  
– No	
  need	
  to	
  communicate	
  with	
  mul%ple	
  services	
  
•  Thinner	
  client	
  
– No	
  need	
  to	
  consume	
  different	
  formats	
  of	
  data	
  
•  Less	
  frequent	
  client	
  updates	
  
– Doesn’t	
  ma]er	
  if	
  one	
  service	
  is	
  removed	
  in	
  favor	
  of	
  another	
  service	
  
Building	
  an	
  Orchestra6on	
  Layer	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
The	
  How	
  
JAX-­‐RS	
  2.0	
  and	
  Jersey	
  2	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Demo	
  Applica%on	
  
•  “Remote”	
  
– applica%on/json,	
  applica%on/xml	
  
– delays	
  
•  “Agent”	
  
– applica%on/json	
  
– dependent	
  calls	
  
Exposed	
  resources	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
A	
  Naïve	
  Approach	
  
Implemen%ng	
  the	
  Service	
  
Get	
  
Customer	
  Details	
  
Get	
  a	
  list	
  of	
  10	
  
Recommended	
  
Des6na6ons	
  
Get	
  
Quote	
  
for	
  the	
  Customer	
  
Get	
  	
  
Weather	
  Forecast	
  
for	
  each	
  Des6na6on	
   for	
  each	
  Des6na6on	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Client	
  client	
  =	
  ClientBuilder.newClient();	
  
	
  
WebTarget	
  rx	
  =	
  client.target("http://example.com/rx").register(JacksonFeature.class);	
  
	
  
WebTarget	
  forecasts	
  =	
  rx.path("remote/forecast/{destination}");	
  
	
  
Forecast	
  forecast	
  =	
  forecasts.resolveTemplate("destination",	
  dest.getDestination())	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .request("application/xml")	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .get(Forecast.class);	
  
JAX-­‐RS	
  2.0	
  Client	
  –	
  Synchronous	
  
Copyright	
  ©	
  2014,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
DEMO	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
A	
  Naïve	
  Approach	
  
Implemen%ng	
  the	
  Service	
  
Get	
  
Customer	
  Details	
  
Get	
  a	
  list	
  of	
  10	
  
Recommended	
  
Des6na6ons	
  
Get	
  
Quote	
  
for	
  the	
  Customer	
  
Get	
  	
  
Weather	
  Forecast	
  
for	
  each	
  Des6na6on	
   for	
  each	
  Des6na6on	
  
150	
  ms	
   250	
  ms	
   1	
  700	
  ms	
  
170	
  ms	
  
3	
  300	
  ms	
  
330	
  ms	
  
5	
  400	
  ms	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Client	
  –	
  Synchronous	
  Approach	
  
•  Easy	
  to	
  read,	
  understand	
  and	
  debug	
  
– Simple	
  requests,	
  Composed	
  requests	
  
•  Slow	
  
– Sequen%al	
  processing	
  even	
  for	
  independent	
  requests	
  
•  Was%ng	
  resources	
  
– Wai%ng	
  threads	
  
•  Suitable	
  for	
  
– Lower	
  number	
  of	
  requests	
  
– Single	
  request	
  that	
  depends	
  on	
  the	
  result	
  of	
  previous	
  opera%on	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Op6mized	
  Approach	
  
Implemen%ng	
  the	
  Service	
  
170	
  ms	
  
Get	
  
Customer	
  Details	
  
Get	
  a	
  list	
  of	
  10	
  
Recommended	
  
Des6na6ons	
  
Async	
  Get	
  
Quote	
  
for	
  the	
  Customer	
  
Async	
  Get	
  	
  
Weather	
  Forecast	
  
for	
  each	
  Des6na6on	
  
for	
  each	
  Des6na6on	
  
150	
  ms	
   250	
  ms	
   330	
  ms	
  
330	
  ms	
  
730	
  ms	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Future<Forecast>	
  forecast	
  =	
  forecasts.resolveTemplate("destination",	
  d.getDestination())	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .request()	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .async()	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .get(new	
  InvocationCallback<Forecast>()	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  @Override	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  public	
  void	
  completed(Forecast	
  forecast)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  //	
  Do	
  Something.	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  @Override	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  public	
  void	
  failed(Throwable	
  throwable)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  //	
  Do	
  Something	
  else.	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  });	
  
while	
  (!forecast.isDone())	
  {	
  
	
  	
  	
  	
  //	
  Do	
  Something.	
  
}	
  
System.out.println(forecast.get());	
  
JAX-­‐RS	
  2.0	
  Client	
  –	
  Asynchronous	
  
Copyright	
  ©	
  2014,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
DEMO	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Client	
  –	
  Asynchronous	
  Approach	
  
•  Returns	
  immediately	
  afer	
  submigng	
  a	
  request	
  
– Future	
  
•  Harder	
  to	
  understand,	
  debug	
  
– Especially	
  when	
  dealing	
  with	
  mul%ple	
  futures	
  	
  
•  Fast	
  
– Each	
  request	
  can	
  run	
  on	
  a	
  separate	
  thread	
  
– Need	
  to	
  ac%vely	
  check	
  for	
  comple%on	
  event	
  (future.isDone())	
  or	
  block	
  (slow)	
  
Futures	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Client	
  –	
  Asynchronous	
  Approach	
  
•  “Don’t	
  call	
  us,	
  we’ll	
  call	
  you”	
  
•  Harder	
  to	
  read,	
  understand	
  and	
  debug	
  
– Especially	
  for	
  composed	
  calls	
  (dependent)	
  
•  Need	
  to	
  find	
  out	
  when	
  all	
  Async	
  requests	
  finished	
  
– Relevant	
  only	
  for	
  2	
  or	
  more	
  requests	
  (CountDownLatch)	
  
•  Fast	
  
– Each	
  request	
  can	
  run	
  on	
  a	
  separate	
  thread	
  
•  Suitable	
  for	
  
– Many	
  independent	
  calls	
  	
  
The	
  Callback	
  Hell	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Beyond	
  The	
  Callback	
  Hell	
  
Reac6ve	
  (Jersey)	
  Client	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Client	
  –	
  Reac%ve	
  Approach	
  
•  Data-­‐Flows	
  
– Execu%on	
  model	
  propagates	
  changes	
  through	
  the	
  flow	
  
•  Asynchronous	
  
– Preferably,	
  Speed	
  
•  Event-­‐based	
  
– No%fy	
  user	
  code	
  or	
  another	
  item	
  in	
  flow	
  about	
  con%nua%on,	
  error,	
  comple%on	
  
•  Composable	
  
– Compose/Transform	
  mul%ple	
  flows	
  into	
  the	
  resul%ng	
  one	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Reac%ve	
  Java	
  Libraries	
  
•  RxJava	
  –	
  Observable	
  
– Analogy	
  to	
  Iterable	
  	
  
– Currently	
  most	
  advanced	
  reac%ve	
  API	
  in	
  Java	
  
– Contributed	
  by	
  Nemlix	
  –	
  hardened	
  &	
  tested	
  in	
  produc%on	
  
•  Java	
  SE	
  8	
  –	
  CompletionStage	
  and	
  CompletableFuture	
  
– Na%ve	
  part	
  of	
  JDK	
  
– Fits	
  the	
  new	
  Java	
  Stream	
  API	
  programming	
  model	
  
– JSR166e	
  –	
  Support	
  for	
  CompletableFuture	
  on	
  Java	
  SE	
  6	
  and	
  Java	
  SE	
  7	
  
•  Guava	
  –	
  ListenableFuture	
  and	
  Futures	
  
– Similar	
  to	
  Java	
  SE	
  8	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Observable	
  
•  Observable	
  (push)	
  
– retrieve	
  data	
  –	
  onNext(T)	
  
– discover	
  error	
  –	
  onError(Exception)	
  
– complete	
  –	
  onCompleted()	
  
•  Iterable	
  (pull)	
  
– retrieve	
  data	
  –	
  T	
  next()	
  
– discover	
  error	
  –	
  throws	
  Exception	
  
– complete	
  –	
  !hasNext()	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Observable<Response>	
  response	
  =	
  …	
  ;	
  
	
  
List<String>	
  visited	
  =	
  new	
  ArrayList<>(10);	
  
	
  
//	
  Read	
  a	
  list	
  of	
  destinations	
  from	
  JAX-­‐RS	
  response	
  
response.map(resp	
  -­‐>	
  resp.readEntity(new	
  GenericType<List<Destination>>()	
  {}))	
  
	
  	
  	
  	
  	
  	
  	
  	
  //	
  If	
  an	
  exception	
  is	
  thrown,	
  continue	
  with	
  an	
  empty	
  list	
  
	
  	
  	
  	
  	
  	
  	
  	
  .onErrorReturn(throwable	
  -­‐>	
  Collections.emptyList())	
  
	
  	
  	
  	
  	
  	
  	
  	
  //	
  Emit	
  list	
  of	
  destinations	
  as	
  a	
  new	
  Observable	
  
	
  	
  	
  	
  	
  	
  	
  	
  .flatMap(Observable::from)	
  
	
  	
  	
  	
  	
  	
  	
  	
  //	
  Take	
  the	
  first	
  10	
  destinations	
  
	
  	
  	
  	
  	
  	
  	
  	
  .take(10)	
  
	
  	
  	
  	
  	
  	
  	
  	
  //	
  Obtain	
  a	
  string	
  representation	
  of	
  a	
  destination	
  
	
  	
  	
  	
  	
  	
  	
  	
  .map(Destination::getDestination)	
  
	
  	
  	
  	
  	
  	
  	
  	
  //	
  Observe	
  the	
  destination	
  events	
  on	
  a	
  separate	
  thread	
  
	
  	
  	
  	
  	
  	
  	
  	
  .observeOn(Schedulers.io())	
  
	
  	
  	
  	
  	
  	
  	
  	
  //	
  Subscribe	
  to	
  callbacks	
  –	
  OnNext,	
  OnError,	
  OnComplete	
  
	
  	
  	
  	
  	
  	
  	
  	
  .subscribe(visited::add,	
  async::resume,	
  ()	
  -­‐>	
  async.resume(visited));	
  
An	
  Observable<Response>	
  Example	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Reac%ve	
  Jersey	
  Client	
  
•  Remember	
  #request()	
  and	
  #request().async()	
  ?	
  
– request()	
  returns	
  Invoca6on.Builder;	
  SyncInvoker	
  –	
  sync	
  HTTP	
  methods	
  
– request().async()	
  returns	
  AsyncInvoker	
  –	
  async	
  HTTP	
  methods	
  
•  #rx()	
  and	
  #rx(ExecutorService)	
  
– Return	
  an	
  extension	
  of	
  RxInvoker	
  
Extension	
  of	
  JAX-­‐RS	
  Client	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
public	
  interface	
  SyncInvoker	
  {	
  
	
  
	
  	
  	
  	
  Response	
  get();	
  
	
  
	
  	
  	
  	
  <T>	
  T	
  get(Class<T>	
  responseType);	
  
	
  
	
  	
  	
  	
  <T>	
  T	
  get(GenericType<T>	
  responseType);	
  
	
  
	
  	
  	
  	
  //	
  ...	
  
}	
  
	
  
public	
  interface	
  AsyncInvoker	
  {	
  
	
  
	
  	
  	
  	
  Future<Response>	
  get();	
  
	
  
	
  	
  	
  	
  <T>	
  Future<T>	
  get(Class<T>	
  responseType);	
  
	
  
	
  	
  	
  	
  <T>	
  Future<T>	
  get(GenericType<T>	
  responseType);	
  
	
  
	
  	
  	
  	
  //	
  ...	
  
}	
  
	
  
SyncInvoker	
  and	
  AsyncInvoker	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
public	
  interface	
  RxInvoker<T>	
  {	
  
	
  
	
  	
  	
  	
  T	
  get();	
  
	
  
	
  	
  	
  	
  <R>	
  T	
  get(Class<R>	
  responseType);	
  
	
  
	
  	
  	
  	
  <R>	
  T	
  get(GenericType<R>	
  responseType);	
  
	
  
	
  	
  	
  	
  //	
  ...	
  
}	
  
	
  
public	
  interface	
  RxObservableInvoker	
  extends	
  RxInvoker<Observable>	
  {	
  
	
  
	
  	
  	
  	
  Observable<Response>	
  get();	
  
	
  
	
  	
  	
  	
  <T>	
  Observable<T>	
  get(Class<T>	
  responseType);	
  
	
  
	
  	
  	
  	
  <T>	
  Observable<T>	
  get(GenericType<T>	
  responseType);	
  
	
  
	
  	
  	
  	
  //	
  ...	
  
}	
  
RxInvoker	
  and	
  an	
  extension	
  Example	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Reac%ve	
  Jersey	
  Client	
  –	
  contd	
  
•  Affected	
  JAX-­‐RS	
  interfaces	
  
– RxInvoca%onBuilder<RX	
  extends	
  RxInvoker>	
  extends	
  Invoca%on.Builder	
  
– RxWebTarget<RX	
  extends	
  RxInvoker>	
  extends	
  WebTarget	
  
– RxClient<RX	
  extends	
  RxInvoker>	
  extends	
  Client	
  
•  Rx	
  class	
  
– RxObservable	
  
– RxComple%onStage	
  
– RxListenableFuture	
  
– RxCompletableFuture	
  (JSR	
  166e)	
  
Extension	
  of	
  JAX-­‐RS	
  Client	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Client	
  client	
  =	
  ClientBuilder.newClient();	
  
WebTarget	
  target	
  =	
  client.target("...");	
  
	
  
	
  
//	
  Rx	
  
RxClient<RxObservableInvoker>	
  rxClient	
  =	
  Rx.newClient(RxObservableInvoker.class);	
  
RxClient<RxObservableInvoker>	
  rxClient	
  =	
  Rx.client(client,	
  RxObservableInvoker.class);	
  
	
  
RxWebTarget<RxObservableInvoker>	
  rxTarget	
  =	
  
	
  	
  	
  	
  Rx.target(target,	
  RxObservableInvoker.class);	
  
	
  
	
  
//	
  RxObservable	
  
RxClient<RxObservableInvoker>	
  rxClient	
  =	
  RxObservable.newClient();	
  
RxClient<RxObservableInvoker>	
  rxClient	
  =	
  RxObservable.client(client);	
  
	
  
RxWebTarget<RxObservableInvoker>	
  rxTarget	
  =	
  RxObservable.target(target);	
  
	
  
	
  
Reac%ve	
  Client	
  –	
  Crea%on	
  
Copyright	
  ©	
  2014,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
DEMO	
  
Copyright	
  ©	
  2014,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Q&A	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Resources	
  
•  JAX-­‐RS	
  Client	
  API	
  
– h]ps://jax-­‐rs-­‐spec.java.net/nonav/2.0/apidocs/overview-­‐summary.html	
  
– h]ps://jersey.java.net/documenta%on/latest/client.html	
  
•  Jersey	
  Rx	
  Client	
  
– h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client	
  
– h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client-­‐guava	
  
– h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client-­‐java8	
  
– h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client-­‐jsr166e	
  
– h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client-­‐rxjava	
  
JAX-­‐RS	
  and	
  Jersey	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Resources	
  
•  3rd	
  party	
  libraries	
  
– h]ps://code.google.com/p/guava-­‐libraries/	
  
– h]ps://github.com/Reac%veX/RxJava	
  
– h]p://docs.oracle.com/javase/8/docs/api/java/u%l/concurrent/package-­‐
summary.html	
  
– h]p://gee.cs.oswego.edu/dl/concurrency-­‐interest/index.html	
  
•  Example	
  (JDK7)	
  
– h]ps://github.com/jersey/jersey/tree/master/examples/rx-­‐client-­‐webapp	
  
Example	
  and	
  Libraries	
  

More Related Content

What's hot

Typesafe Reactive Platform: Monitoring 1.0, Commercial features and more
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and moreTypesafe Reactive Platform: Monitoring 1.0, Commercial features and more
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and moreLegacy Typesafe (now Lightbend)
 
Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...
Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...
Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...Codemotion
 
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...Konrad Malawski
 
Akka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming WorldAkka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming WorldKonrad Malawski
 
How Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemHow Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemKonrad Malawski
 
Akka 2.4 plus new commercial features in Typesafe Reactive Platform
Akka 2.4 plus new commercial features in Typesafe Reactive PlatformAkka 2.4 plus new commercial features in Typesafe Reactive Platform
Akka 2.4 plus new commercial features in Typesafe Reactive PlatformLegacy Typesafe (now Lightbend)
 
Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Konrad Malawski
 
Architectural changes in the repo in 6.1 and beyond
Architectural changes in the repo in 6.1 and beyondArchitectural changes in the repo in 6.1 and beyond
Architectural changes in the repo in 6.1 and beyondStefan Kopf
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5Gal Marder
 
Do's and don'ts when deploying akka in production
Do's and don'ts when deploying akka in productionDo's and don'ts when deploying akka in production
Do's and don'ts when deploying akka in productionjglobal
 
End to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to SocketEnd to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to SocketKonrad Malawski
 
Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...
Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...
Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...Lightbend
 
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...Gal Marder
 
Dropwizard and Groovy
Dropwizard and GroovyDropwizard and Groovy
Dropwizard and Groovytomaslin
 
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analyticsPivotalOpenSourceHub
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideMohanraj Thirumoorthy
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introductionJonathan Holloway
 
Developing Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring CloudDeveloping Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring CloudDustin Ruehle
 

What's hot (19)

Typesafe Reactive Platform: Monitoring 1.0, Commercial features and more
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and moreTypesafe Reactive Platform: Monitoring 1.0, Commercial features and more
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and more
 
Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...
Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...
Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...
 
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...
 
Akka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming WorldAkka-chan's Survival Guide for the Streaming World
Akka-chan's Survival Guide for the Streaming World
 
How Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemHow Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM Ecosystem
 
Akka 2.4 plus new commercial features in Typesafe Reactive Platform
Akka 2.4 plus new commercial features in Typesafe Reactive PlatformAkka 2.4 plus new commercial features in Typesafe Reactive Platform
Akka 2.4 plus new commercial features in Typesafe Reactive Platform
 
Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016
 
Architectural changes in the repo in 6.1 and beyond
Architectural changes in the repo in 6.1 and beyondArchitectural changes in the repo in 6.1 and beyond
Architectural changes in the repo in 6.1 and beyond
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5
 
Do's and don'ts when deploying akka in production
Do's and don'ts when deploying akka in productionDo's and don'ts when deploying akka in production
Do's and don'ts when deploying akka in production
 
End to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to SocketEnd to End Akka Streams / Reactive Streams - from Business to Socket
End to End Akka Streams / Reactive Streams - from Business to Socket
 
Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...
Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...
Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...
 
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
 
Exachk and oem12c
Exachk and oem12cExachk and oem12c
Exachk and oem12c
 
Dropwizard and Groovy
Dropwizard and GroovyDropwizard and Groovy
Dropwizard and Groovy
 
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Developing Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring CloudDeveloping Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring Cloud
 

Viewers also liked

Tachyon and Apache Spark
Tachyon and Apache SparkTachyon and Apache Spark
Tachyon and Apache Sparkrhatr
 
Reactive streams
Reactive streamsReactive streams
Reactive streamscodepitbull
 
xPatterns on Spark, Shark, Mesos, Tachyon
xPatterns on Spark, Shark, Mesos, TachyonxPatterns on Spark, Shark, Mesos, Tachyon
xPatterns on Spark, Shark, Mesos, TachyonClaudiu Barbura
 
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsPSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsStephane Manciot
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on AndroidTomáš Kypta
 
Reactive Streams and RabbitMQ
Reactive Streams and RabbitMQReactive Streams and RabbitMQ
Reactive Streams and RabbitMQmkiedys
 
Akka in Practice: Designing Actor-based Applications
Akka in Practice: Designing Actor-based ApplicationsAkka in Practice: Designing Actor-based Applications
Akka in Practice: Designing Actor-based ApplicationsNLJUG
 
xPatterns ... beyond Hadoop (Spark, Shark, Mesos, Tachyon)
xPatterns ... beyond Hadoop (Spark, Shark, Mesos, Tachyon)xPatterns ... beyond Hadoop (Spark, Shark, Mesos, Tachyon)
xPatterns ... beyond Hadoop (Spark, Shark, Mesos, Tachyon)Claudiu Barbura
 
Micro services, reactive manifesto and 12-factors
Micro services, reactive manifesto and 12-factorsMicro services, reactive manifesto and 12-factors
Micro services, reactive manifesto and 12-factorsDejan Glozic
 
12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM DeploymentJoe Kutner
 

Viewers also liked (10)

Tachyon and Apache Spark
Tachyon and Apache SparkTachyon and Apache Spark
Tachyon and Apache Spark
 
Reactive streams
Reactive streamsReactive streams
Reactive streams
 
xPatterns on Spark, Shark, Mesos, Tachyon
xPatterns on Spark, Shark, Mesos, TachyonxPatterns on Spark, Shark, Mesos, Tachyon
xPatterns on Spark, Shark, Mesos, Tachyon
 
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsPSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Reactive Streams and RabbitMQ
Reactive Streams and RabbitMQReactive Streams and RabbitMQ
Reactive Streams and RabbitMQ
 
Akka in Practice: Designing Actor-based Applications
Akka in Practice: Designing Actor-based ApplicationsAkka in Practice: Designing Actor-based Applications
Akka in Practice: Designing Actor-based Applications
 
xPatterns ... beyond Hadoop (Spark, Shark, Mesos, Tachyon)
xPatterns ... beyond Hadoop (Spark, Shark, Mesos, Tachyon)xPatterns ... beyond Hadoop (Spark, Shark, Mesos, Tachyon)
xPatterns ... beyond Hadoop (Spark, Shark, Mesos, Tachyon)
 
Micro services, reactive manifesto and 12-factors
Micro services, reactive manifesto and 12-factorsMicro services, reactive manifesto and 12-factors
Micro services, reactive manifesto and 12-factors
 
12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment
 

Similar to Reactive Jersey Client

Stream Analytics
Stream Analytics Stream Analytics
Stream Analytics Franco Ucci
 
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckEdward Burns
 
How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesHow to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesPavel Bucek
 
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouHTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouDavid Delabassee
 
JAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridgeJAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridgeJosé Paumard
 
JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013Jagadish Prasath
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJosé Paumard
 
Oracle REST Data Services
Oracle REST Data ServicesOracle REST Data Services
Oracle REST Data ServicesChris Muir
 
Why Upgrade to Oracle Database 12c?
Why Upgrade to Oracle Database 12c?Why Upgrade to Oracle Database 12c?
Why Upgrade to Oracle Database 12c?DLT Solutions
 
QA standup - workload analysis
QA standup  - workload analysisQA standup  - workload analysis
QA standup - workload analysisSerghei Radov
 
Alta Disponibilidade no MySQL 5.7
Alta Disponibilidade no MySQL 5.7Alta Disponibilidade no MySQL 5.7
Alta Disponibilidade no MySQL 5.7MySQL Brasil
 
Real World Problem Solving Using Application Performance Management 10
Real World Problem Solving Using Application Performance Management 10Real World Problem Solving Using Application Performance Management 10
Real World Problem Solving Using Application Performance Management 10CA Technologies
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_daviddTakashi Ito
 
Explore Advanced CA Release Automation Configuration Topics
Explore Advanced CA Release Automation Configuration TopicsExplore Advanced CA Release Automation Configuration Topics
Explore Advanced CA Release Automation Configuration TopicsCA Technologies
 
Jfokus 2017 Oracle Dev Cloud and Containers
Jfokus 2017 Oracle Dev Cloud and ContainersJfokus 2017 Oracle Dev Cloud and Containers
Jfokus 2017 Oracle Dev Cloud and ContainersMika Rinne
 
(ZDM) Zero Downtime DB Migration to Oracle Cloud
(ZDM) Zero Downtime DB Migration to Oracle Cloud(ZDM) Zero Downtime DB Migration to Oracle Cloud
(ZDM) Zero Downtime DB Migration to Oracle CloudRuggero Citton
 
Oracle Cloud Platform - Migrer vers la Database 12c
Oracle Cloud Platform - Migrer vers la Database 12cOracle Cloud Platform - Migrer vers la Database 12c
Oracle Cloud Platform - Migrer vers la Database 12cBastien Leblanc
 
Coherence 12.1.2 Live Events
Coherence 12.1.2 Live EventsCoherence 12.1.2 Live Events
Coherence 12.1.2 Live Eventsharvraja
 
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...Codemotion Tel Aviv
 

Similar to Reactive Jersey Client (20)

Stream Analytics
Stream Analytics Stream Analytics
Stream Analytics
 
JAX-RS.next
JAX-RS.nextJAX-RS.next
JAX-RS.next
 
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
 
How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesHow to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based Microservices
 
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouHTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
 
JAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridgeJAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridge
 
JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) Bridge
 
Oracle REST Data Services
Oracle REST Data ServicesOracle REST Data Services
Oracle REST Data Services
 
Why Upgrade to Oracle Database 12c?
Why Upgrade to Oracle Database 12c?Why Upgrade to Oracle Database 12c?
Why Upgrade to Oracle Database 12c?
 
QA standup - workload analysis
QA standup  - workload analysisQA standup  - workload analysis
QA standup - workload analysis
 
Alta Disponibilidade no MySQL 5.7
Alta Disponibilidade no MySQL 5.7Alta Disponibilidade no MySQL 5.7
Alta Disponibilidade no MySQL 5.7
 
Real World Problem Solving Using Application Performance Management 10
Real World Problem Solving Using Application Performance Management 10Real World Problem Solving Using Application Performance Management 10
Real World Problem Solving Using Application Performance Management 10
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_davidd
 
Explore Advanced CA Release Automation Configuration Topics
Explore Advanced CA Release Automation Configuration TopicsExplore Advanced CA Release Automation Configuration Topics
Explore Advanced CA Release Automation Configuration Topics
 
Jfokus 2017 Oracle Dev Cloud and Containers
Jfokus 2017 Oracle Dev Cloud and ContainersJfokus 2017 Oracle Dev Cloud and Containers
Jfokus 2017 Oracle Dev Cloud and Containers
 
(ZDM) Zero Downtime DB Migration to Oracle Cloud
(ZDM) Zero Downtime DB Migration to Oracle Cloud(ZDM) Zero Downtime DB Migration to Oracle Cloud
(ZDM) Zero Downtime DB Migration to Oracle Cloud
 
Oracle Cloud Platform - Migrer vers la Database 12c
Oracle Cloud Platform - Migrer vers la Database 12cOracle Cloud Platform - Migrer vers la Database 12c
Oracle Cloud Platform - Migrer vers la Database 12c
 
Coherence 12.1.2 Live Events
Coherence 12.1.2 Live EventsCoherence 12.1.2 Live Events
Coherence 12.1.2 Live Events
 
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
 

Recently uploaded

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 

Recently uploaded (20)

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 

Reactive Jersey Client

  • 1. Reac%ve  Jersey  Client   Michal  Gajdos   michal.gajdos@oracle.com     January,  2015   Copyright  ©  2014,  Oracle  and/or  its  affiliates.  All  rights  reserved.      
  • 2. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Safe  Harbor  Statement   The  following  is  intended  to  outline  our  general  product  direc%on.  It  is  intended  for   informa%on  purposes  only,  and  may  not  be  incorporated  into  any  contract.  It  is  not  a   commitment  to  deliver  any  material,  code,  or  func%onality,  and  should  not  be  relied  upon   in  making  purchasing  decisions.  The  development,  release,  and  %ming  of  any  features  or   func%onality  described  for  Oracle’s  products  remains  at  the  sole  discre%on  of  Oracle.  
  • 3. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       The  Problem   A  Travel  Agency  
  • 4. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       A  Travel  Agency  Service   Orchestra%ng  Services   Weather   Customers   Des%na%ons   Quo%ng   Travel  Agency  
  • 5. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       The  Why  
  • 6. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       The  Why   •  Client  specific  API   – Different  needs  for  various  devices:  screen  size,  payment  methods,  ...   •  Single  Entry  Point   – No  need  to  communicate  with  mul%ple  services   •  Thinner  client   – No  need  to  consume  different  formats  of  data   •  Less  frequent  client  updates   – Doesn’t  ma]er  if  one  service  is  removed  in  favor  of  another  service   Building  an  Orchestra6on  Layer  
  • 7. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       The  How   JAX-­‐RS  2.0  and  Jersey  2  
  • 8. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Demo  Applica%on   •  “Remote”   – applica%on/json,  applica%on/xml   – delays   •  “Agent”   – applica%on/json   – dependent  calls   Exposed  resources  
  • 9. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       A  Naïve  Approach   Implemen%ng  the  Service   Get   Customer  Details   Get  a  list  of  10   Recommended   Des6na6ons   Get   Quote   for  the  Customer   Get     Weather  Forecast   for  each  Des6na6on   for  each  Des6na6on  
  • 10. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Client  client  =  ClientBuilder.newClient();     WebTarget  rx  =  client.target("http://example.com/rx").register(JacksonFeature.class);     WebTarget  forecasts  =  rx.path("remote/forecast/{destination}");     Forecast  forecast  =  forecasts.resolveTemplate("destination",  dest.getDestination())                                                            .request("application/xml")                                                            .get(Forecast.class);   JAX-­‐RS  2.0  Client  –  Synchronous  
  • 11. Copyright  ©  2014,  Oracle  and/or  its  affiliates.  All  rights  reserved.       DEMO  
  • 12. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       A  Naïve  Approach   Implemen%ng  the  Service   Get   Customer  Details   Get  a  list  of  10   Recommended   Des6na6ons   Get   Quote   for  the  Customer   Get     Weather  Forecast   for  each  Des6na6on   for  each  Des6na6on   150  ms   250  ms   1  700  ms   170  ms   3  300  ms   330  ms   5  400  ms  
  • 13. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Client  –  Synchronous  Approach   •  Easy  to  read,  understand  and  debug   – Simple  requests,  Composed  requests   •  Slow   – Sequen%al  processing  even  for  independent  requests   •  Was%ng  resources   – Wai%ng  threads   •  Suitable  for   – Lower  number  of  requests   – Single  request  that  depends  on  the  result  of  previous  opera%on  
  • 14. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Op6mized  Approach   Implemen%ng  the  Service   170  ms   Get   Customer  Details   Get  a  list  of  10   Recommended   Des6na6ons   Async  Get   Quote   for  the  Customer   Async  Get     Weather  Forecast   for  each  Des6na6on   for  each  Des6na6on   150  ms   250  ms   330  ms   330  ms   730  ms  
  • 15. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Future<Forecast>  forecast  =  forecasts.resolveTemplate("destination",  d.getDestination())                                                                          .request()                                                                          .async()                                                                          .get(new  InvocationCallback<Forecast>()  {                                                                                  @Override                                                                                  public  void  completed(Forecast  forecast)  {                                                                                          //  Do  Something.                                                                                  }                                                      @Override                                                    public  void  failed(Throwable  throwable)  {                                                            //  Do  Something  else.                                                    }                                              });   while  (!forecast.isDone())  {          //  Do  Something.   }   System.out.println(forecast.get());   JAX-­‐RS  2.0  Client  –  Asynchronous  
  • 16. Copyright  ©  2014,  Oracle  and/or  its  affiliates.  All  rights  reserved.       DEMO  
  • 17. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Client  –  Asynchronous  Approach   •  Returns  immediately  afer  submigng  a  request   – Future   •  Harder  to  understand,  debug   – Especially  when  dealing  with  mul%ple  futures     •  Fast   – Each  request  can  run  on  a  separate  thread   – Need  to  ac%vely  check  for  comple%on  event  (future.isDone())  or  block  (slow)   Futures  
  • 18. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Client  –  Asynchronous  Approach   •  “Don’t  call  us,  we’ll  call  you”   •  Harder  to  read,  understand  and  debug   – Especially  for  composed  calls  (dependent)   •  Need  to  find  out  when  all  Async  requests  finished   – Relevant  only  for  2  or  more  requests  (CountDownLatch)   •  Fast   – Each  request  can  run  on  a  separate  thread   •  Suitable  for   – Many  independent  calls     The  Callback  Hell  
  • 19. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Beyond  The  Callback  Hell   Reac6ve  (Jersey)  Client  
  • 20. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Client  –  Reac%ve  Approach   •  Data-­‐Flows   – Execu%on  model  propagates  changes  through  the  flow   •  Asynchronous   – Preferably,  Speed   •  Event-­‐based   – No%fy  user  code  or  another  item  in  flow  about  con%nua%on,  error,  comple%on   •  Composable   – Compose/Transform  mul%ple  flows  into  the  resul%ng  one  
  • 21. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Reac%ve  Java  Libraries   •  RxJava  –  Observable   – Analogy  to  Iterable     – Currently  most  advanced  reac%ve  API  in  Java   – Contributed  by  Nemlix  –  hardened  &  tested  in  produc%on   •  Java  SE  8  –  CompletionStage  and  CompletableFuture   – Na%ve  part  of  JDK   – Fits  the  new  Java  Stream  API  programming  model   – JSR166e  –  Support  for  CompletableFuture  on  Java  SE  6  and  Java  SE  7   •  Guava  –  ListenableFuture  and  Futures   – Similar  to  Java  SE  8  
  • 22. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Observable   •  Observable  (push)   – retrieve  data  –  onNext(T)   – discover  error  –  onError(Exception)   – complete  –  onCompleted()   •  Iterable  (pull)   – retrieve  data  –  T  next()   – discover  error  –  throws  Exception   – complete  –  !hasNext()  
  • 23. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Observable<Response>  response  =  …  ;     List<String>  visited  =  new  ArrayList<>(10);     //  Read  a  list  of  destinations  from  JAX-­‐RS  response   response.map(resp  -­‐>  resp.readEntity(new  GenericType<List<Destination>>()  {}))                  //  If  an  exception  is  thrown,  continue  with  an  empty  list                  .onErrorReturn(throwable  -­‐>  Collections.emptyList())                  //  Emit  list  of  destinations  as  a  new  Observable                  .flatMap(Observable::from)                  //  Take  the  first  10  destinations                  .take(10)                  //  Obtain  a  string  representation  of  a  destination                  .map(Destination::getDestination)                  //  Observe  the  destination  events  on  a  separate  thread                  .observeOn(Schedulers.io())                  //  Subscribe  to  callbacks  –  OnNext,  OnError,  OnComplete                  .subscribe(visited::add,  async::resume,  ()  -­‐>  async.resume(visited));   An  Observable<Response>  Example  
  • 24. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Reac%ve  Jersey  Client   •  Remember  #request()  and  #request().async()  ?   – request()  returns  Invoca6on.Builder;  SyncInvoker  –  sync  HTTP  methods   – request().async()  returns  AsyncInvoker  –  async  HTTP  methods   •  #rx()  and  #rx(ExecutorService)   – Return  an  extension  of  RxInvoker   Extension  of  JAX-­‐RS  Client  
  • 25. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       public  interface  SyncInvoker  {            Response  get();            <T>  T  get(Class<T>  responseType);            <T>  T  get(GenericType<T>  responseType);            //  ...   }     public  interface  AsyncInvoker  {            Future<Response>  get();            <T>  Future<T>  get(Class<T>  responseType);            <T>  Future<T>  get(GenericType<T>  responseType);            //  ...   }     SyncInvoker  and  AsyncInvoker  
  • 26. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       public  interface  RxInvoker<T>  {            T  get();            <R>  T  get(Class<R>  responseType);            <R>  T  get(GenericType<R>  responseType);            //  ...   }     public  interface  RxObservableInvoker  extends  RxInvoker<Observable>  {            Observable<Response>  get();            <T>  Observable<T>  get(Class<T>  responseType);            <T>  Observable<T>  get(GenericType<T>  responseType);            //  ...   }   RxInvoker  and  an  extension  Example  
  • 27. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Reac%ve  Jersey  Client  –  contd   •  Affected  JAX-­‐RS  interfaces   – RxInvoca%onBuilder<RX  extends  RxInvoker>  extends  Invoca%on.Builder   – RxWebTarget<RX  extends  RxInvoker>  extends  WebTarget   – RxClient<RX  extends  RxInvoker>  extends  Client   •  Rx  class   – RxObservable   – RxComple%onStage   – RxListenableFuture   – RxCompletableFuture  (JSR  166e)   Extension  of  JAX-­‐RS  Client  
  • 28. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Client  client  =  ClientBuilder.newClient();   WebTarget  target  =  client.target("...");       //  Rx   RxClient<RxObservableInvoker>  rxClient  =  Rx.newClient(RxObservableInvoker.class);   RxClient<RxObservableInvoker>  rxClient  =  Rx.client(client,  RxObservableInvoker.class);     RxWebTarget<RxObservableInvoker>  rxTarget  =          Rx.target(target,  RxObservableInvoker.class);       //  RxObservable   RxClient<RxObservableInvoker>  rxClient  =  RxObservable.newClient();   RxClient<RxObservableInvoker>  rxClient  =  RxObservable.client(client);     RxWebTarget<RxObservableInvoker>  rxTarget  =  RxObservable.target(target);       Reac%ve  Client  –  Crea%on  
  • 29. Copyright  ©  2014,  Oracle  and/or  its  affiliates.  All  rights  reserved.       DEMO  
  • 30. Copyright  ©  2014,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Q&A  
  • 31. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Resources   •  JAX-­‐RS  Client  API   – h]ps://jax-­‐rs-­‐spec.java.net/nonav/2.0/apidocs/overview-­‐summary.html   – h]ps://jersey.java.net/documenta%on/latest/client.html   •  Jersey  Rx  Client   – h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client   – h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client-­‐guava   – h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client-­‐java8   – h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client-­‐jsr166e   – h]ps://github.com/jersey/jersey/tree/master/incubator/rx/rx-­‐client-­‐rxjava   JAX-­‐RS  and  Jersey  
  • 32. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Resources   •  3rd  party  libraries   – h]ps://code.google.com/p/guava-­‐libraries/   – h]ps://github.com/Reac%veX/RxJava   – h]p://docs.oracle.com/javase/8/docs/api/java/u%l/concurrent/package-­‐ summary.html   – h]p://gee.cs.oswego.edu/dl/concurrency-­‐interest/index.html   •  Example  (JDK7)   – h]ps://github.com/jersey/jersey/tree/master/examples/rx-­‐client-­‐webapp   Example  and  Libraries