Giter VIP home page Giter VIP logo

service-harness-amqp-rabbitmq's Introduction

Melior Service Harness :: AMQP : RabbitMQ

Artefact

Get the artefact and the POM file in the artefact folder.

<dependency>
    <groupId>org.melior</groupId>
    <artifactId>melior-harness-amqp-rabbitmq</artifactId>
    <version>2.3</version>
</dependency>

Client

Create a bean to instantiate the RabbitMQ client. The RabbitMQ client uses connection pooling to improve performance.

@Bean("myclient")
@ConfigurationProperties("myclient")
public RabbitMQClient client() {
    return RabbitMQClientBuilder.create().build();
}

The RabbitMQ client is auto-configured from the application properties.

myclient.url=amqp://some.service:5672/environment
myclient.username=user
myclient.password=password
myclient.exchange=myExchange
myclient.queue=myQueue
myclient.request-timeout=30
myclient.inactivity-timeout=300

Map the attributes in the JSON message to the fields in the JAVA class.

public class Message {
    @JsonProperty("category")
    private String category;

    @JsonProperty("type")
    private String type;

    @JsonProperty("description")
    private String description;

    @JsonProperty("volume")
    private double volume;

    @JsonProperty("balance")
    private double balance;

    ...
}

Wire in and use the RabbitMQ client. There is no need to convert the JAVA object to JSON before using the RabbitMQ client to send the message. The RabbitMQ client performs the object mapping automatically.

@Autowired
private RabbitMQClient client;

public void foo(Message message) throws RemotingException {
    client.send(message)
}

The RabbitMQ client may be configured using these application properties.

Name Default Description
url The URL of the RabbitMQ server
username The user name required by the RabbitMQ server
password The password required by the RabbitMQ server
minimum-connections 0 The minimum number of connections to open to the RabbitMQ server
maximum-connections 1000 The maximum number of connections to open to the RabbitMQ server
connection-timeout 30 s The amount of time to allow for a new connection to open to the RabbitMQ server
validate-on-borrow false Indicates if a connection must be validated when it is borrowed from the JDBC connection pool
validation-timeout 5 s The amount of time to allow for a connection to be validated
request-timeout 60 s The amount of time to allow for a request to the RabbitMQ server to complete
backoff-period 1 s The amount of time to back off when the circuit breaker trips
backoff-multiplier 1 The factor with which to increase the backoff period when the circuit breaker trips repeatedly
backoff-limit The maximum amount of time to back off when the circuit breaker trips repeatedly
inactivity-timeout 300 s The amount of time to allow before surplus connections to the RabbitMQ server are pruned
maximum-lifetime unlimited The maximum lifetime of a connection to the RabbitMQ server
prune-interval 60 s The interval at which surplus connections to the RabbitMQ server are pruned

ย 

References

Refer to the Melior Service Harness :: Core module for detail on the Melior logging system and available utilities.

service-harness-amqp-rabbitmq's People

Contributors

meliorartefacts avatar

Stargazers

 avatar  avatar

Watchers

 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.