Skip to content

Latest commit

 

History

History

rabbitmq-client

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Use CloudAMQP from Java

A minimal example of publishing and consuming messages with the RabbitMQ Java client, against CloudAMQP or any AMQP 0-9-1 broker such as LavinMQ or RabbitMQ.

  • Publisher.java publishes a persistent message with publisher confirms.
  • Worker.java consumes with manual acknowledgements and a prefetch of 10.
  • Amqp.java connects using the BROKER_URL environment variable.

Usage

Tool versions are in mise.toml; install them with mise, or use Java 21+ and Maven 3.

export BROKER_URL="amqps://user:password@host/vhost"
mvn compile exec:java -Dexec.mainClass=Worker      # in one terminal
mvn compile exec:java -Dexec.mainClass=Publisher   # in another

Without BROKER_URL it connects to amqp://guest:guest@localhost.

Tests

mvn test publishes and consumes a message through a real broker on localhost. CI runs it against LavinMQ.