26
IBM WebSphere Application Server V4.0 IBM WebSphere Application Server V4.0 Extended Messaging Support in WebSphere EE 01/31/02 ' Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 1 of 26

Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

IBM WebSphere Application Server V4.0IBM WebSphere Application Server V4.0

Extended Messaging Support in

WebSphere EE

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 1 of 26

Page 2: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Messaging in an n-Tier environmentMessaging support in WebSphereJMS Listener in WebSphere Enterprise Extensions

Programming modelConfiguration fileTransaction supportConnection poolingPrerequisitesFurther reading

AgendaAgenda

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 2 of 26

Page 3: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Messaging in an n-Tier environmentMessaging in an n-Tier environment

WAS CTS

Tier-0 Web Browsers

Tier-1 Servers Presentation Logic

Tier-1 Clients

B2B Connections

Tier-2 Servers Business Logic

Tier-3 Servers Data Logic

PvC

DocumentExchange

MethodExchange

MessageExchange

ServletServlet

JSPJSP EJBEJB

EJBEJBEJBEJB

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 3 of 26

Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a messaging client can send messages to, and receive messages from, any other client. Each client connects to a messaging agent that provides facilities for creating, sending, and receiving messages. Servlets and EJBs can send and receive messages to/from a messaging vendor.Messaging technologies provide an additional means of communicating with Server Side Components

Page 4: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Loose CouplingEnables application programs to communicate asynchronously with each otherApplication data sent as a messageIf the receiver, or the communication channel to it, is temporarily unavailable, the message can be forwarded at a later time.

Messaging in an n-Tier environmentMessaging in an n-Tier environment

MessagingMiddleware(QUEUE)

PUT GET

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 4 of 26

Messaging enables distributed communication that is loosely coupled. A component sends a message to a destination, and the recipient can retrieve it from the destination. However, the sender and receiver do not have to be available at the same time in order to communicate. In fact, the sender does not need to know anything about the receiver, nor does the receiver need to know anything about the sender; they only need to know what message format and what destination to use. In this respect, messaging differs from tightly coupled technologies such as Remote Method Invocation (RMI), which require an application to know a remote application's methods.

Page 5: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Messaging support in WebSphereMessaging support in WebSphere

WebSphere 4.0Application

Server

EJBEJB

EJB Container

ServletServlet

JSPJSP

Servlet Container

JNDI

JTA

RM

I/IIOP

JDBC

JavaMailJAF

J2EE Server Core

Client Program(Java, C++, VB

etc.)

Message PUT Message GET

Message GET

Message PUT

Inbound

Outbound

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 5 of 26

Applications running in WebSphere can create, send and receive messages using JMS

Page 6: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Inbound and Outbound messagesInbound and Outbound messages

Inbound MessagesInject work into WebSphere Application ServerAn EJB or Servlet programmatically receives messages from a JMS Destination (QUEUE)

... or uses a JMS Listener

Outbound messagesDelegate work to application components outside WebSphereWebSphere sends messages to a JMS Destination

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 6 of 26

A JMS Listener automates tasks that would otherwise be done by the application code.In JMS, a Message Queue is referred to as a JMS Destination.JMS Destinations can be of two types

Queue: Used for Point-To-Point messagingTopic: Used for Publish/Subscribe messaging

Page 7: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Message Listener in an n-Tier environmentMessage Listener in an n-Tier environment

JMS Listener--> adds function to the server --> new source of inbound work--> target is EJBs

Tier: Server-Side Business Logic

Tier: Server-Side Data Logic

Tier: Client-Side Presentation

J2EE Server Core

JNDI

JTA

RMI/IIO

P

JDBC

JavaMail

JAF

Client Container

Servlet Container

ServletServlet

JSPJSP

JNDI

JTA

RMI/IIO

P

JDBC

JavaMail

JAF

J2EE Server Core

RMI/IIOP

RM

I / IIOP

BusinessBean

EJB Container

J2EE Server Core

JNDI

JTA

RM

I/IIOP

JDBC

JavaMail

JAF

QueueMessage

Bean

Listener

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 7 of 26

Page 8: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Benefits of JMS ListenersBenefits of JMS Listeners

Automatic consumption of messages

No polling needed in the application code

Reduce application codeSynchronous communication between Queue and ListenerLeave resource management to the container

RMI/IIOP

BusinessBean

EJB Container

J2EE Server Core

JNDI

JTA

RM

I/IIOP

JDBC

JavaMail

JAF

QueueMessage

Bean

Listener

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 8 of 26

Page 9: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Send datato Queue

Wait tillWebSphere isready

Deliver datato WebSphere

JMS ListenerJMS Listener

MessagingMiddleware(QUEUE)

PUTGET

BusinessBean

EJB Container

J2EE Server Core

JNDI

JTA

RMI/IIO

P

JDBC

JavaMail

JAF

MessageBean

Listener

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 9 of 26

Page 10: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

"Application component that accepts INBOUND messages"

A Message Bean is a Stateless Session Bean that follows certain guidelines

Automatic synchronous delivery of messagesInjects work into a WebSphere applicationProvides transactional supportFollows direction for Message Driven Beans

Message Driven Beans defined in J2EE 1.3 specSupported in the next WebSphere release

Built upon MQSeries and JMS

Message BeanMessage Bean

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 10 of 26

Page 11: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Message and Business ProcessingMessage and Business Processing

Provide separation between theListener and Business logic

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 11 of 26

By providing a clear separation between message and business processing, it is easier to implement the Message Beans as Message Driven Beans (J2EE 1.3)

Page 12: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

public void onMessage(javax.jms.Message msg)

{try{

System.out.println("Input message = "+ ((TextMessage) msg).getText.());

MyEJBHome home = (MyEJBHome)PortableRemoteObject.narrow(ic.lookup("com/mycom/MyEJBHome"),MyEJBHome.class);

MyEJBHome obj = home.create();

obj.myBusinessMethod(msg); // business method

}catch(Exception err){err.printStackTrace();}

}

onMessage()onMessage()

Invoke theBusiness Bean

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 12 of 26

An example of a Message Bean invoking a Business Bean

Page 13: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Listener ManagerListener Manager

Every AppServer has a Listener ManagerEnabled during AppServer initializationCreates JMSListeners for destinations

Based upon a user provided XML configuration file

Interfaces with JMS Application Server Facilities (ASF)Controls the cleanup of resources during server shutdown

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 13 of 26

Page 14: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Sample XML Configuration FileSample XML Configuration File<Config>

<Pooling> <Timeout> 300000 | timeoutMilliSeconds </Timeout> <Threshold> 10 | maxUnusedConnections </Threshold></Pooling><Listener> <HomeJNDIName> homeName </HomeJNDIName> <JMSConnectionFactory> factoryJNDIName </JMSConnectionFactory> <JMSDestination> destinationJNDIName </JMSDestination> <JMSDestinationType> javax.jms.Queue | javax.jms.Topic </JMSDestinationType> <JMSSubscriptionDurability> nondurable | durable </JMSSubscriptionDurability> <JMSSubscriptionName> name </JMSSubscriptionName> <JMSMessageSelector> selector </JMSMessageSelector> <JMSAcknowledgeMode> auto-acknowledge | dups-ok-acknowledge

</JMSAcknowledgeMode> <MaxRetries> 0 | retryNumber </MaxRetries> <MaxSessions> 1 | sessionNumber </MaxSessions> <Transactional> true | false </Transactional></Listener>

<Listener> ............ </Listener> </Config>

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 14 of 26

In order to enable Message Beans, the AppServer has to be provided a configuration file. This configuration file is read when the AppServer starts up.A sample configuration file is provided with WebSphere.In the config file, the underlined values are the defaultsThe config file can have multiple <Listener></Listener> tag pairs.The config file can have only one <Pooling></Pooling> tag pair.

Page 15: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

JMS Listener Configuration in AEsJMS Listener Configuration in AEs

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 15 of 26

Specifying the location of the XML config file in AEs

Page 16: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

JMS Listener Configuration in AEJMS Listener Configuration in AE

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 16 of 26

Specifying the location of the XML config file in AE

Page 17: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

ScalingScaling

A single Application Server can have multiple JMS Listeners

JND

I

JTA

RM

I/IIO

P

JDBC

JavaMail

JAF

JSP

Servlet

EJB2EJB Module

Web Module

EJB3EJB1

MessageBeans

JMSDestinations

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 17 of 26

Page 18: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

MQSeries configurationMQSeries configuration

JMSAdmin.config in <MQ_JAVA_INSTALL>AEs

INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactoryPROVIDER_URL=file://C:/JNDI-Directory

AEINITIAL_CONTEXT_FACTORY=com.ibm.ejs.ns.jndi.CNInitialContextFactory

PROVIDER_URL=iiop://localhost/

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 18 of 26

JMSAdmin.bat is a configuration tool provided by MQSeries as part of the MA88 install. The tool uses a configuration file (default name JMSAdmin.config).The foil above shows the differences between AE and AEs when providing JNDI options in the config file.In AEs, we use a file system (C:\...) to configure the JMS administered objects. The reason being that AEs does not persist its JNDI namespaceIn AE however, we can rely on using WebSphere namespace (iiop://localhost/)

Page 19: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Listener Manager - One per AppServerListener Manager - One per AppServer

a Listener Manager

a Listener 01

a Listener 02

a Listener 03

Queue A

a Connection

Queue B

a Connection

a Message Bean 02 a Message Bean

03

a Message Bean 01

sessions

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 19 of 26

One Listener Manager per App ServerMany Listeners per Listener ManagerOne connection per ListenerMany Sessions per connectionListener threads are managed by the Listener ManagerMessage Bean Session threads are managed by the Listener One Listener corresponding to a <Listener></listener> tag pair in the XML config fileMessage Bean has the onMessage() method

Page 20: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Filtering the message headerFiltering the message header

a Listener Manager

a Listener 01

a Listener 02

a Listener 03

Queue Ba Connection

a Message Bean 02 a Message Bean

03

a Message Bean 01

sessions

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 20 of 26

Message headers can be read before pulling messages off a Queue.The filtering criteria is specified in the XML config file.

Page 21: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Queues/Topics

Q1Destinations

MessageBeans

BusinessBeans

M1

B1

Q2

M2

B2

Q3

B3

T1

M3

B4

T2

M4

Message FlowMessage Flow

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 21 of 26

Page 22: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Allows JMS Listener participation in a 2-phase commitConfiguration

In XML configuration file: Transactional = true<Transactional> true | false </Transactional>

Use JMSAdmin to configure WebSphere JMS / XA connection factories

Transactional SupportTransactional Support

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 22 of 26

The JMSAdmin tool is provided by MQSeriesDetailed information on this tool can be found in the redbook "MQSeries Using Java"

Page 23: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Enable MQSeries connection poolingProvides improved JMS system performanceMaximum benefit when connections used for short timeEnabled by Listener during initialization

ConfigurationValues specified via configuration fileWill use default values if not specified

Timeout = 300000 millisecondsThreshold = 10 Connections

Connection PoolingConnection Pooling

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 23 of 26

Page 24: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

WebSphere 4.0 (AE/AEs + EE) and it's pre-reqs

MQSeries V5.2 Server

MQSeries JMS support pack - MA88http://www-4.ibm.com/software/ts/mqseries/txppacs/ma88.html

MQSeries Pub/Sub support pack - MA0Chttp://www-4.ibm.com/software/ts/mqseries/txppacs/ma0c.html

System RequirementsSystem Requirements

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 24 of 26

Support pack ma0c needs to be installated in MQSeries to enable Publish/Subscribe. This is in addition to ma88 support pack.

Page 25: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

Part of WebSphere 4.0 EEProvides ability to inject work into the systemProvides transaction supportProvides connection pooling with MQSeriesFollows direction for Message Driven Beans in J2EE 1.3

Summary - JMS ListenerSummary - JMS Listener

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 25 of 26

Page 26: Extended Messaging Support in WebSphere EE · Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: a

������������

DocumentationDocumentation

WebSphere EE 4.0 InfoCenter

"MQSeries Using Java" SC34-5456-06 http://www.redbooks.ibm.com

White Paper- WebSphere 3.5 JMS/JTA support for MQSeries

http://www-4.ibm.com/software/webservers/appserv/whitepapers/was_mqseries.pdf

http://www.javasoft.com/jms

01/31/02 © Copyright IBM Corporation 2001 JMSListenerPrezAEs.PRZ Page 26 of 26