!--a11y-->
Developing
JMS Applications 
The Java Message Service (JMS) is an enterprise messaging system that provides a way for business applications to exchange data, without need to be directly connected to each other. The communication is obtained using messages.
Note that JMS is not a product itself, but a set of predefined interfaces provided in the javax.jms package. The applications uses this API to send and receive messages to and from a destination located on a JMS messaging server, that is the JMS provider itself. Java programs that send or receive messages using JMS are called JMS clients. JMS messages can contain any kind of data, including plain text, HTML, XML, and images.

Main JMS Objects
There are few objects that make the JMS connection. Some of these objects are referred to as administrated objects, that is these objects were already created and configured by an administrator of the JMS provider. Also that means that you can simply use such objects in the application, instead of creating and configuring these objects. The main elements of the JMS connection are:
· Connection factory – an administrated object that you use to create a connection. You can reference a connection factory using JNDI.
· Connection – the active connection to the JMS provider.
· Session – a single-threaded context for sending and receiving messages. Using the session you can create:
Ў Message producer – an object created by the session used to send messages to a destination.
Ў Message consumer – an object created by the session used to receive messages sent to a destination.
Ў Message – the messages are requests, responses or events that are asynchronous, and which are used by the enterprise applications. They contain the information required to coordinate the application communications.
· Destinations – the destination is an administered object that encapsulates the identity of a message destination. The destination messaging model could be:
Ў Point-to-point (queue destination) – use it to send messages, that only one specified consumer can receive, that is “one-to-one” message delivery.
Ў Publish-subscribe (topic destination) – use it to send messages to a group of consumers, that is “one-to-many” message delivery. The model also allows you to create the so-called durable subscribers, which enable you to get a message sent to this destination, while the consumer was not active.
However, a JMS client instantiates one or more producer or consumer objects through which the client sends or receives messages, respectively. The JMS producer implements the standard MessageProducer interface, while the JMS consumer implements the standard MessageConsumer interface.
While destinations are represented as objects, they are handled slightly differently. Since destinations (these are the message queues or topics) can be used repeatedly across applications, destination objects are usually set up as administered objects and then retrieved by the JMS client at runtime using JNDI instead of being directly instantiated. The JMS provider also gives you a way to dynamically instantiate temporary destinations.
The JMS enables applications that use one messaging system to exchange messages easily. With the JMS API, you have a standard for writing applications that have to send, receive or exchange asynchronous messages.
J2EE Engine JMS provider is compliant with the JMS specifications versions 1.0.2.
The JMS provider enables you to:
· Create different types of messages – the JMS supports few messages types. You can use them to send a certain type of information. See JMS Messages.
· Send messages – you can send messages to an exact client of the messages, or you can send messages to a group of clients that are subscribed to a messaging instance.
· Receive messages – JMS enables easy messages receiving.
· Secure the JMS connection – the JMS provider enables you to apply security restrictions over the JMS connections you use. See Security on JMS Service.
· Use transactions – you can use the transacted connection factories, which are the XAConnectionFactories on the J2EE Engine.
· Use message-driven beans – the message-driven beans are fully supported by the JMS provider implementation. See Developing Message-Driven Beans.
· Create Clustered Subscriber – this is required for the message-driven bean container of the J2EE Engine. A special API attaches a groupID to all types of standard JMS subscriptions. This group ID results in special semantics in the message delivery levels of the J2EE agents – instead of publishing a message to all subscribers, JMS only chooses one subscriber of each different group and send the message to it.
· Use JMS message selector. See Creating Message Selector.
· Use the additional API to create and delete destinations programmatically.
· Use the API for obtaining monitoring or statistics data from the JMS server.
See also:
· Creating a JMS Connection – for information on how to develop applications using JMS.
·
JMS Administration in the
Administration Manual.