ntc-jrabbit

ntc-jrabbit is module rabbitmq java client

License

License

GroupId

GroupId

com.streetcodevn
ArtifactId

ArtifactId

ntc-jrabbit
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

ntc-jrabbit
ntc-jrabbit is module rabbitmq java client
Project URL

Project URL

https://github.com/congnghia0609/ntc-jrabbit
Source Code Management

Source Code Management

https://github.com/congnghia0609/ntc-jrabbit/tree/master

Download ntc-jrabbit

How to add to project

<!-- https://jarcasting.com/artifacts/com.streetcodevn/ntc-jrabbit/ -->
<dependency>
    <groupId>com.streetcodevn</groupId>
    <artifactId>ntc-jrabbit</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.streetcodevn/ntc-jrabbit/
implementation 'com.streetcodevn:ntc-jrabbit:1.0.0'
// https://jarcasting.com/artifacts/com.streetcodevn/ntc-jrabbit/
implementation ("com.streetcodevn:ntc-jrabbit:1.0.0")
'com.streetcodevn:ntc-jrabbit:jar:1.0.0'
<dependency org="com.streetcodevn" name="ntc-jrabbit" rev="1.0.0">
  <artifact name="ntc-jrabbit" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.streetcodevn', module='ntc-jrabbit', version='1.0.0')
)
libraryDependencies += "com.streetcodevn" % "ntc-jrabbit" % "1.0.0"
[com.streetcodevn/ntc-jrabbit "1.0.0"]

Dependencies

compile (12)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.3
ch.qos.logback : logback-core jar 1.2.3
org.slf4j : slf4j-api jar 1.7.25
commons-configuration : commons-configuration jar 1.10
org.apache.commons : commons-lang3 jar 3.4
org.apache.commons : commons-io jar 1.3.2
commons-io : commons-io jar 2.5
com.streetcodevn : ntc-configuration jar 1.0.0
com.rabbitmq : amqp-client jar 5.4.3
com.fasterxml.jackson.core : jackson-core jar 2.10.1
com.fasterxml.jackson.core : jackson-databind jar 2.10.1
com.fasterxml.jackson.core : jackson-annotations jar 2.10.1

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

ntc-jrabbit

ntc-jrabbit is a module rabbitmq java client.

Maven

<dependency>
    <groupId>com.streetcodevn</groupId>
    <artifactId>ntc-jrabbit</artifactId>
    <version>1.0.0</version>
</dependency>

Usage

Producer

String routingKey = "test_queue";
String msg = "this is message";
byte[] msgb = JsonUtils.Instance.toByteJson(msg);
ProducerUtil.sendMsg(routingKey, msgb);

Consumer

public static void main(String[] args) {
    ConsumerRBQueue cq = new ConsumerRBQueue();
    cq.add(new SampleWorker());
    cq.add(new SampleWorker());
    cq.start();
}


public static class SampleWorker extends ConsumerRBProcess {
    private Logger logger = LoggerFactory.getLogger(SampleWorker.class);

    private final static String routingKey = "test_queue";
    private final static String amqpUrl = "amqp://username:password@localhost:5672/";

    public ThumbnailWorker() {
        super(routingKey, amqpUrl);
    }

    @Override
    public String getRoutingKey() {
        return routingKey;
    }

    public static String getAmqpUrl() {
        return amqpUrl;
    }

    @Override
    public void execute(byte[] data) {
        try {
            String message = new String(data, "UTF-8");
            System.out.println(" [xxx] Received '" + routingKey + "':'" + message + "'");
        } catch (Exception e) {
        }
    }
}

License

This code is under the Apache License v2.

Versions

Version
1.0.0