43
© Adastra Group WMQ, WMB & EIP Message-Oriented Middleware jPrase Vít Kotačka 29. 3. 2012

WMQ, WMB and EIP

Embed Size (px)

DESCRIPTION

Presentation about Enterprise Integration Patterns (EIP), WebSphere MQ (WMQ) and WebSphere Message Broker (WMB).

Citation preview

Page 1: WMQ, WMB and EIP

© Adastra Group

WMQ, WMB & EIP

Message-Oriented Middleware

jPrase

Vít Kotačka

29. 3. 2012

Page 2: WMQ, WMB and EIP

2

Agenda

Enterprise Integration Patterns� Overview� Basic Patterns� Complex Patterns

WebSphere MQ� Overview� Java Interaction

WebSphere Message Broker� Overview� Route Node� Java Compute Node� Web Services

Page 3: WMQ, WMB and EIP

3

Enterprise Integration Patterns

Page 4: WMQ, WMB and EIP

4

Enterprise (Application) Integration

Enterprise integration is the task of making disparate applications work together to produce a unified set of functionality.

Page 5: WMQ, WMB and EIP

5

Main Integration Styles

File Transfer – each application produce files of shared data for others to consume and consume files that others have produced.

Shared Database – applications store the data they wish to share in a common database.

Remote Procedure Invocation – each application expose some of its procedures so that they can be invoked remotedly, and have applications invoke those to initiate behavior and exchange data.

Messaging – each application connect to a common messaging system, and exchange data and invoke behavior using messages.

Page 6: WMQ, WMB and EIP

6

Message

An atomic data packet that the messaging system can transmit from one system to another.

Two basic parts:� Header – information used by the messaging system that describes the

data being transmited (destination, expiration, sequence, etc).� Body – data being transmited.

Types:� Document Message – passes a set of data to another application.� Event Message – notifies another application of change.� Command Message – invokes a procedure in another application.

Java: JMS Message (TextMessage, BytesMessage, ObjectMessage, StreamMessage, MapMessage)

Page 7: WMQ, WMB and EIP

7

Message Channel

A logical address in the messaging system, connecting two applications.

One-way path – first application writes into while second application reads from the channel.

Types:� Point-toPoint Channel – one receiver will receive a particular message.� Publish-Subscribe Channel – delivers a copy of a particular message to

each receiver.� Message Bus – well-designed set of channels that acts like a

messaging API for a whole group of application.

Java: JMS Destination (Queue, Topic)

Page 8: WMQ, WMB and EIP

8

Message Endpoint

Encapsulates the messaging system from the rest of the application.

Is channel-specific, can be used to send OR receive messages(not both).

Types:� Selective Consumer� Durable Subscriber� Idempotent Receiver� Competing Consumers

Java: JMS Producer & Consumer

Page 9: WMQ, WMB and EIP

9

Message Router

A special filter which consumes a message from one message channel and republish it to a different message channel.

Types:� Content-Based Router� Dynamic Router� Message Broker

Java: Apache ActiveMQ/Camel, Spring Integration

Page 10: WMQ, WMB and EIP

10

Pipes and Filters

An architectural style to divide a larger processing task into a sequence of smaller, independent processing steps (filters) that are connected by channels (pipes).

Java: Intercepting Filter (Core J2EE Patterns)

Page 11: WMQ, WMB and EIP

11

Message Translator

A special filter for translation one data format into another. GoF Design Pattern Adapter. Levels of transformation:

� Data Structures – aggregations, cardinalities� Data Types - conversions� Data Representation – parse date and render in a different format.� Transport – move data across protocols

Java: ???, XSLT (Xalan)

Page 12: WMQ, WMB and EIP

12

EIP Basic Patterns Example

Page 13: WMQ, WMB and EIP

13

Message Broker

A central component that can receive messages from multiple destinations, determine the correct destination, and route the message to the correct channel.

Prevention of the spaghetti point-to-point integrations. Usually has to deal with translating message data formats

between applications. Usually uses a Canonical Data Model.

Java: Apache ActiveMQ/Camel, HornetQ (JBoss), BlazeDS

Page 14: WMQ, WMB and EIP

14

Canonical Data Model

A common model independent from any specific application. Require each application to produce and consume messages in this common format.

Java: Data Integration Guidelines (Java BluePrints Patterns) Non-Java: WSDL

Page 15: WMQ, WMB and EIP

15

WebSphere MQ

Page 16: WMQ, WMB and EIP

16

What is WebSphere MQ?

Software that enables programs to communicate across a network using a simple and consistent application programming interface. It is messaging and queuing middleware.

Messaging: programs communicate by sending each other data in messages rather than by calling each other directly.

Queuing: the messages are placed on queues in storage, so that programs can run independently of each other, at different speeds and times, in different locations, and without having a logical connection between them.

Page 17: WMQ, WMB and EIP

17

WebSphere MQ Explorer

Page 18: WMQ, WMB and EIP

18

Queue Manager

Owns and manages queues. Provides API to access queues and messages:

� Message Queue Interface (MQI)� Java Message Service (JMS)

May have multiple queue managers per system. The first WMQ object to be created.

Page 19: WMQ, WMB and EIP

19

Queue

Local queue: stores messages Remote queue: definition for queue that is owned by another

queue manager Transmission queue: temporarily stores messages that are

destined for remote queue managers. Dead-letter queue: designated for messages that cannot be

delivered

Page 20: WMQ, WMB and EIP

20

Message channel

Provides a one-way communication path from one queue manager to another for the transmission of messages.

Consists of� Sending MCA (Message Channel Agent)� Receiving MCA� Communication connection

Transmission queue is required (at the sending end).

Page 21: WMQ, WMB and EIP

21

Remote Queue Messaging

class WebSphere MQ

localhost

«executionEnvironment»WMQ local

«Queue Manager»QM_J PRASE

«Dead-Letter Queue»DLQ

«Receiver Channel»QM_REMOTE.QM_J PRASE

«Local Queue»RECEIVER

remote host

«executionEnvironment»WMQ remote

«Queue Manager»QM_REMOTE

«Dead-Letter Queue»DLQ

«Sender Channel»QM_REMOTE.QM_J PRASE

«Transmission Queue»QM_J PRASE

«Remote Queue»SENDER

TCP

«use»

«use»

«use»«use»

Page 22: WMQ, WMB and EIP

22

Java Interaction

WMQ classes for Java� Encapsulate the Message Queue Interface (MQI).� Full range of features of WMQ.� Not a standard, but more easy.

WMQ classes for JMS� An industry standard� Part of Java EE� Central repository of JMS administered objects

Page 23: WMQ, WMB and EIP

23

WMQ classes for Java

Requires Server-connection channel on the queue manager.

MQQueueManager queueManager =new MQQueueManager(QM_NAME);

MQQueue queue = queueManager.accessQueue(QUEUE,

CMQC.MQOO_OUTPUT);MQMessage message = new MQMessage();message.writeUTF("Hello, jPrase!");queue.put(message);

queue.close();queueManager.disconnect();

Page 24: WMQ, WMB and EIP

24

WMQ classes for Java (configuration)

Page 25: WMQ, WMB and EIP

25

WMQ classes for JMS

Requires Server-connection channel on the queue manager. Requires Initial Context (JMS Administered Objects) JNDI Namespace

� LDAP Server� File System� Other

JMS Administered Objects� Connection Factories� Destinations (mapped on queues)

Page 26: WMQ, WMB and EIP

26

WMQ classes for JMS (code)

ConnectionFactory factory = (ConnectionFactory) context.lookup("jPraseConnectionFactory");Connection connection =

factory.createConnection();Session session=connection.createSession(false,

Session.AUTO_ACKNOWLEDGE);Destination destination =

session.createQueue("JPRASE");MessageProducer producer =

session.createProducer(destination);TextMessage message = session.createTextMessage("Hello, jPrase!");producer.send(message);

Page 27: WMQ, WMB and EIP

27

WMQ classes for JMS (configuration)

deployment JMS Interaction

localhost

«executionEnvironment»WMQ local

«Queue Manager»QM_J AVA

«Local Queue»J PRASE

«Server-connection Channel»J AVA.CHANNEL

«I ni tial Context»file:/ jms

«Connection Factory»jmsConnFact

«Destination»J PRASE

Page 28: WMQ, WMB and EIP

28

WebSphere Message Broker

Page 29: WMQ, WMB and EIP

29

What is WebSphere Message Broker?

You can use IBM® WebSphere® Message Broker to connect applications together, regardless of the message formats or protocols that they support.

The product supports a wide range of protocols: WebSphere MQ, JMS 1.1, HTTP and HTTPS, Web Services (SOAP and REST), File, Enterprise Information Systems (including SAP and Siebel), and TCP/IP.

It supports a broad range of data formats: binary formats (C and COBOL), XML, and industry standards (WIFT, EDI, and HIPAA).

It supports many operations, including routing, transforming, filtering, enriching, monitoring, distribution, collection, correlation, and detection.

Page 30: WMQ, WMB and EIP

30

WebSphere Message Broker Toolkit

Page 31: WMQ, WMB and EIP

31

Message Flow

A sequence of processing steps that run in the broker when an input message is received.

A message flow must include an input node that provides the source of the messages that are processed. You can process the message in one or more ways, and optionally deliver it through one or more output nodes.

The message is received as a bit stream, and is converted by a parser into a tree structure that is used internally in the message flow. Before the message is delivered to a final destination, it is converted back into a bit stream.

Page 32: WMQ, WMB and EIP

32

Message Set

A container for grouping messages and associated message resources (elements, types, groups).

Every message set requires at least one message definition file to describe its messages.

A message describes the structure and content of a set of data that is passed from one application to another.

Typically import of message formats described by:� XML DTD� XML Schema� WSDL� C structure

Page 33: WMQ, WMB and EIP

33

Execution Group

An execution group is a named grouping of message flows that have been assigned to a broker. The broker enforces a degree of isolation between message flows in distinct execution groups by ensuring that they run in separate address spaces, or as unique processes.

Each execution group is started as a separate operating system process, providing an isolated runtime environment for a set of deployed message flows. Within an execution group, the assigned message flows run in different thread pools.

Page 34: WMQ, WMB and EIP

34

Message Flow Deployment

deployment WebSphere Message Broker

«Broker»J PRASE_BRK

«executionEnvironment,Execution Group»default

jPrase.bar

«Message Set»jPraseMessageSet

«Message Flow»jPrase

Page 35: WMQ, WMB and EIP

35

Message Routing

Page 36: WMQ, WMB and EIP

36

Message Routing Example cmp MQ Routing

«Broker»J PRASE_BRK

«MQI nput Node»MQ Input

«MQOutput Node»MQ Output

«J ava MQ Client»Producer

«Queue Manager»QM_J PRASE

«Local Queue»INPUT

«Local Queue»OUTPUT

«Local Queue»UPRASE

«Local Queue»J PRASE

«Route Node»Route

«MQOutput Node»MQ jPrase

«MQOutput Node»MQ uPrase

«xml»message

MQPUT

«tcp»

«send»

Page 37: WMQ, WMB and EIP

37

Java Compute Node

Page 38: WMQ, WMB and EIP

38

Java Compute Node Example cmp Jav a Compute

«Broker»J PRASE_BRK

«MQI nput Node»MQ Input

«MQOutput Node»MQ Output

«J ava MQ Client»Producer

«Queue Manager»QM_J PRASE

«Local Queue»INPUT

«Local Queue»OUTPUT

«xml»message

«J ava MQ Client»Consumer

«J avaCompute Node»J ava Compute

«xml»reverse message

MQPUT

«tcp»

«send»

MQGET

«tcp»

«receive»

Page 39: WMQ, WMB and EIP

39

Web Services Nodes

Service� SOAPInput� SOAPReply

Client� SOAPRequest� SOAPAsyncRequest� SOAPAsyncResponse

Page 40: WMQ, WMB and EIP

40

Web Service Example, flow

Page 41: WMQ, WMB and EIP

41

Web Service Example, components cmp Web Serv ice

«J ava MQ Client»Consumer

«WebService»soapUI

«Broker»J PRASE_BRK

«MQI nput Node»MQ Input

«Compute Node»XmlToSoap

«SOAPRequest Node»SOAP Request

«Compute Node»SoapToXml

«MQOutput Node»MQ Output

«J ava MQ Client»Producer

«Queue Manager»QM_J PRASE

«Local Queue»INPUT

«Local Queue»OUTPUT

«xml»request message

«xml»response message

MQPUT

«tcp»

request

«soap»

response

«soap»

MQGET

«tcp»

«send»

«receive»

Page 42: WMQ, WMB and EIP

42

Sources

Enterprise Integration Patterns: Designing, Building and Deploying Messaging Solutions. Gregor Hope, Bobby Woolf.

WebSphere MQ Helphttp://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp

WebSphere Message Broker Helphttp://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp

Page 43: WMQ, WMB and EIP

43