Spring Boot RabbitMQ RPC

A library for automatic generation of RabbitMQ RPC clients

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

org.bakeneko
ArtifactId

ArtifactId

spring-boot-starter-rabbitmq-rpc
Last Version

Last Version

0.0.3-beta
Release Date

Release Date

Type

Type

jar
Description

Description

Spring Boot RabbitMQ RPC
A library for automatic generation of RabbitMQ RPC clients
Project URL

Project URL

https://projects.spring.io/spring-boot/#/spring-boot-starter-parent/spring-boot-starter-rabbitmq-rpc
Source Code Management

Source Code Management

https://github.com/i-sergienko/spring-rabbitmq-rpc/tree/master

Download spring-boot-starter-rabbitmq-rpc

How to add to project

<!-- https://jarcasting.com/artifacts/org.bakeneko/spring-boot-starter-rabbitmq-rpc/ -->
<dependency>
    <groupId>org.bakeneko</groupId>
    <artifactId>spring-boot-starter-rabbitmq-rpc</artifactId>
    <version>0.0.3-beta</version>
</dependency>
// https://jarcasting.com/artifacts/org.bakeneko/spring-boot-starter-rabbitmq-rpc/
implementation 'org.bakeneko:spring-boot-starter-rabbitmq-rpc:0.0.3-beta'
// https://jarcasting.com/artifacts/org.bakeneko/spring-boot-starter-rabbitmq-rpc/
implementation ("org.bakeneko:spring-boot-starter-rabbitmq-rpc:0.0.3-beta")
'org.bakeneko:spring-boot-starter-rabbitmq-rpc:jar:0.0.3-beta'
<dependency org="org.bakeneko" name="spring-boot-starter-rabbitmq-rpc" rev="0.0.3-beta">
  <artifact name="spring-boot-starter-rabbitmq-rpc" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.bakeneko', module='spring-boot-starter-rabbitmq-rpc', version='0.0.3-beta')
)
libraryDependencies += "org.bakeneko" % "spring-boot-starter-rabbitmq-rpc" % "0.0.3-beta"
[org.bakeneko/spring-boot-starter-rabbitmq-rpc "0.0.3-beta"]

Dependencies

compile (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-amqp jar 2.1.8.RELEASE

test (4)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.1.8.RELEASE
org.springframework.amqp : spring-rabbit-test jar 2.1.8.RELEASE
com.fasterxml.jackson.core : jackson-core jar 2.10.0
com.fasterxml.jackson.core : jackson-databind jar 2.10.0

Project Modules

There are no modules declared in this project.

About

A Spring Boot Starter module for automatic RabbitMQ client generation from interfaces.

Usage

Import the project as a dependency:

<dependency>
    <groupId>org.bakeneko</groupId>
    <artifactId>spring-boot-starter-rabbitmq-rpc</artifactId>
    <version>0.0.2-SNAPSHOT</version>
</dependency>

Enable RPC client generation by annotating one of your Spring configuration classes with @EnableRabbitRPC, for example:

@SpringBootApplication
@EnableRabbitRPC
public class MyAwesomeApp { ... }

Specify a org.springframework.amqp.support.converter.SmartMessageConverter bean - fof JSON conversion org.springframework.amqp.support.converter.Jackson2JsonMessageConverter is a common choice:

@Configuration
public class MyConfig {
    @Bean
    public MessageConverter converter() {
        return new Jackson2JsonMessageConverter();
    }
}

Create one or more interfaces annotated with @RabbitClient:

@RabbitClient(
    exchange="default exchange (if any)",
    routingKey="default routing key (if any)",
    messagePostProcessor="default message post processor bean name, if any"
)
public interface SomeClient {

    @RabbitSender(
        exchange="exchange overriding the default one (if necessary)"
        routingKey="routing key overriding the default ont (if necessary)"
        messagePostProcessor="message post processor bean name, to override the default one (if necessary)"
    )
    SomeResponseType someRequest(SomeRequestType request);
}

Methods in @RabbitClient interfaces can optionally be marked with the @RabbitSender annotation, to override the default metadata specified in @RabbitClient.

Methods must have exactly 1 argument, or alternatively mark all parameters as @Payload, @Header or @Headers.
If there is only one argument, it is considered to be @Payload by default, no need to mark it explicitly.
There can only be one (mandatory) @Payload argument and one (optional) @Headers argument. The number of @Header arguments is not restricted, you can have as many as you like.

After the initial setup the implementations can be @Autowired by type into other beans:

@Service
public class SomeService {
    @Autowired
    private SomeClient autoGeneratedClient;
    
    ...
}

Versions

Version
0.0.3-beta
0.0.2