Thursday, September 7, 2017

ATG Oracle Commerce 11.3 JAX-RS Stateless REST services

ATG Oracle Commerce 11.3 JAX-RS Stateless REST services Stateless is one of the defining features of RESTful services. Client’s sta... thumbnail 1 summary
ATG Oracle Commerce 11.3 JAX-RS Stateless REST services


  1. Stateless is one of the defining features of RESTful services.
  2. Client’s state is not kept on the server,each request to be treated independently.
  3. By default, the framework is configured to be stateful. Pls refer here to enable the stateless layer.
  4. When we enable the dynamo layer as stateless, clients each request to be treated independently.
  5. ATG will passes the state info to the client in the response header and the same data need to pass t the server in the next request.
  6. Session and windows scopes are mapped to request scope.
  7. ATG components will be either request scope or global scope.
  8. Environment should not contain any shareable types [Cart and Profile]
  9. Need to ensure Session Affinity for the best performance.This eliminates the need to replicate session data like the http session or session beans.
  10. Data volume for service calls and responses increases.
  11. Increasing network bandwidth will increase the performance 
  12. Performance results may differ depending on the environment and configuration
  13. The profile and cart state information is passed back and forth using headers. The cart can grow to be very large as we pass extra data in the response body .

  14. There are two main components that pass data during a session.
      1.ProfileLoadableService
                                The profile maintains data for a shopper, which includes the profile ID, security status, and active promotions.
             2.OrderLoadableService              
                                The shopping cart passes a JSON representation of the cart to the client in the HTTP response body for any endpoint that interacts with the cart.
Passing State Data in the HTTP Header
When a component uses a header to pass state data between the client and the server, the data is comprised of a map of key/value pairs that reconstruct the component on the next request. This encoded and signed data is keyed on the component name. The value is the child map of key/value pairs used to reconstruct the component. The header value is a string representation of this map.
For example:
{ /atg/userprofiling/ProfileLoadableService = {securityStatus=0,
    activePromotions=, userId=1160002} }</a>
To configure a component to pass state information within the headers, add the Nucleus component path to a request-scoped instance of LoadableService to the loadableServicePaths property in the 
RequestStateManager:
loadableServicePaths=\
    /atg/userprofiling/ProfileLoadableService</a>


Example Post method for login service. After login success,we can see the x-ocstatedata header in the response.
We have to send this header for every request to get the logged user details.

Login Url : http://localhost:8080/public/v1/currentUser/login?pushSite=002


Getting user detail Url : http://localhost:8080/public/v1/currentUser?pushSite=002



Reference
http://docs.oracle.com/cd/E69533_01/Platform.11-3/ATGWSFrameGuide/html/s0517workingwithstatelessness01.html


No comments

Post a Comment