16.01.2014 Views

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

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

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

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Task 2.5 – JMS <strong>Message</strong> Selectors<br />

A message selector allows the JMS consumer to filter undesired, incoming JMS<br />

messages before they are processed. A selector is defined as a boolean<br />

expression combining header fields <strong>and</strong> properties in a way reminiscent of the<br />

WHERE statement of an SQL query.<br />

Assume the following scenarios:<br />

1. An insurance application uses a message queue to collect complains from<br />

its clients. The application needs to select from the queue all the messages<br />

that are come from chemists <strong>and</strong> physicists that work for the University of<br />

Stuttgart.<br />

2. A producer wants to receive a message as soon as it is posted to his<br />

queue an order of at least 100 pieces of the article with the inventory<br />

number “SFW374556-02”.<br />

Define for each of the above scenarios a selector <strong>and</strong> describe which header<br />

fields <strong>and</strong> properties have to be included in the message.<br />

Task 2.6 – JMS Topics<br />

Define a hierarchy of JMS topics that describes the German stock market. The<br />

topic German stock market should include the indexes (DAX, MDAX, TECDAX,…)<br />

as well as different industrial sectors as (sub-)topics. The companies enlisted in<br />

the stock market can be represented in different sectors, e.g. a company can<br />

publish its messages over the Topic DAX, as well as over a topic “Diversified<br />

industrials”.<br />

In the scope of the JMS Topic hierarchy resulting from above, consider the<br />

following cases:<br />

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

should those messages be published?<br />

● A customer wants to receive the messages from every company listed in<br />

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

topics has the customer to subscribe to?<br />

Task 2.7 Chat Application 1<br />

For this task you may use NetBeans IDE 7.0.1 Java EE Bundle (comes already<br />

with GlassFish Server Open Source Edition 3.1.1:<br />

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

Your task is to develop a chat application that run from comm<strong>and</strong>-line using JMS<br />

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

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

chat application reads the messages given input by the user from comm<strong>and</strong> line<br />

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

is not processed by the chat application unless the user presses the “return”<br />

button). The messages are published on a predefined JMS topic. Incoming<br />

messages are pulled by the very same JMS topic, which the chat application<br />

must subscribe. All incoming <strong>and</strong> outgoing messages should be also displayed on<br />

the console in the form: [name of the originating user]: [message text]<br />

The following hints should help you while developing your chat application:<br />

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

David A. Chappell

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!