JMS (Java messaging Service) is a standard defined in Java EE to address the producer consumer problem. It standardizes the way of message exchange between two or more system. JMS can be vaguely related to Webservice as they both do the same tasks sending and receiving message. But the main difference lies is Webservice are Synchronous and JMS is asynchronous. Also, we can relate JMS and messaging queues provided different vendor such as WebSphere MQ, ActiveMQ, RabbitMQ etc. AMQP and Microsoft messaging queue does not implement JMS. You can bind JMS inside a EJB same as other locale remote network access using java interfaces, webservices etc. Loos coupling, reliability and asynchronous are main characteristics.
Here are JMS component.
JMS Provider - A system which has implemented JMS specification such as Websphere MQ, RabbitMQ etc.
JMS Client - Application or client which produced/receives message.
JMS producer/publisher - Application or client which produces message.
JMS consumer/subscriber - Application or client which produces message.
JMS Message - A message containing data.
JMS Queue - Queue is provided by providers they maintains the message until the are delivered to destination application.
JMS Topic - Queue is point to point while topic is point to multi point, publish and subscribe model.
You will need a JMS provider server.
You can use Active MQ, Rabbit MQ, Websphere MQ etc, which ever you like and configure few queues in that and get the URL, username password, queue name etc.
Different options to configure JMS
Using Application Server : Since JMS is a specification this is supported by many enterprise level application server for ex IBM Websphere, Weblogic etc. You can configure the JMS URL, queue name, id password etc at Application server level and get it working.
Using Spring Framework : Overall spring tries to reduce the Job for Application server, Spring provides very light option to support Java specification implementation and one of them is JMS. You can choose to use spring framework to configure JMS client and use JMSTemplate to receive or send the message.
Add following dependency to your pom.xml.
For Active MQ
For Websphere MQ
Sending Message to Active MQ.
Sending requires, spring jmsTemplate, Spring CachingConnectionFactory and Provider provided connection factory.
Recieving Message from Active MQ.
Receiving requires @EnableJms, Spring DefaultJmsListenerContainerFactory and Provider provided connection.
Send & Recive message to Websphere MQ.
Since we are using Spring JMS Websphere MQ started jar, the jmsTemplate is already created which you can use anywhere in your code.
Add @EnableJMS to your configuration class and add the following key value pair in property file.