Wednesday, 17 April 2013

Transaction Management


Do Everything or Nothing

  • The process compiling related operations into single unit and executing them by "Do Everything Or Nothing" principle is called Transaction Management.
  • Ex: Credit/Debit card processing of online transactions.
public void bm() {
try
{
Begin Transaction
operation1....
operation2....
operation3....
Commit Transaction
}
catch (Exception e)
{
rollback Transaction
}
}
  • Transaction Management gives support to ACID properties
    • A - Atomicity
    • C - Consistency
    •  I -  Isolation
    • D - Durability
  • Atomicity: Process of combining multiple and related indivisible operations into single unit.
  • Consistency: Guarantee of  "No rule violation" at the end of Transaction even though rules kept in database violated during the process.
  • Isolation: Preventing concurrent and simultaneous operations on database data.
  • Durability: The ability of bringing database software to normal state through log files and backup files when database is corrupted.

Saturday, 6 April 2013

JNDI




JNDI - Java Naming and Directory Interface

  • The JNDI is a Java API for a directory service that allows Java software clients to discover and lookup data and objects via a name.
  • Like all Java APIs, that interface with host systems, JNDI is independent of the underlying implementation.
  • Aditionally, It specifies a Service Provider Interface (SPI) that allows directory service implementations (like LDAP, DNS, NIS and etc...) to be plugged in to framework. It may make use of a server, a flat file, or a database; the choice upto the vendor.
  • JNDI is defined to be independent of any specific directory service implementation. Thus a variety of directories new, emerging and already deployed can be accessed in a common way.
  • The JNDI API is used by RMI and JEE APIs to lookup objects in a network.
  • JNDI API provides
    • A mechanism to bind an object to a name.
    • A directory lookup interface that allows general queries.

  • To provide Global visibility to Java objects and their references we keep them in registry software.
  • Every Web server/ Application server gives a registry software
    • Weblogic --> Weblogic registry
    • Tomcat --> Tomcat registry
    • Glassfish --> Glassfish registry
    • JBoss --> JNP registry
  • Java Applications use JDBC API (java.sql, javax.sql packages) to interact with Database software.
  • Java Applications use JNDI API (javax.naming and its subpackages) to interact with Registry software.
  • JDBC, JNDI are part of JSE module(JDK s/w).
  • Multiple Java Applications can use an object which was stored in JNDI Registry as shown in above diagram.


References:

Definitions


Information systems
Information systems is the study of complementary networks of hardware and software that people and organizations use to collect, filter, process, create and distribute data. Any specific information aims to support operations, management and decision making.

World Wide Web
A World Wide Web is a system of interlinked hypertext documents accessed via the Internet.

With a web browser, one can view web pages that may contain text, images, videos, and other multimedia, and navigate between them via hyperlinks.
Using concepts from his earlier hypertext systems like ENQUIRE, British engineer,computer scientist and at that time employee of CERN, Sir Tim Berners-Lee, now Director of the World Wide Web Consortium (W3C), wrote a proposal in March 1989 for what would eventually become the World Wide Web.
The terms Internet and World Wide Web are often used in everyday speech without much distinction. However, the Internet and the World Wide Web are not the same. The Internet is a global system of interconnected computer networks. In contrast, the Web is one of the services that runs on the Internet. It is a collection of text documents and other resources, linked by hyperlinks and URLs, usually accessed by web browsers from web servers. In short, the Web can be thought of as an application "running" on the Internet.[25]
Viewing a web page on the World Wide Web normally begins either by typing the URL of the page into a web browser or by following a hyperlink to that page or resource.


Communication protocol
A Communication protocol is a system of digital message formats and rules for exchanging those messages in or between computing systems and in telecommunications.

Software package
A specific piece of software which the system can install and uninstall.

Web service
web service is a method of communication between two electronic devices over the World Wide Web. A web service is a software function provided at a network address over the web or the cloud, it is a service that is "always on" as in the concept of utility computing.

Software component
An individual software component is a software package, a web service, a web resource, or a module that encapsulates a set of related functions (or data).

DelegateA person authorized to act on behalf of someone else. "Delegated" carries with it the connotation that one is acting as a representative of a superior in carrying out a task.
ProxyA person chosen or elected to act for or represent another or others.
Reference/ Source: http://www.wikipedia.org/

Java tutorials

JDBC Connection pool


Thursday, 4 April 2013

JMS





                                                             JMS

MOM (Message Oriented Middleware)
MOM is a software/hardware infrastructure supporting sending/receiving messages between distributed applications.


JMS (Java Message Service)
  • JMS is no way related with Java Mail.
  • JMS supports Asynchronous communication.
  • JMS API is a Java Message Oriented Middleware API for sending messages between two or more clients.
  • JMS is a part of the Java Platform, Enterprise Edition, and is defined by a specification developed under Java Community Process.
  • It is a messaging standard that allows application components to create, send, receive and read messages.
  • Messaging means "loosely-coupled distributed communication", where communication is between two software components.
JMS elements:
  • JMS Provider: An implementation of the JMS interface for a Message Oriented Middleware. JMS server/ provider supplies, destinations having capability to store messages temporarily.
    • MQ series from IBM
    • MSMQ from Microsoft
    • Weblogic Message Server from Weblogic(Application server)
    • Glassfish Message Server from Glassfish(Application server)
    • Every Application server supplies one built-in JMS server.
  • JMS Client:
    • A application or process that produces and/ or receives messages.
  • JMS Producer/ Publisher:
    • A JMS Client that creates and sends messages.
  • JMS Consumer/ Subscriber:
    • A JMS Client that receives messages.
  • JMS Message:
    • An Object that contains data being transferred between JMS clients.
  • JMS Queue:
    • A staging area that contains messages that have been sent and are waiting to be read. Note that, contrary to what the name queue suggests, messages don't have to be delivered in the order sent. The JMS Queue only guarantees that each processed only once. 
  • JMS Topic:
    • The distributed mechanism for publishing messages that are delivered to multiple subscribers.
A JMS Application is composed of the following parts:
  • JMS provider is a messaging system that implements the JMS interfaces and provides administrative and control freatures.
  • JMS clients are the programs or components, written in Java programming language, that produce and consume messages.
  • Messages are the objects that communicate information between JMS clients.
  • Administrated objects are preconfigured JMS objects created by Administrator for use of clients. The two types of administrated objects are destinations and connection factories.
  • Native clients programs that use a messaging product's native API instead of JMS API.
Fig: JMS Architecture
CF- Connection factory, D - destination

Messaging Domain:

  • There are two approaches of  Messaging
    • Point-to-Point Messaging Domain:
      • Fig: PtoP overview
      • uses JMS Queue
      • Each message has only one consumer.
      • The receiver acknowledges the successful processing of a message.
    • Publish/ Subscribe Messaging Domain:
      • Fig: Pub-Sub overview
      • uses JMS Topic
      • Each message can have multiple consumers.
Administrated objects: connection factories and destinations
  • Connections
  • Sessions
  • Message producers
  • Message consumers
    • Message selectors
    • Message listeners
  • Messages
    • A JMS Message has three parts
      • Header
      • Properties(optional)
      • Body(optional)
Fig: Client Application model

    Import resources of JMS API  related to Queue:

    • QueueConnectionFactory (I)
    • QueueConnection (I)
    • Queue (I)
    • QueueSession (I)
    • QueueSender (I)
    • QueueReceiver (I) and etc....
    Important resources of JMS API related to Topic:

    • TopicConnectionFactory (I)
    • TopicConnection (I)
    • Topic (I)
    • TopicSession (I)
    • TopicPublisher (I)
    • TopicSubscriber (I) and etc...
    Create Queue and Topic Destinations:

    • Create JMS Connection factory having a JNDI name:
      • JMS Connection facotry  represents JMS Connection pool.
      • Each Connection object represents the connection between Client Application and JMS Server.
    • Create Queue destination having a JNDI name
    • Create Topic destination having a JNDI name
      References: