Skip to content

Commit 38c7555

Browse files
committed
update post release
1 parent ce2b1ed commit 38c7555

File tree

4 files changed

+70
-9
lines changed

4 files changed

+70
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ target
55
*.iml
66
.classpath
77
.project
8+
9+
pom.xml.versionsBackup

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
## JavaNSQClient
22

3-
A (fast?) netty-based Java8 client for [NSQ][nsq]
4-
heavily forked of TrendrrNSQClient
3+
A (fast?) netty-based Java8 client for [NSQ](https://nsq.io)
4+
heavily forked of TrendrrNSQClient.
5+
6+
## Artefact
7+
8+
```
9+
<dependency>
10+
<groupId>com.github.brainlag</groupId>
11+
<artifactId>nsq-client</artifactId>
12+
<version>1.0.0.ALPHA</version>
13+
</dependency>
14+
```
515

616
## TODO:
7-
auth
8-
ssl
9-
....
17+
* auth
18+
* ssl
19+
* ....
1020

1121
## Consumer
1222

pom.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>com.github.brainlag.nsq</groupId>
7+
<groupId>com.github.brainlag</groupId>
88
<artifactId>nsq-client</artifactId>
9-
<version>1.0.0-SNAPSHOT</version>
9+
<version>1.0.0.ALPHA</version>
1010

1111
<name>JavaNSQClient</name>
1212
<description>Fast Java client for NSQ.</description>
@@ -88,6 +88,17 @@
8888
</execution>
8989
</executions>
9090
</plugin>
91+
<plugin>
92+
<groupId>org.sonatype.plugins</groupId>
93+
<artifactId>nexus-staging-maven-plugin</artifactId>
94+
<version>1.6.3</version>
95+
<extensions>true</extensions>
96+
<configuration>
97+
<serverId>ossrh</serverId>
98+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
99+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
100+
</configuration>
101+
</plugin>
91102
</plugins>
92103
</build>
93104
</profile>

src/test/java/com/github/brainlag/nsq/NSQProducerTest.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.github.brainlag.nsq.exceptions.NSQException;
44
import com.github.brainlag.nsq.lookup.NSQLookup;
5+
import com.google.common.base.Throwables;
56
import org.apache.logging.log4j.LogManager;
67
import org.junit.Test;
78

@@ -10,6 +11,7 @@
1011
import java.util.concurrent.atomic.AtomicInteger;
1112

1213
import static org.junit.Assert.assertEquals;
14+
import static org.junit.Assert.assertTrue;
1315

1416
public class NSQProducerTest {
1517

@@ -27,7 +29,7 @@ private NSQConfig getDeflateConfig() {
2729
}
2830

2931
@Test
30-
public void testProduceOneMsg() throws NSQException, TimeoutException, InterruptedException {
32+
public void testProduceOneMsgSnappy() throws NSQException, TimeoutException, InterruptedException {
3133
AtomicInteger counter = new AtomicInteger(0);
3234
NSQLookup lookup = new NSQLookup();
3335
lookup.addAddr("localhost", 4161);
@@ -106,7 +108,43 @@ public void testProduceMoreMsg() throws NSQException, TimeoutException, Interrup
106108
while (counter.get() < 1000) {
107109
Thread.sleep(500);
108110
}
109-
assertEquals(1000, counter.get());
111+
assertTrue(counter.get() >= 5000);
112+
consumer.shutdown();
113+
}
114+
115+
@Test
116+
public void testParallelProducer() throws NSQException, TimeoutException, InterruptedException {
117+
AtomicInteger counter = new AtomicInteger(0);
118+
NSQLookup lookup = new NSQLookup();
119+
lookup.addAddr("localhost", 4161);
120+
121+
NSQConsumer consumer = new NSQConsumer(lookup, "test3", "testconsumer", (message) -> {
122+
LogManager.getLogger(this).info("Processing message: " + new String(message.getMessage()));
123+
counter.incrementAndGet();
124+
message.finished();
125+
});
126+
consumer.start();
127+
128+
for (int n = 0; n < 5; n++) {
129+
new Thread(() -> {
130+
NSQProducer producer = new NSQProducer();
131+
producer.addAddress("localhost", 4150);
132+
producer.start();
133+
for (int i = 0; i < 1000; i++) {
134+
String msg = randomString();
135+
try {
136+
producer.produce("test3", msg.getBytes());
137+
} catch (NSQException | TimeoutException e) {
138+
Throwables.propagate(e);
139+
}
140+
}
141+
producer.shutdown();
142+
}).start();
143+
}
144+
while (counter.get() < 5000) {
145+
Thread.sleep(500);
146+
}
147+
assertEquals(5000, counter.get());
110148
consumer.shutdown();
111149
}
112150

0 commit comments

Comments
 (0)