Branch | Tests | Code Quality |
---|---|---|
master |
Helpful links:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
maven { url "https://jitpack.io" }
Framework Core
<dependency>
<groupId>com.github.Szczurowsky</groupId>
<artifactId>RatOverNATS</artifactId>
<version>1.1.0</version>
</dependency>
implementation 'com.github.Szczurowsky:RatOverNats:1.1.0'
More complex examples in docs
With credentials
public class Example {
public Example() {
RatOverNats ratOverNats = new RatOverNatsBuilder()
.options(
new Options.Builder()
.server("nats://localhost:4222")
.userInfo("login", "password")
.build()
)
.build();
}
}
With URI
public class Example {
public Example() {
RatOverNats ratOverNats = new RatOverNatsBuilder()
.uri("nats://localhost:4222")
.build();
}
}
Class with instance
public class Example {
public Example() {
RatOverNats ratOverNats = new RatOverNatsBuilder()
.options(
new Options.Builder()
.server("nats://localhost:4222")
.userInfo("login", "password")
.build()
)
.registerHandler(new TestMessageHandler())
.build();
}
}
Handler
public class TestMessageHandler extends RatMessageHandler<String> {
protected TestMessageHandler() {
super(1, "test");
}
@Override
protected void onReceive(String s, Message message) {
System.out.println(s);
}
}
Class with instance
public class Example {
public Example() {
RatOverNats ratOverNats = new RatOverNatsBuilder()
.options(
new Options.Builder()
.server("nats://localhost:4222")
.userInfo("login", "password")
.build()
)
.registerHandler(new TestMessageHandler())
.build();
ratOverNats.publish("test", new Packet<>("test").setPacketId(1));
}
}