Loose Coupling and Message-based Integration WS 2012 ... - IAAS

iaas.uni.stuttgart.de

Loose Coupling and Message-based Integration WS 2012 ... - IAAS

Prof. Dr. Frank Leymann / Olha Danylevych

Institute of Architecture of Application Systems

University of Stuttgart

Loose Coupling and Message-based Integration

WS 2012

Exercise 2

Date: 24.08.12 (13:00 – 14:30, Room 38.03 or 38.02)

Task 2.1 – Guaranteed Delivery

a) What does the term “guaranteed delivery” mean?

b) What are the pros and cons of guaranteed delivery? Provide examples when

guaranteed delivery would be necessary and when it would instead be "overkill"

(i.e. a waste of resources/performance/etc.).

c) How can guaranteed delivery be realized in JMS?

Task 2.2 – JMS Header Information

JMS messages have headers that can convey varied information. Many types of

headers are specified in the JMS specifications, and custom ones may be added

by particular vendor implementations. Describe (a) which values should be

assigned to which header fields and (b) who may assign these header fields in

order to:

● Deliver a message with high priority

● Specify the destination of a reply message

● Specify the timestamp of its creation

Message is valid only within a certain time interval

Task 2.3 – JMS Properties

JMS does not provide any means to guarantee the security aspects of the

message exchanges in terms of (1) sender authentication and (2) encryption of

the message contents.

How can JMS properties be used to enrich the messages with the data relevant

to security? Assume the usage of login and passwords as well as encryption via

public/private key.

Define an appropriate protocol that satisfies the following requirements:

1. user authentication

2. establishing of a secure channel between the communicating parties

Task 2.4 – JMS Message Types

Assume a message structured as:

({companyName, stock price}+)

which contains the current stock prices of several companies (identified by

name) at a particular point in time. These data can be packed into different JMS

message types, e.g. TextMessage, MapMessage. Provide examples of different

formatting of the data for each of the various JMS message types.


Task 2.5 – JMS Message Selectors

A message selector allows the JMS consumer to filter undesired, incoming JMS

messages before they are processed. A selector is defined as a boolean

expression combining header fields and properties in a way reminiscent of the

WHERE statement of an SQL query.

Assume the following scenarios:

1. An insurance application uses a message queue to collect complains from

its clients. The application needs to select from the queue all the messages

that are come from chemists and physicists that work for the University of

Stuttgart.

2. A producer wants to receive a message as soon as it is posted to his

queue an order of at least 100 pieces of the article with the inventory

number “SFW374556-02”.

Define for each of the above scenarios a selector and describe which header

fields and properties have to be included in the message.

Task 2.6 – JMS Topics

Define a hierarchy of JMS topics that describes the German stock market. The

topic German stock market should include the indexes (DAX, MDAX, TECDAX,…)

as well as different industrial sectors as (sub-)topics. The companies enlisted in

the stock market can be represented in different sectors, e.g. a company can

publish its messages over the Topic DAX, as well as over a topic “Diversified

industrials”.

In the scope of the JMS Topic hierarchy resulting from above, consider the

following cases:

● BMW wants to publish messages about its stocks. To which (sub-)topics

should those messages be published?

● A customer wants to receive the messages from every company listed in

the DAX index, as well as from Puma (which is listed in MDAX). Which

topics has the customer to subscribe to?

Task 2.7 Chat Application 1

For this task you may use NetBeans IDE 7.0.1 Java EE Bundle (comes already

with GlassFish Server Open Source Edition 3.1.1:

http://netbeans.org/downloads/index.html) or any other tooling of your choice.

Your task is to develop a chat application that run from command-line using JMS

pub/sub API1. In a nutshell, the chat application receives the name of the user

as launch parameter (i.e. as args[] in the method main). After its launch, the

chat application reads the messages given input by the user from command line

(System.in). Each message is terminated by a carriage return (i.e. the message

is not processed by the chat application unless the user presses the “return”

button). The messages are published on a predefined JMS topic. Incoming

messages are pulled by the very same JMS topic, which the chat application

must subscribe. All incoming and outgoing messages should be also displayed on

the console in the form: [name of the originating user]: [message text]

The following hints should help you while developing your chat application:

1 This task is based on the Chapter 2 from the book “Java Message Service” by Richard Monson and

David A. Chappell


Create the Connection Factory and Topic required for the chat application

in your GlassFish using the management console.

Create a NamingProperties.java (extends Hashtable) with the

configurations of Connection Factory name, Topic name etc.

Your application will need to obtain a JNDI connection to the JMS

messaging server and look up all required JMS administered objects;

create the corresponding JMS session objects as well as JMS publisher and

subscriber (here you have to set a JMS message listener), start the JMS

connection to the predefined topic. These steps could be done e.g. in the

constructor of the class Chat.

That Chat class should implement the interface the

javax.jms.MessageListener and implement the corresponding onMessage

method to react on the messages received from the topic.

For reading the messages typed by the user on the command line, you

may use the method readLine shown here:

http://myy.helia.fi/~karte/readline_in_java.html

Create a method writeMessage(String text) to form a JMS message and

publish it on the topic whenever user has typed a message on the console.

Additional Task: modify your chat application to filter out the messages

from specific users.

More magazines by this user
Similar magazines