- Understand Message Oriented Middleware (MOM) concept
- Learn about JMS topic and queue concept
- Learn about basic message types
- Get familiar with JMS java code
-
- method of communication via messaging agent
- sender and the receiver do not have to be available at the same time
- sender does not need to know anything about the receiver / receiver does not need to know anything about the sender
- sender and receiver need to know message format and message destination
- Question: point main difference between Remote Method Invocation and Messaging.
-
- pub-sub: one producer can send a message to many consumers through a virtual channel called topic
- point-to-point: point to point model allows JMS clients to send and receive messages via virtual channels known as queues. Given queue may have multiple receivers, but only one receiver may consume each message.
-
- allows to create, send, receive, and read messages
- it's for programs written in the Java
- JMS is vendor independent
- in JMS communication is asynchronous and reliable
-
- data synchronization
- real time
- notifying (we need to propagate information about new employee to all company systems)
- async processing (we want to process multiple "commands" on remote services in asynchronous fashion)
- as an integration layer (check spring integration)
- Question: how to implement codility like application (remember about heavy load during "RUN" operation)
-
Example of JMS messaging agents
-
Alternatives
-
Check JMS JavaDoc:
-
implement pl.edu.amu.dji.jms.exercise1.SayMain
- follow with comments in code
- ask questions
- this class should produce messages for "SayHelloQueue" queue
-
implement pl.edu.amu.dji.jms.exercise1.HelloMain
- follow with comments in code
- ask questions
- this class should consume messages for "SayHelloQueue" queue
-
Run
- pl.edu.amu.dji.jms.lab1.Broker (start one instance)
- pl.edu.amu.dji.jms.lab1.SayMain (start one instance)
- interact with SayMain console
- pl.edu.amu.dji.jms.lab1.HelloMain (start one instance)
- explain HelloMain behaviour
-
Run
- pl.edu.amu.dji.jms.lab1.Broker (start one instance)
- pl.edu.amu.dji.jms.lab1.HelloMain (start 3 instances)
- pl.edu.amu.dji.jms.lab1.SayMain (start one instance)
- interact with SayMain console
- explain HelloMain behaviour
-
Change queue to topic in HelloMain and SayMain
-
Run
- pl.edu.amu.dji.jms.lab1.Broker (start one instance)
- pl.edu.amu.dji.jms.lab1.SayMain (start one instance)
- interact with SayMain console
- pl.edu.amu.dji.jms.lab1.HelloMain (start 3 instances)
- explain HelloMain behaviour
-
Run
- pl.edu.amu.dji.jms.lab1.Broker (start one instance)
- pl.edu.amu.dji.jms.lab1.HelloMain (start 3 instances)
- pl.edu.amu.dji.jms.lab1.SayMain (start one instance)
- interact with SayMain console
- explain HelloMain behaviour
Exercise 3: JMS headers####
- JMSDestination
- JMSDeliveryMode
- JMSExpiration
- JMSPriority
- JMSMessageID
- JMSTimestamp
- JMSCorrelationID
- JMSReplyTo
- JMSType
- JMSRedelivered
- JMS provider
-
Change topic to queue in HelloMain and SayMain
-
In SayMain set time to live (in milliseconds) on producer (setTimeToLive method) to 3s (1000 millis * 3 sec)
-
Run
- pl.edu.amu.dji.jms.lab1.Broker (start one instance)
- pl.edu.amu.dji.jms.lab1.SayMain (start one instance)
- interact with SayMain console
- wait 4 seconds
- pl.edu.amu.dji.jms.lab1.HelloMain (start 3 instances)
- explain HelloMain behaviour
- interact with SayMain console
- explain HelloMain behaviour
JMS properties all setProperty and getProperty methods
-
In SayMain set boolean property on hello message which checks if input text contains dots
-
In HelloMain print this property and write message selector based to filter only messages with this new property
- check parameters for session.createConsumer(...)
- selectors are based on SQL-92 conditional expressions (in example "dots = true" for boolean parameter with name "dots")
##Feedback##