spring-amqp-utils

Provides some utility-methods to simplify the use of Spring Amqp

License

License

Categories

Categories

IDE Development Tools
GroupId

GroupId

com.avides.spring
ArtifactId

ArtifactId

spring-amqp-utils
Last Version

Last Version

1.0.1.RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

spring-amqp-utils
Provides some utility-methods to simplify the use of Spring Amqp
Project URL

Project URL

https://github.com/avides/spring-amqp-utils
Project Organization

Project Organization

AVIDES Media AG
Source Code Management

Source Code Management

https://github.com/avides/spring-amqp-utils

Download spring-amqp-utils

How to add to project

<!-- https://jarcasting.com/artifacts/com.avides.spring/spring-amqp-utils/ -->
<dependency>
    <groupId>com.avides.spring</groupId>
    <artifactId>spring-amqp-utils</artifactId>
    <version>1.0.1.RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.avides.spring/spring-amqp-utils/
implementation 'com.avides.spring:spring-amqp-utils:1.0.1.RELEASE'
// https://jarcasting.com/artifacts/com.avides.spring/spring-amqp-utils/
implementation ("com.avides.spring:spring-amqp-utils:1.0.1.RELEASE")
'com.avides.spring:spring-amqp-utils:jar:1.0.1.RELEASE'
<dependency org="com.avides.spring" name="spring-amqp-utils" rev="1.0.1.RELEASE">
  <artifact name="spring-amqp-utils" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.avides.spring', module='spring-amqp-utils', version='1.0.1.RELEASE')
)
libraryDependencies += "com.avides.spring" % "spring-amqp-utils" % "1.0.1.RELEASE"
[com.avides.spring/spring-amqp-utils "1.0.1.RELEASE"]

Dependencies

provided (1)

Group / Artifact Type Version
org.springframework.amqp : spring-amqp jar 2.0.0.RELEASE

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.8.0

Project Modules

There are no modules declared in this project.

spring-amqp-utils

Maven Central Codacy Badge Coverage Status Build Status

Maven

<dependency>
    <groupId>com.avides.spring</groupId>
    <artifactId>spring-amqp-utils</artifactId>
    <version>1.0.1.RELEASE</version>
</dependency>

Available methods

AmpqUtils.buildDurableQueueWithDlx(String queueName, AmqpAdmin adminThatShouldDeclare)
AmpqUtils.buildDurableQueueWithDlx(String queueName, AmqpAdmin adminThatShouldDeclare, AmqpAdmin... furtherAdminsThatShouldDeclare)

AmpqUtils.buildDurableQueueWithDlxArguments(String queueName, AmqpAdmin adminThatShouldDeclare)
AmpqUtils.buildDurableQueueWithDlxArguments(String queueName, AmqpAdmin adminThatShouldDeclare, AmqpAdmin... furtherAdminsThatShouldDeclare)

AmpqUtils.buildDurableDlxQueueFor(Queue queue)
AmpqUtils.buildDurableDlxQueueFor(String queueName, AmqpAdmin adminThatShouldDeclare)
AmpqUtils.buildDurableDlxQueueFor(String queueName, AmqpAdmin adminThatShouldDeclare, AmqpAdmin... furtherAdminsThatShouldDeclare)

AmpqUtils.buildNonDurableQueueWithDlx(String queueName, AmqpAdmin adminThatShouldDeclare)
AmpqUtils.buildNonDurableQueueWithDlx(String queueName, AmqpAdmin adminThatShouldDeclare, AmqpAdmin... furtherAdminsThatShouldDeclare)

AmpqUtils.buildNonDurableQueueWithDlxArguments(String queueName, AmqpAdmin adminThatShouldDeclare)
AmpqUtils.buildNonDurableQueueWithDlxArguments(String queueName, AmqpAdmin adminThatShouldDeclare, AmqpAdmin... furtherAdminsThatShouldDeclare)

AmpqUtils.buildNonDurableDlxQueueFor(Queue queue)
AmpqUtils.buildNonDurableDlxQueueFor(String queueName, AmqpAdmin adminThatShouldDeclare)
AmpqUtils.buildNonDurableDlxQueueFor(String queueName, AmqpAdmin adminThatShouldDeclare, AmqpAdmin... furtherAdminsThatShouldDeclare)

AmqpUtils.buildDlxQueueFor(Queue queue)

Examples

Possibility 1
@Configuration
@EnableRabbit
public class RabbitConfiguration
{
    @Bean
    public Exchange exchange()
    {
        return new TopicExchange("exchange.name");
    }

    @Bean
    public Queue queue(AmqpAdmin amqpAdmin)
    {
        return AmqpUtils.buildDurableQueueWithDlx("queue.name", amqpAdmin);
    }
    
    @Bean
    public Binding binding(AmqpAdmin amqpAdmin)
    {
        return bind(queue(amqpAdmin)).to(exchange()).with("routing.key").noargs();
    }
}
Possibility 2

If you want to have access to the DLX-Queue-Bean

@Configuration
@EnableRabbit
public class RabbitConfiguration
{
    @Bean
    public Exchange exchange()
    {
        return new TopicExchange("exchange.name");
    }

    @Bean
    public Queue queue(AmqpAdmin amqpAdmin)
    {
        return AmqpUtils.buildDurableQueueWithDlxArguments("queue.name", amqpAdmin);
    }
    
    @Bean
    public Queue dlxQueue(AmqpAdmin amqpAdmin)
    {
        return AmqpUtils.buildDlxQueueFor(queue(amqpAdmin));
    }
    
    @Bean
    public Binding binding(AmqpAdmin amqpAdmin)
    {
        return bind(queue(amqpAdmin)).to(exchange()).with("routing.key").noargs();
    }
}
Possibility 3

The same as possibility 2, but referncing the Queue and the DLX-Queue via the queue-name

@Configuration
@EnableRabbit
public class RabbitConfiguration
{
    @Bean
    public Exchange exchange()
    {
        return new TopicExchange("exchange.name");
    }

    @Bean
    public Queue queue(AmqpAdmin amqpAdmin)
    {
        return AmqpUtils.buildDurableQueueWithDlxArguments("queue.name", amqpAdmin);
    }
    
    @Bean
    public Queue dlxQueue(AmqpAdmin amqpAdmin)
    {
        return AmqpUtils.buildDurableDlxQueueFor("queue.name", amqpAdmin);
    }
    
    @Bean
    public Binding binding(AmqpAdmin amqpAdmin)
    {
        return bind(queue(amqpAdmin)).to(exchange()).with("routing.key").noargs();
    }
}

In all given examples, it is also possible to give more than one RabbitAdmin/AmqpAdmin that should declare the queues. Also all examples can be made with non-durable-queues (use the AmqpUtils.buildNonDurable...-methods)

com.avides.spring

AVIDES Media AG

E-Commerce Solutions

Versions

Version
1.0.1.RELEASE
1.0.0.RELEASE