Monday 10 December 2018

// // Leave a Comment

Serialization :1 min study

Serialization

•Its concept provided by Java Prog. Lang. to persist the data into file.
•Serialization means change the status of an objects in bit or byte.
•While Serialization use public static final serialVersionUID to match the exact sender or receiver.

Advantages

•Serialization make an object serializable it will transfer through network.
•Using FileInputStream and FileOutputStream as well as ObjectInputStream and     ObjectOutputStream we make an object serializable.
•It contains bits or bytes of information.
•No need to verification while accessing the data.
•Data will be in high security mode while transmission.
•Serializable is the marker interface in Java. It doesn’t contains any methods.
•Static and final keywords are not usable in serialization.
•Transient keyword used to hide the data while serialization.
•We can perform operation on the serialized data.

 Disadvantages

•Serialization only used in Java it is not universal.
•We can stored multiple object using collection but it is complex to read and write.
•It is used by only programmer.
•It may fail while transmission the data from different platform.
Read More
// // 2 comments

Soap Vs Rest



SOAP – “Simple Object Access Protocol”

          is an XML-based messaging protocol for exchanging information among computers.
SOAP provides data transport for Web services, uses WSDl rules "web services description language".

REST – “Representational State Transfer”

is an architectural style not a protocol, you can use HTTP or FTP ot any other medium for data transfer.
In REST data can be transferred in XMl Json binary or any other format.

SOAP
REST
SOAP is a protocol.
REST can be defined as an architectural style.
SOAP can't use REST since it is a protocol.
REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.
SOAP defines standards to be strictly followed.
REST does not define too much standards like SOAP.
SOAP requires more bandwidth and resource than REST.
REST requires less bandwidth and resource than SOAP.
SOAP permits XML data format only.
REST permits different data format such as Plain text, HTML, XML, JSON etc.
SOAP is less preferred than REST.
REST more preferred than SOAP.


Read More

Friday 7 December 2018

// // Leave a Comment

Service Choreography vs Service Orchestration

Service Choreography:

Choreography can be simply defined where several services are distributed where no centralized point and all services work with comman aim without any micro management.
Ex :Event Driven Process


Lets look at above diagram where all services are interconnected and they communicate for particular goal. 

Service Orchestration:

In Orchestration there will be centralized service monitoring like micro management which combines all services with a fixed logic.
Ex:BPEL

Lets analyse the above diagram where centralized service will communicate with each service for a particular goal.

Individual Service Api x,Api y and Api z will not be connected with each other it will be connected to central service which acts as orchestration. 

Concluding with both we cannot compare best of both it is all based on Business Requirements.

Read More

Thursday 6 December 2018

// // Leave a Comment

REST-Annotations @Provider & @Context


@Provider:


@Provider is used to register the provider classes with the JAX-RS Runtime.

Different provider interfaces/classes where we can use @Provider Annotation:
There are some list of provider interfaces/classes are there which are going to registed using @Provider annotation which are given below

1. ParamConverterProvider-Contract for a provider of ParamConverter instances
2. MessageBodyReader-Contract for a provider that supports the conversion of a stream to a Java type
3. MessageBodyWriter-Contract for a provider that supports the conversion of a Java type to a stream
4. ContextResolver-Contract for a provider that supplies context information to resource classes and other providers 

 @Context: 

Purpose of @Context:
In order to access the predefined obj's there are there with the JAX-RS we need to use @Context annotaion so that JAX-RS Runtime will injects into our Resource class.

Different places where we can use @Contex Annotation:

There are predefined obj's that are there in JAX-RS API where if we wanted to access those obj so let the JAX-RS Runtime to inject those predefined obj's (like UriInfo obj) into pur Resource class for this we need to annotate with @Context annotation.

We can use @Context to get the predefined obj's that are there in JAX-RS API some of them are
1. UriInfo-An injectable interface that provides access to application and request URI information
2. HttpHeaders-An injectable interface that provides access to HTTP header information
3. Providers interface-An injectable interface providing runtime lookup of provider instances
4. SecurityContext
5. Request [For caching purpose]
Read More
// // Leave a Comment

Microservices: Best Practices

Building Microservices then below are the best practices to build a service in simple and clear way. 

Top 1 :Try to Achieve Fully Restful API

Writing an API then follow RMM (The Richardson Maturity Model)

RMM is used for checking API is fully Restful or Not.

Fully Restful API ↑ 

-Level 3:When you use HATEOS
-Level 2:Use of right HTTP methods(Get,Put,Post,Delete)
-Level 1:Resource URI-Profile Request to internal URI
-Level 0:Swamp of POX (No HTTP Contents only XML)

Top 2:Use HATEOS-Hyper Media As Engine of Application State

{
    "id": "123",
    "name": "Employee",
    "links": [{
        "rel": "emp",
    }, {
        "rel": "empDetails",
    }]
}

So that everytime you specify URI  client cannot hardcode.

Top 3:Documenting API

Ex: Swagger

Always document API’s so that it can be used to share documentation among product managers, testers and developers, but can also be used by various tools to automate API-related processes.

Top 4: Continuous Delivery

Continuous Delivery is extension of Continuous Integration,where teams ensure that every change to the system is releasable.

Its Recommended.
Read More

Monday 3 December 2018

// // Leave a Comment

RabbitMQ- Introduction & Installation

Introduction

In the world of Micro'Services', These independent services will talk or communicate each other
for communication among these services we need broker to forward the sent message.

RabbitMQ do exactly same that is forwards the received message.



Lets observe the above diagram where API-X sends message to API-Y via messaging queue or broker this will forward the same.

Installation

Step 1: Download and install Erlang from below available site .

              Download Erlang

Step 2: Download and install RabbitMq

             Download RabbitMq

Step 3: Open RabbitMQ command prompt which will be available in bin usually it will be in below                 path

            Programs\RabbitMQ Server             

Step 4: Run rabbitmq-plugins enable rabbitmq_management


Step 5: Start Server 
          
            rabbitmq-service start


Step 6: Open Browser and hit below url

            http://localhost:15672





Step 7: Username:guest  Password: guest



Finally installation DONE Successully!!!!!!!!!!

Thanks for reading. comments & suggestions always welcome :)
Read More
// // Leave a Comment

Spring Boot

Spring Boot!!!!! WHAT & WHY?

Spring boot helps developer to concentrate more on Business logic than configurations.

Spring boot is best assistant to developer reducing efforts to develop application without required to write same boilerplate configuration again and again.

If you have developed application in traditional way you would understand the pain of building project adding dependencies.





How it Assists or Why its Popular ?

Lets discuss some of the features or why to use Spring Boot.

1. Managing the dependencies made easy.

As I said above in old applications if you need to add jars it was not so easy task because other dependent jars would trouble you.
This was simplified here by just adding starters

Something it looks like this
Spring-boot-starter-*

Where * can be any dependencies like
  Spring-boot-starter-web  ->This commonly used for Spring MVC.
  Spring-boot-starter-jpa  -> This pulls jpa + hibernate .
  So on…

It looks like this :
Pom.xml
<parent>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-parent</artifactId>
       </parent>

2.Almost made zero configuration.

Spring-boot-starter-* will not only add dependencies but also configures commonly registered bean like Dispatcher Servlet, Resource handler, Message source etc.
This was mainly introduced to achieve Boiler plate config by automatic configuration of registering beans.

Registering beans based on
  • ·         Class should be available in particular path
  • ·         Presence or absence of bean.
  • ·         Presence of System properties.
  • ·         Absence of configuration file.

3.Spring boot has Embedded Servlet container.

No need to do any extra configuration for servlet container like traditional way just add -web in starter then spring-boot-starter-tomcat automatically pulled it has embedded container.

4.Actuator

Key features provides several web end points.
By Actuator you can find out how beans are wired through spring application context
Spring-boot-starter-actuator to be added in pom.xml

Some of them listed below

/health               : This is get method which displays health of application
/env                   : This is get method which displays health of environment properties.
/shutdown         : This is post method which shutdowns the application.

FAQs:

1.For Datasource, EMF transaction manager beans automatically created HOW???

Ans: If we have in memory D.B driver like H2 or HSQL automatically creates in memory data source and do automatically with sensible defaults

2 How connection established for Mysql ?

Ans: App.properties files will have connection. Boot creates Data Source with this properties.

3.How it has Embedded Servlet Container?

Ans: Spring-boot-starter-web 
When web is added  then spring-boot-starter-tomcat is automatically pulled. It has embedded container.

4.How to change to jetty server instead of tomcat?

Ans: Exclude Spring-boot-starter-tomcat and include Spring-boot-starter-jetty

5.What is Fat jar

Ans: Spring-boot-maven plugin creates single deployment unit which runs in production without IDE that’s nothing but fat jar.

Thanks for Reading!!!Comments and Suggestions always welcome

Read More