Saturday, 20 February 2016

REST Vs SOAP

'Unless you have a definitive reason to use SOAP use REST'


REST :  REST is sweat spot when you are exposing the public API overt internet to handle the CRUD operation on the data.REST focuses on assessing the named resources through the  single consistent  Interface.


  SOAP:   SOAP brings it's own protocol and focuses on the exposing the pieces of application logic (not the data).SOAP focuses on accessing the named operation, which implements some business logic through different interfaces.
Though SOAP is commonly referred to as “web services” this is a misnomer. SOAP has very little if anything to do with the Web. REST provides true “Web services” based on URIs and HTTP.
 -Language, Platform ,protocol indepedent

Why REST ?
  1. REST  ( lightweight, ) has better performance and scalability .
  2.REST supports multiple data format XML,JSON etc.
  3.REST reads can be cached, while SOAP based read can not be cached.

Why SOAP ?

1. WS_SECURITY
  While SOAP supports SSL (just like REST) it also supports WS-Security which adds some enterprise security features. Supports identity through intermediaries, not just point to point (SSL). It also provides a standard implementation of data integrity and data privacy. Calling it “Enterprise” isn’t to say it’s more secure, it simply supports some security tools that typical internet services have no need for, in fact they are really only needed in a few “enterprise” scenarios.

2. WS_AUTOMIC_TRANSACTION

Rest doesn’t have a standard messaging system and expects clients to deal with communication failures by retrying. SOAP has successful/retry logic built in and provides end-to-end reliability even through SOAP intermediaries.
3. WS_MESSAGE_RELIBILITY 

4.WS_CO_ORDINATIOND


What is Integration ?

  Integration is process by which information is passed between tow or more distinct software entities.

THE CHOICE OF INTEGRATION MEDIA IS CATEGORICALLY IS DETERMINED WITH HELP OF FOLLOWING QUESTIONNAIRES.

1. Is transfer of information is synchronous or asynchronous ?
2. Is transfer of information acknowledged ?
3. Is transfer of information transactional ?
4. Does transfer of information requires message-level or transport-level  encryption ?
5.Does transfer of information occurs in batches composed of multiple message or one message at time ?
6. Does transfer of information occurs between system build using same technology or different technology ?
7. Does transfer of information use the technology-specific/transport protocol specific ?.


Java to Java  Integration
--------------------------
1. JMS  
1. JMS is interinsically designed for Asynchronous communication between between to java aplication.
   Features:
          1. publish subscribe and point to point messaging model.
          2. Message Delivery  Acknowledgement
          3.Message Level Encryption
          4.Distributed Transaction (JTA)

Java to Non-Java Integration :
------------------------------
  1.Web service are intrinsically designed to facilitate the integration of heterogeneous systems.
      1. Using web service is truly technology  independent .
     Which one embrace :
             1. SOAP
             2. Self Describing mesaage format Such as XML
         
    SOAP VS REST.   
 
https://dzone.com/articles/put-vs-post
https://knpuniversity.com/screencast/rest/put-versus-post

  Deciding between Put and POST

=======================

1. if the end point is idempotent .
2. URI must be addressed to resource being updated.


Patch :
  Update the resource without sending  all  the attributes in the request.

 







Friday, 19 February 2016

Java Memory Structure

JVM memory areas / components
    - Heap area
      Objects and array stored
      Created when JVM started  define fix size or vary between min and max size  –Xms -Xmx
       Yong Generation
        Eden Memory
        Survivor Memory
        Most of the newly created objects are located in the Eden memory space.
            When Eden space is filled with objects, Minor GC is performed and all the survivor objects are moved to one of the survivor spaces.
           
       Old Generation
         after many rounds of minor GC object is moved to the Old generation space.
       
    --  Perm Gem  :
      Permanent Generation or “Perm Gen” contains the application metadata required by the JVM to describe the classes and methods used in the application. Note that Perm Gen is not part of Java Heap memory.
    - Method area and runtime constant pool
      field, method data, code, constructor ,
      created on JVM started its part of Heap Memory
       The method area may be of a fixed size or may be expanded as required by the computation and may be contracted if a larger method area becomes unnecessary
      
    - JVM stack
      Each of the JVM threads has a private stack created at the same time as that of the thread. The stack stores frames. A frame is used to store data and partial results and to perform dynamic linking, return values for methods, and dispatch exceptions.
     
       If the computation in a thread requires a larger Java Virtual Machine stack than is permitted, the Java Virtual Machine throws a StackOverflowError.
      
       f Java Virtual Machine stacks can be dynamically expanded, and expansion is attempted but insufficient memory can be made available to effect the expansion, or if insufficient memory can be made available to create the initial Java Virtual Machine stack for a new thread, the Java Virtual Machine throws an OutOfMemoryError.
      
    - Native method stacks
        Native method stacks is called C stacks; it support native methods (methods written in a language other than the Java programming language), typically allocated per each thread when each thread is created. Java Virtual Machine implementations that cannot load native methods and that do not themselves rely on conventional stacks need not supply native method stacks.

The size of native method stacks can be either fixed or dynamic.
    - PC registers
   
--    Memory Pool
      To store immutable object
     
     
--  Runtime Constant Pool

Runtime constant pool is per-class runtime representation of constant pool in a class. It contains class runtime constants and static methods. Runtime constant pool is the part of method area.



VM Switch     VM Switch Description
-Xms     For setting the initial heap size when JVM starts
-Xmx     For setting the maximum heap size.
-Xmn     For setting the size of the Young Generation, rest of the space goes for Old Generation.
-XX:PermGen     For setting the initial size of the Permanent Generation memory
-XX:MaxPermGen     For setting the maximum size of Perm Gen
-XX:SurvivorRatio     For providing ratio of Eden space and Survivor Space, for example if Young Generation size is 10m and VM switch is -XX:SurvivorRatio=2 then 5m will be reserved for Eden Space and 2.5m each for both the Survivor spaces. The default value is 8.
-XX:NewRatio     For providing ratio of old/new generation sizes. The default value is 2.


Resource Link :
http://howtodoinjava.com/core-java/garbage-collection/jvm-memory-model-structure-and-components/
 http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html  
  http://www.journaldev.com/2856/java-jvm-memory-model-and-garbage-collection-monitoring-tuning