reactive-listener

this is amqp listener objective class

License

License

Categories

Categories

Spring Boot Container Microservices React User Interface Web Frameworks
GroupId

GroupId

jp.spring-boot-reference
ArtifactId

ArtifactId

reactive-listener
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

reactive-listener
this is amqp listener objective class
Project URL

Project URL

https://projects.spring.io/spring-boot/#/spring-boot-starter-parent/reactive-listener
Source Code Management

Source Code Management

https://github.com/kcwebapply/reactiveListener

Download reactive-listener

How to add to project

<!-- https://jarcasting.com/artifacts/jp.spring-boot-reference/reactive-listener/ -->
<dependency>
    <groupId>jp.spring-boot-reference</groupId>
    <artifactId>reactive-listener</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/jp.spring-boot-reference/reactive-listener/
implementation 'jp.spring-boot-reference:reactive-listener:1.0'
// https://jarcasting.com/artifacts/jp.spring-boot-reference/reactive-listener/
implementation ("jp.spring-boot-reference:reactive-listener:1.0")
'jp.spring-boot-reference:reactive-listener:jar:1.0'
<dependency org="jp.spring-boot-reference" name="reactive-listener" rev="1.0">
  <artifact name="reactive-listener" type="jar" />
</dependency>
@Grapes(
@Grab(group='jp.spring-boot-reference', module='reactive-listener', version='1.0')
)
libraryDependencies += "jp.spring-boot-reference" % "reactive-listener" % "1.0"
[jp.spring-boot-reference/reactive-listener "1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-amqp jar 2.1.1.RELEASE
org.springframework.boot : spring-boot-starter-web jar RELEASE
com.fasterxml.jackson.core : jackson-databind jar 2.9.7

test (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.1.1.RELEASE

Project Modules

There are no modules declared in this project.

reactiveListener

apache licensed Java Maven Central

reactiveListener is Objective Queue Subscriber.

Usage

initialize and subscribe

you can use ReactiveListener like below.

// initialize object with hostname.
ReactiveListener reactiveListener = new ReactiveListener("localhost");

// set queuename you want to subscribe
reactiveListener.setQueue("messageQueue");

// setCallBackClass which implements `ListenerInterface` interface
reactiveListener.setCallBackMethod(test);

// subscribe start
reactiveListener.listen();

set callback action

you should create class which implements ListenerInterface to set callback method.

public class Test implements ListenerInterface {

    private String name;

    Test(String name){
        this.name = name;
    }

    // callback method that is called when subsribing a message.
    @Override
    public void callBack(Message message) {
        System.out.println("receiveMessage::"+message.toString());
    }

    // callback method that is called when error happend by subscribing.
    @Override
    public void errorCallBack(Throwable throwable) {
        System.out.println("error::"+throwable.getMessage());
    }
}

stop

you can stop subscribing by calling stop() method.

reactiveListener.stop();

messageConverter

setting messageConverter like below.

// set messageConverter
reactiveListener.setMessageConverter(messageConverter);


// default messageConverter is this .
private Jackson2JsonMessageConverter defaultMessageConverter(){
        ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
                .modules(new JavaTimeModule())
                .dateFormat(new StdDateFormat())
                .build();
        Jackson2JsonMessageConverter jackson2JsonMessageConverter
                = new Jackson2JsonMessageConverter(objectMapper);
        return jackson2JsonMessageConverter;
}

Versions

Version
1.0