What is JMS?● A specification that describes a common way for Java programs to create, send, receive and read distributed enterprise messages;● loosely coupled communication;● Asynchronous messaging;● Reliable delivery; – A message is guaranteed to be delivered once and only once.● Outside the specification – Security services – Management services
Goals● Provide a single, unified message API● Minimize knowledge needed for programmers needed to write clients● Utilize concepts of message exchange applications● Simplify portability of JMS clients
JMS ApplicationA JMS application is composed of the following parts:• JMS Clients - These are the Java language programs that sendand receive messages.• Non-JMS Clients.• Messages - Each application defines a set of messages that areused to communicate information between its clients.• JMS Provider - This is a messaging system that implementsJMS in addition to the other administrative and controlfunctionality required of a full-featured messaging product.• Administered Objects - Administered objects are preconfiguredJMS objects created by an administrator for the use of clients.
Administered objectsTwo types of JMS administered objects:• ConnectionFactory - This is the object a clientuses to create a connection with a provider.• Destination - This is the object a client uses tospecify the destination of messages it is sendingand the source of messages it receives.
DomainsThere are two models of interaction:● In the point-to-point (or PTP) messaging model, each message is delivered from a message producer to a single message consumer.● In the publish/subscribe (or pub/sub) model, a single message can be delivered from a producer to any number of consumers.
Session● A session is a single-threaded context for producing and consuming messages.● Sessions are the JMS entity that supports transactions. – A JMS client may use JTA to delimit distributed transactions; however, this is a function of the transaction environment the client is running in. It is not a feature of JMS.
Messages Composed of:● Header used by both clients and providers to identify and route messages● Properties – Application-specific properties – Standard properties – Provider-specific properties● Body
Message Selection● By headers and properties not delivered differ a bit depending on the MessageConsumer● Based on SQL92 conditional expression syntax "JMSType = ’car’ AND color = ’blue’ AND weight > 2500"
Message Scheduling● No message scheduling in specification!
Apache ActiveMQActiveMQ from version 5.4 has an optional persistent scheduler built into the ActiveMQmessage broker. It is enabled by setting the broker schedulerSupport attribute to true inthe Xml Configuration.An ActiveMQ client can take advantage of a delayed delivery by using the followingmessage properties. Property name type description AMQ_SCHEDULED_DELAY long The time in milliseconds that a message will wait before being scheduled to be delivered by the broker AMQ_SCHEDULED_PERIOD long The time in milliseconds to wait after the start time to wait before scheduling the message again AMQ_SCHEDULED_REPEAT int The number of times to repeat scheduling a message for delivery AMQ_SCHEDULED_CRON String Use a Cron entry to set the schedule