Giter Site home page Giter Site logo

spring-jms-examples's Introduction

Spring JMS Examples

This project provides some examples of using Spring JMS for both asynchronous and synchronous message consumption.

Asynchronous Consumption

All of the examples for asynchronous message consumption utilize the Spring DefaultMessageListenerContainer for message consumption.

Spring JMS supports three types of message listeners including:

These three types of message listeners are all demonstrated using examples in the async directory.

Running the Examples

These examples are intended to be run from the command-line using Maven. The consumer should be run in one terminal and the producer should be run in a separate terminal. Below are examples of running each of the three asynchronous examples.

Run the Producer for the MessageListener Example

$ cd ./async/message-listener-adapter
$ mvn -Pproducer exec:java

Run the Consumer for the MessageListener Example

$ cd ./async/message-listener-adapter
$ mvn -Pconsumer exec:java

Run the Producer for the SessionAwareMessageListener Example

$ cd ./async/message-listener-adapter
$ mvn -Pproducer exec:java

Run the Consumer for the SessionAwareMessageListener Example

$ cd ./async/message-listener-adapter
$ mvn -Pconsumer exec:java

Run the Producer for the MessageListenerAdapter Example

This example requires a couple of arguments, the first one for the destination name and the second one for the message type. The destination name should be either FOO.TEST or FOO.TEST2. The message type should text, bytes, map or object. Below is an example of text:

$ cd ./async/message-listener-adapter
$ mvn -Pproducer exec:java -Dexec.args="FOO.TEST2 text"

These arguments allow you to invoke one of two MessageListenerAdapter examples and to send four different types of messages.

Run the Consumer for the MessageListenerAdapter Example

$ cd ./async/message-listener-adapter
$ mvn -Pconsumer exec:java

Synchronous Consumption

The example for synchronous message consumption uses the Spring JmsTemplate.

Running the Examples

This example is also intended to be run from the command-line using Maven. The consumer should be run in one terminal and the producer should be run in a separate terminal. Below is an example of running the synchronous example.

Run the Consumer for the JmsTemplate Example

$ cd ./sync/jms-template
$ mvn -Pconsumer exec:java 

Run the Producer for the JmsTemplate Example

This example supports two different types of sends including a simple convertAndSend and also a jmsSend. These two types are specified using an argument when starting up the producer as shown below:

$ cd ./sync/jms-template
$ mvn -Pproducer exec:java -DsendType=convertAndSend

Summary

If you have any questions about these examples, please create an issue for the project. This will allow everyone to see all questions and answers and it will notify me when folks enter new issues.

I also blog about JMS occasionally. Here are some popular posts I have written about Spring JMS:

spring-jms-examples's People

Contributors

bsnyder avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.