- Rabbitmq java basic consume
- Where to get help
- «Hello World»
- (using the Java Client)
- Sending doesn’t work!
- Receiving
- Putting it all together
- Listing queues
- Hint
- Production [Non-]Suitability Disclaimer
- Getting Help and Providing Feedback
- Help Us Improve the Docs If you’d like to contribute an improvement to the site, its source is available on GitHub. Simply fork the repository and submit a pull request. Thank you! 1 «Hello World!» The simplest thing that does something Queue -> Consuming: Work Queue used to distribute time-consuming tasks among multiple workers.» width=»180″/> 3 Publish/Subscribe Sending messages to many consumers at once Queue -> Consuming: subscribe to a subset of the messages only.» width=»180″ height=»50″/> 5 Topics Receiving messages based on a pattern (topics) Queue -> Consuming: RPC (Remote Procedure Call), the request/reply pattern.» width=»180″ height=»50″/> 7 Publisher Confirms Reliable publishing with publisher confirms Источник
- 1 «Hello World!»
- 3 Publish/Subscribe
- 5 Topics
- 7 Publisher Confirms
Rabbitmq java basic consume
This tutorial assumes RabbitMQ is installed and running on localhost on the standard port ( 5672 ). In case you use a different host, port or credentials, connections settings would require adjusting.
Where to get help
If you’re having trouble going through this tutorial you can contact us through the mailing list or RabbitMQ community Slack.
RabbitMQ is a message broker: it accepts and forwards messages. You can think about it as a post office: when you put the mail that you want posting in a post box, you can be sure that the letter carrier will eventually deliver the mail to your recipient. In this analogy, RabbitMQ is a post box, a post office, and a letter carrier.
The major difference between RabbitMQ and the post office is that it doesn’t deal with paper, instead it accepts, stores, and forwards binary blobs of data ‒ messages.
RabbitMQ, and messaging in general, uses some jargon.
- Producing means nothing more than sending. A program that sends messages is a producer :
Note that the producer, consumer, and broker do not have to reside on the same host; indeed in most applications they don’t. An application can be both a producer and consumer, too.
«Hello World»
(using the Java Client)
In this part of the tutorial we’ll write two programs in Java; a producer that sends a single message, and a consumer that receives messages and prints them out. We’ll gloss over some of the detail in the Java API, concentrating on this very simple thing just to get started. It’s a «Hello World» of messaging.
In the diagram below, «P» is our producer and «C» is our consumer. The box in the middle is a queue — a message buffer that RabbitMQ keeps on behalf of the consumer.