GithubHelp home page GithubHelp logo

spring-amqp-rabbit's Introduction

RabbitMq Producer and Consumer using Spring Amqp Framework

Producer to a RabbitMq Broker (Federated) SSL External configurated, 3 messages and wait for a minute.

Consume with listeners the 3 messages produced in order to verify connection with the broker/s

Docker

Previously it's necessary to have a RabbitMq broker composed of two containers from an image created with the Dockerfile included in /docker directory

In the first place, from docker directory:

docker build -t rabbitmq:3.5.7-management-ssl

After, run the docker containers

docker run -d --hostname rabbit1 --name my-rabbit1 rabbitmq:3.5.7-management-ssl
docker run -d --hostname rabbit2 --name my-rabbit2 rabbitmq:3.5.7-management-ssl

Update the federation upstream uri in each broker, log in the web administration console (user guest, pass guest) at

https://rabbit1:15672/#/federation-upstreams

https://rabbit2:15672/#/federation-upstreams

and replacing rabbit-host by rabbit2 in rabbit1 broker and rabbit-host by rabbit1.

Check the federation status in

https://rabbit1:15672/#/federation

https://rabbit2:15672/#/federation

is running

Installing jar with dependencies

From pom.xml directory

mvn clean install

Under ./target directory there is the SpringAmqpRabbit-1.0-SNAPSHOT.jar with all dependencies included in it.

Configuration

A configuration by example must be created inside the machine where jar will be executed. Create by convention a directory called /var/properties/spring-amqp-rabbit/ and locate in:

  • keycert.p12 client certificate .p12 file.
  • keycert.jks trusted certificates store in jks.
  • ssl.properties copied from /src/main/resources

Keycert files can be get from one of the two docker containers running under the /etc/rabbitmq/ssl/client directory

# client certificate store
keyStore=file:/var/properties/spring-amqp-rabbit/keycert.p12

# java trust store with all the trusted server certificates
trustStore=file:/var/properties/spring-amqp-rabbit/keycert.jks

# client certificate password
keyStore.passPhrase=rabbitmqpass

# java trust store with all the trusted server certificates password
trustStore.passPhrase=rabbitmqpass

# connection addresses hostname:port separated with commas
connection.addresses=172.17.0.2:5673,172.17.0.3:5673

To test with more than one RabbitMQ Federated broker in connection.addresses include all hostname:port brokers separated with commas

Execution

java -jar SpringAmqpRabbit-1.0-SNAPSHOT.jar 

Output

MESSAGE CONSUMED: Message 1 queued with key
MESSAGE CONSUMED: Message 2 queued with key
MESSAGE CONSUMED: Message 3 queued with key

After 60 secs program exits(0)

spring-amqp-rabbit's People

Contributors

next-franciscoescribano avatar

Stargazers

avoidcat avatar  avatar Nestor Gracia avatar Miguel Fernández avatar

Watchers

 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.