Quick guide to Websphere MQ


It is the Messaging style of communication the communication takes place between Queue Managers.

Firstly the application program writes to the some name queue then the queue manager determines the location of those queues and handles all of the communication.

MCA ( Message channel agent ) is the Queue Manager program to perform the network communication.

If messages to be delivered to the remote queue the queue manager checks it and put it into the transmission queue to process further.

MQPUT (write) to MQGET (read)

IBM WebSphere reference architecture

http://publib.boulder.ibm.com/infocenter/wmqv7/v7r1/index.jsp

Synchronous

Asynchronous

SOA

Reduce the service to bare business logic

Resource Manager Or Queue manger owns the queue (MCA – Message channel agent)

MQPut

MQGet

Application –> MQ Interface (MQI) –>Queue Manager –> Process Definition –> Queues

Major Calls

  • MQCONN
  • MQCONNX
  • MQDICS
  • MQOPEN
  • MQCLOSE
  • MQPUT – Write
  • MQPUT1
  • MQGET – Read
  • MQSUB
  • MQSUBRQ

Minor Calls

  • MQBEGIN
  • MQCOMIT
  • MQBACK
  • MQINQ
  • MQSET

MQ Messages = Header + Application Data

Header – Message descriptor

WebSphere MQ largest message size is 100 MB

Easily process data in parallel

Conversation

Call and return

Messaging

Program MQI

retrieve messages from queue

Lets now jump in and create the real life example

I will share an example of StockQuote (i.e. stock price)

We require IBM WebSphere MQ Explorer 7.1 software

1)

StockQuotes
1414

****************************************
* Command: “E:\Program Files\IBM\WebSphere MQ\bin\crtmqm” -sa StockQuotes
****************************************
WebSphere MQ queue manager created.
Directory ‘E:\Program Files\IBM\WebSphere MQ\qmgrs\StockQuotes’ created.
The queue manager is associated with installation ‘Installation1’.
Creating or replacing default objects for queue manager ‘StockQuotes’.
Default objects statistics : 74 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.
exitvalue = 0
****************************************
* Command: “E:\Program Files\IBM\WebSphere MQ\bin\strmqm” StockQuotes
****************************************
WebSphere MQ queue manager ‘StockQuotes’ starting.
The queue manager is associated with installation ‘Installation1’.
5 log records accessed on queue manager ‘StockQuotes’ during the log replay phase.
Log replay for queue manager ‘StockQuotes’ complete.
Transaction manager state recovered for queue manager ‘StockQuotes’.
WebSphere MQ queue manager ‘StockQuotes’ started using V7.1.0.0.
exitvalue = 0
****************************************
* Command: “E:\Program Files\IBM\WebSphere MQ\bin\runmqsc” StockQuotes
* Input: DEFINE LISTENER(‘LISTENER.TCP’) TRPTYPE(TCP) PORT(1414) CONTROL(QMGR)
****************************************
5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED.
Starting MQSC for queue manager StockQuotes.
1 : DEFINE LISTENER(‘LISTENER.TCP’) TRPTYPE(TCP) PORT(1414) CONTROL(QMGR)
AMQ8626: WebSphere MQ listener created.
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
exitvalue = 0
****************************************
* Command: “E:\Program Files\IBM\WebSphere MQ\bin\runmqsc” StockQuotes
* Input: START LISTENER(‘LISTENER.TCP’)
****************************************
5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED.
Starting MQSC for queue manager StockQuotes.
1 : START LISTENER(‘LISTENER.TCP’)
AMQ8021: Request to start WebSphere MQ listener accepted.
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
exitvalue = 0

Advertisements

JAVA Design Pattern


JAVA Design Pattern

The design patten is a vast subject, I will be giving you an head start here

Gang of Four – widely used design patterns

  1. Behavioral patterns
    1. Chain of responsibility
    2. Command
    3. Interpreter
    4. Iterator
    5. Mediator
    6. Memento
    7. Observer
    8. State
    9. Strategy
    10. Template method
    11. Visitor
  2. Creational patterns
    1. Abstract factory
    2. Builder
    3. Factory method
    4. Prototype
    5. Singleton
  3. Structural patterns
    1. Adapter
    2. Bridge
    3. Composite
    4. Decorator
    5. Facade
    6. Flyweight
    7. Proxy

Definition:- Common Problem and Common Solution for them, If you have data with problem and to tackle that you need to find problem pattern and propose solution pattern for that.

Note: No body owns the design pattern

Standard pattern are 23 those are listed above.

J2EE design pattern standardize by sun

EJB Patterns

  1. Intercepting Filter (apache mod rewrite)
  2. Composite View
  3. Front Controller
  4. Service to worker
  5. Business delegate
  6. Service Locater
  7. Transfer object assembler
  8. Facade

site: theserverside.com
site:www.tml.tkk.fi/~pnr/GoF-models/html

EJB cont


Entity Bean

An entity bean is representation of single row in a databases. Entity always be an heavy component. But the connectivity to database will be a transparent to developer. When you create a new entity bean automatically in database new row will be added.

ORM – Object Relational Mapping, row in a table will be one object in memory.

Stateless Session Bean can have pooled creation.

Statefull Session Bean can have cached creation.

But Entity bean can have either cache or pooled creation.

Whenever you need to work with processed or in other words process matters over data you should use session bean. But whenever you want to work with DATA or in other words DATA matters over process you should use entity beans.

Entity beans are heavy object because its a in memory object for database table. Where each instance of entity bean object refer to one record set in table or row in table.

Entity beans are of two types
Bean Managed Persistence
Container Managed Persistence

CMP Bean
Local Client
Remote Client

Favourite topic WSAD entity bean example 🙂 without writing a single line of code get the entity bean in place here we go

  1. Create new project EntityBean
  2. Create new Enterprise bean
  3. Select Type Entity bean
  4. Select CMP bean 2.0
  5. Bean detail select Remote & Local both the interfaces
  6. Select the project
  7. Run the Entity bean on server
  8. Configure new Test Server or run on existing server
  9. Create table and deploy entity bean
  10. Finish
  11. It will show success message, i.e. it will test the create and alter statement on newly created table.
  12. Select server client local
  13. Finish
  14. It will open Test Client
  15. Click on EntityExampleLocal
  16. Click on CMPLocal.findByPrimaryKey
  17. Enter value into and click invoke.

This how you will be testing tyour entity beans. Just now what we have seen is the Top to Bottom appoch, we have another approach which is Bottom to Top where in we will be having table already existing in and then will be creating the entity bean accordingly.  

Facts……….

-EJB can be accessed using servlet
-Entity Bean should not be remote
-Session Bean should not be local
-In entity bean you should not use primitive data-type.

ENTERPRISE JAVA BEANS


sCOPE oRGANIZATION wIDE

MVC
Model= EJB
View= JSP
Controller = SERVLET

Why should we go for EJB?
Scalability (application should work same for 2 client and 2 million client.)
Should be catering to multiple request simulatanously.
Problem with the thread is Sycronization.
EJB CONTANER, will work on instance pooling and multiple instance.

Example
jdbc

to enable tansaction, first step is to make the autocomit off.
set autocommit flase applicable to the JVM where this property is set.

focus should be buisness logic, let transaction manage by somebody so this will be managed by CTM (container transaction management)

Web server & application server
Diffrence
Application server is super set of web server. In other words web server can be one component in application server.
Main diffrence will be application server is aware of its surroundings.

  1. Security
  2. Application control
  3. Infrastructural Capability

Application Server Main Properties

  1. Transaction management
  2. LDAP
  3. Persistance
  4. Threading
  5. Socket
  6. DBMS

Enterprise Level Application
EJB can be deploy only on Application Server. Used for scalable problems.

MESSAGE BEANS: asyncronous communication

If you need to generalizes something you make implementation and every one will write interface for it.

EJB distributed component need security any request comes in from cinet has to be checked.

EJB Contaner will decide whether to provide you access or not.

Per bean there will be one instance object.
Rule of thumb: One client one bean one instance will be always true.

Types of Bean

  1. Session Bean
    1. Stateless bean
    2. Statefull bean
  2. Enttyty Bean
    1. CMP – Container Managed Persistence
    2. BMP – Bean Managed Persistence
  3. Message Driven Bean (MBD) – Asyncronous beans

what to used and when to use

Session
Dealing with process, Its a temporary or volatile.

Stateless-Session bean without any instance variables. i.e. processed are not dependent on each other. Example could be Controlling Mechenism

Statefull-Session bean with instance variable i.e.

Entity
Dealing with DBMS or Data

EJB FrameworkEJB framework Session Facade (Mean entry point.)

Creating session bean from Web Sphear Application Development.

EJB Module -> Project -> EJB -> Create 2.0 EJB -> Project Name -> Module Deps -> Finish

  1. newInstance()
  2. ejbCreate
  3. setSessionContext

Technology

Reflection & Retropection
Runtime can find out class and charachterstics

Terminology
Call back method
Calles when an event occurs.

Thoughts on java

Java in not 100% OO?
1) Static classes, does not require instance to acces its charachterstics.
2) Reperesantation of real world entity without charachterstic is not possible. But we can create java class without any class variables.

Import Definations

Abstraction
Real world entity properties create class.

Coupling and Cohesion Software Engineering.

Middleware


Middleware

Client/server is dead. That’s the buzz now that newer Internet-based technologies are flourishing. But those new technologies are merely the natural evolution of earlier approaches, implemented with newer, more open protocols and designed to provide greater scalability, manageability, and diversity.

Middleware is computer software that connects software components or applications. It is used most often to support complex, distributed applications. It includes web servers, application servers, content management systems, and similar tools that support application development and delivery. Middleware is especially integral to modern information technology based on XML, SOAP, Web services, and service-oriented architecture.

Types of middleware

  • Remote Procedure Call (RPCs) — Client makes calls to procedures running on remote systems. Can be asynchronous or synchronous.
  • Message Oriented Middleware (MOM) — Messages sent to the client are collected and stored until they are acted upon, while the client continues with other processing.
  • Object Request Broker (ORB) — This type of middleware makes it possible for applications to send objects and request services in an object-oriented system.
  • SQL-oriented Data Access — middleware between applications and database servers.
  • Other sources include these additional classifications:
    • Transaction processing (TP) monitors — Provides tools and an environment for developing and deploying distributed applications.
    • Application servers — software installed on a computer to facilitate the serving (running) of other applications.
    • Enterprise Service Bus — An abstraction layer on top of an Enterprise Messaging System.