Monday, March 29, 2021

Enterprise Java Bean (EJB)

 ðŸ‘‰    What is EJB and specify its components?

*    It is a specification given by Sun's Micro-system to develop secured, robust and scalable distributed systems.

*    It is a server side component and hence reusable.

*    It is similar to a java class and typically contains the business logic.

*    There are mainly 3 types of EJB's

    1.    Entity Bean.

    2.    Session Bean.

    3.    Message driven.

 ðŸ‘‰    What is Enterprise Java Server(EJS) ?

*    The EJS is the server where the EJB is deployed (Server-side).

*    This is a part of the application server that hosts the EJB container.

*    EJB cannot directly interact with the EJS whereas it uses a middleware.

*    EJB specification outlines eight services that must be provided by the EJS such as :

    1.    Naming.
    2.    Transaction.
    3.    Security.
    4.    Persistence.
    5.    Concurrency.
    6.    Life-cycle.
    7.    Messaging
    8.    Timer.

*    Examples    :    WebSphere, Sun Application Server, Oracle Application Server, JBoss

 ðŸ‘‰    Briefly explain the EJB components ?

*    First lets categorize the EJB as follows which makes it easier to understand the concepts:


*    EJB components are categorized as synchronous and asynchronous.

*    Entity bean and the session bean are categorized in the synchronous block while the message driven bean is an asynchronous block.

*    The Entity bean is further classified as Container Managed Persistence (CMP) & Bean Managed Persistence (BMP).

*    The session bean is further classified as stateless and stateful.

NOTE : Lets consider the Student Management System for explaining the EJB components further.

 ðŸ‘‰    What is an Entity Bean in EJB components ?

*    Java objects are created when the program is created and lost when the program terminates. But the entity bean stays until it is deleted. 

*    Typically in the business logic entity beans are backed up onto a stable storage media (in most cases it is a database).

*    The entity bean has a primary key. It is used to uniquely identify the data in the entity bean.

*    @Entity annotation is used to specify an entity bean class.

*    This must be a non-final concrete class and no methods in the entity bean is final.


*    CMP    -    The container maintains persistence transparently using JDBC calls.
*    BMP    -    The programmer provides the persistence logic. It is used to connect non-JDBC calls. 

*    Lets consider out Student management example.
    The nouns in the system are categorized under the Entity Bean. Eg. Student, Timetable, etc.

 ðŸ‘‰    What is an Session Bean in EJB components ?

*    There are 2 types of session beans mainly :

    1.    Stateless Session Bean (SLSB).

*    It is not essential to remember the client state when considering the SLSB.

*    @Stateless annotation is used to denote a SLSB.

*    The optional lifecycle callback events are @PostConstruct and @PreDestroy.

    2.    Stateful Session Bean (SFSB).

*    Maintains the conversational state of the client.

*    Each instance in the SFSB maintains an instance of the client.

*    @Stateful annotation is used to denote a SFSB.

*    The optional lifecycle callback events are @PostConstruct and @PreDestroy.

*    Lets consider out Student management example.

    The verbs in the system are categorized under the Session Bean  (The Methods) . 
    Eg. addStudent(), register(), etc.


 

 ðŸ‘‰    What is an Message driven Bean in EJB components ?

*    This is invoked by asynchronous messages.

*    This cannot be invoked by remote or local interfaces.

*    @MessageDriven is the annotation used to mark a message driven bean.

*    It is stateless and transaction aware.




 ðŸ‘‰    List some advantages of EJB ?

*    Simplified development with a reliable robust and portable application.
*    Focuses on the business logic without considering the application development.
*    Increase in the developer productivity.
*    Reduces the time to launch the real-time critical systems.


Sunday, March 21, 2021

Point-to-point Integration | Enterprise Integration

👉    What is point-to-point integration?


*    This is simple way of integration among the integration models. This integration model is used when the sender sends a message and it is received only by one receiver. (1 sender : 1 receiver).
*    Example    :    Updating the human resource database with the information from an ERP system.

*    The above diagram shows a point-to-point integration sample in a organization. Here every system or the services in most cases has physical connection to all other services/systems in the organization.
*    This means the IP addresses all the system/services should be stored in each individual system/service in the organization for an effective communication.
*    The number links in the overall integration is equal to 
       Number of Links = N ( N - 1 )

👉    What are the advantages in point-to-point integration?

*    This integration provides a way to connect between all systems/services throughout the organization.

👉    What are the drawbacks of point-to-point integration?

*    Complexity due to the number of physical links which in turn hardens to find errors when there is a fault.
*    The main drawback is the difficulty in update of the services.
     Lets consider a scenario where the IP address of a particular system/service changes in an instance. Now each and every system/service should be re-configured to set the newly added IP address. This can yield more time and it is cost consuming.

👉    What is the solution for the drawback in point-to-point integration?

*    The main idea behind the drawback is that its tight coupling between the services or the systems. Since the IP address and necessary configurations are fed into each system/service individually, the problem arises.
*    `This can be prevented by using the mediator design pattern in the integration model.


👉    What is used as the mediator in the above scenario?


*    The ESB or the service proxy is used as the mediator in this scenario.
*    Now the ESB/service proxy serving as the mediator the messages flow only across the necessary sender and the receiver. 
*    All the system/services configurations in the organization are configured in the service proxy, not in the individual systems.
*    This serves as the solution for updating the configuration in one system/service. 
*    In case the configuration of the system/service changes it is only needed to change the configuration in the service proxy not on all individual components.
*    This helps in creating, updating and deleting the components in the enterprise environment.
*    The complexity of he communication is also decreased and helps to easily understand the flow of the communication path.

👉    What is an ESB?

*    Enterprise Service Bus (ESB) is a software architecture model used for designing and implementing the interaction and communication between mutually interacting software components in service oriented architecture.
*    An example for ESB is the WSO2 ESB.


👉    What are the features of ESB?


*    Promotes asynchronous message passing between the components.
*    Identify the type of message and route in-between the receivers.
*    Allow message to transport across different transport protocols.
*    System status, statistics with graphs are maintained. -- More of WSO2 ESB feature --
*    SOAP tracer.
*    Logs, configuring and monitoring.
*    Allow secure and reliable communication.

👉    What are the architecture of WSO2 ESB?




*    The above diagram shows the arrangement of WSO2 ESB.
*    The ESB is totally dependent on the WSO2 Carbon.
*    The WSO2 ESB mainly consists of WSO2 Carbon and the Apache Synapse.
*    The WSO2 ESB lies above the Apache Tomcat Server,
*    The Apache synapse is based on Axis2 or Java.
*    This acts as an Apache mediation library for different protocols.
*    Supports different protocols through SOAP based proxy services.    

👉    Instance of using ESB in a business scenario?

*    Consider a business scenario where the user has to download an image from the drop box, post it to Facebook and send notifications to his/her friends in twitter.
*    In this kind of complex scenario a ESB can be used.
*    The user can get the image in drop box through request in ESB .
*    Then the ESB can handle the posting to Facebook then sending notifications to friends in twitter,
*    Finally the user is notified from the ESB that the process is successful.


Sunday, March 14, 2021

Introduction to Testrail

 ðŸ‘‰    What is testrail?

*    It is a web based test case management tool. It is popular for its user-friendly interface and easy graphical way of displaying the results for the testcases,
*    It is used by the testers, developers and other teams that take effort to manage the software quality in all terms.
*    It can be used online using the cloud as the storage or it can be deployed in the local machine.




👉    What are the advantages of testrail?

*    Manage test cases, test suites and test runs,
*    Boost testing productivity.
*    Real-time tracking of the test runs and evaluation of results.
*    Generation of different kinds of report for the results.

👉    What are the steps in creating a test in testrail?


1.    Creating a project.

*    After you sign in to your free trial account you are launched at the dashboard of testrail.
*    You can see the necessary steps involved in creating a test in testrail at the bottom of the dashboard,.
*    Click on the 'Add Project' on the right hand corner of the project.
*    Give it a name, announcements(if needed) and select the repository (single/ testsuite).
*    Click in the add project button after filling all the above details.
*    Then you are launched at the project dashboard.





2.    Creating a test case.

*    Click on the testcases tab in the navigation bar.
*    You can see 2 buttons namely ' Add Section' and 'Add testcase'.
*    The difference between them is the section consist of multiple testcases inside it and the other button creates a individual test case.
*    For example consider payments as a section with its own testcases.
*    Select a option and give the necessary details such as title for testcase, references if present, etc. 
*    Here the most important is the preconditions, steps and the expected result.
*    Consider a test case called Login.
      Preconditions           :    The user should have a username and password.
      Steps                        :    Enter the username and password. Then click on the Login button.
      Expected Results     :    The user should be successfully logged in.

3.    Creating a test run.

*    After creating the testcase again you are launched on the project dashboard.
*    Click on the 'Test Run' tab in the navigation panel.
*    Select new run.
*    Fill the relevant details which includes a description for a test run along with the testcases to be included.  
*    Click on the add test run button.



4.    Checking the test results.

*    Soon after you create a test run you are launched at the test results page.
*    Here you can see the results in a pie chart and all the test cases related to the test run is shown as a list.
*    You can manually set the run to passed by changing the status to passes along with a comment.

NOTE : These are the four main steps involved in creating a test in testrail, the other two steps involve in connecting to external environment.



5.    Inviting users.

*    After you create a test in testrail, you are able to invite external users to your project and give access to the testcases as needed.
*    To do this you should select the 'Administration' tab in the navigation tab.
*    Select the users and roles.
*    Invite the users by giving their name and the email address.
*    Click on the invite user button when you are done with the above steps.

6.    Setting up integration.

*    To do this you should select the 'Administration' tab in the navigation tab.
*    Select the integration.
*    You can setup a 'Jira Integration' or a 'Assembla Integration' with your relevant Jira configurations.
*    The lower part of the page consists of URL that need to be specified if a particular test case is failed.
*    There is a facility to set testrail notify you via a email in case a testcase fails.
*    Click on the set integration button when you are done.

These are the main steps involved in creating a test in the testrail. This is just a outline of testrail and basis that can be done in the tetrail.   

Click on the below link if you need to try testrail.
 

Sunday, March 7, 2021

NoSQL & Overview of MongoDB

 ðŸ‘‰    What are the types of NoSQL databases?

            1.    Key-value

*    Here the data is stored in key value pairs. Each data is stored in an attribute name and its corresponding value.

*    This has two columns in which the first column is the key and the second column is the value. 

*    Examples :    Redis, Riak, memcached.

            2.    Document.

*    This database type stores data in JSON, BSON or XML documents.

*    Its is the most common database type. The popular MongoDB is the type of document database.

*    Document databases are flexible to rework the modify structures according to the application, shaping their data structures as their application requirements change overtime.

            3.    Column-family.

*    Store data in column families.

*    Columns are grouped according to the data and organized to columns appropriately. This helps to read the columns directly without consuming memory.

            4.    Graph.

*    This database type focuses on the relationship between the data elements.

*    This is much similar to a relational database which the connections between the data elements are called links or relationships.

*    This database organize the data elements along with its relationship in a analytics format which is easy to understand and grab the database content.  

*    The example for a graph database is Neo4j.

Read more on NoSQL database types


 ðŸ‘‰    Mongo Database.



            1.    Features of MongoDB.
                
                   *    This is a type of document NoSQL database.
                   *    Uses the spidermonkey JS engine.
                   *    This contains a in-built storage named grid file system.

        2.    Special documents of MongoDB.
                
               *    Multi-document transactions.
               *    Indexing capabilities.
               *    In memory storage engine.
               *    Sharding.

       3.    Using MongoDB.
            
               *    Install MongoDB enterprise community to the local machine.
               *    Use studio3T or Robo3T to work with MongoDB.
               *    Use the online MongoDB Atlas.

       4.    Some basic MongoDB commands(in studio3T).

               *    Create a database called university.
                     use university
                
               *    Create a collection (table) called student in the database university and insert document                         (record in table).
                     db.student.insertOne({name:"John", address:"Kandy", age:"20"})
                     db.student.insertMany({name:"John", address:"Kandy", age:"20"},
                                                          {name:"Jane", address:"Colombo", age:"20"})


               *    Open a document in collection.
                     (Retrieve all the documents in the collection)
                     db.student.find()
                     (Retrieve specific document in the collection)
                     db.student.find({name:"John"})

               *    Remove document in collection.
                     db.student.remove()

               *    Update document in collection.
                     db.student.update({name:"John"},{$set:{address:"Galle"}})

               *    Update an array and new value to array.
                      db.student.update({name:"John"},{$push:{subjects:"Galle"}})   

                        

Monday, March 1, 2021

Socket Programming

 ðŸ‘‰    What is a socket?

            *    A socket is an object created by the operating system to communicate with the ports in the                      network.
            *    Its is a logical construct.

 ðŸ‘‰    What is the difference between socket and ports?

            *    A ports is a acting like a door or window of a particular network, while a socket is a object                      created by the OS  that communicates with the ports.
            *    Ports are physical construct while the sockets are logical construct.

 ðŸ‘‰    What is the types of sockets?

            *    TCP Sockets    :    Connection oriented and reliable.
            *    UDP Sockets    :    Not connection oriented and non-reliable.

 ðŸ‘‰    Explain on TCP Sockets and UDP Sockets?

            *    TCP Sockets are used in the reliable application          Eg    :    Email, http
            *    UDP Sockets are used in non-reliable application        Eg    :    Streaming applications

            *    In TCP Sockets one application is assigned to one particular socket.
            *    In UDP Sockets many applications are assigned to one particular socket.

 ðŸ‘‰    Explain the connection establishment process between client and server using            the TCP Sockets?

            

            *    The client consists of the client socket.
            *    The server consists of welcome socket and the connection socket.
            *    The client is an active entity while the server is a passive entity.
            *    The client sockets initiates connection while communicating with the Welcome socket in the                   server.
            *    The Welcome server is responsible to accept the client.
            *    Once the client is accepted then the client socket starts communication between the                                  connection socket in the server.
            *    In the meantime, the welcome socket becomes free and wait for other client processes.

 ðŸ‘‰    What is blocking in sockets?

            *    Blocking means no other client is able to access while a particular client got accepted.
            *    The other client processes has to wait until the socket becomes vacant.
            *    A solution for this is Multi-threaded programming.

 ðŸ‘‰    Java socket programming.

            *    The java.net and above supports socket programming.
            *    To use socket programming in java , the below should be imported.
                        import java.net.*
            *    Simple chat applications can be constructed using the socket programing.

 ðŸ‘‰    Java socket programming classes.

            1.    Inet Address class.
            2.    Socket.
            3.    Server Socket.
            4.    Datagram Socket.
            5.    Datagram Packet.

            *    The yellow colored ones belong to TCP Sockets.
            *    The red colored ones belong to UDP Sockets.


Monolithic vs Microservices

👉     Monolithic Architecture. *     Monolithic architecture was there before Microservices came into action.  *     All functionalities or...