Skip to content

Commit

Permalink
update post release
Browse files Browse the repository at this point in the history
  • Loading branch information
brainlag committed Apr 27, 2015
1 parent ce2b1ed commit 38c7555
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ target
*.iml
.classpath
.project

pom.xml.versionsBackup
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
## JavaNSQClient

A (fast?) netty-based Java8 client for [NSQ][nsq]
heavily forked of TrendrrNSQClient
A (fast?) netty-based Java8 client for [NSQ](https://nsq.io)
heavily forked of TrendrrNSQClient.

## Artefact

```
<dependency>
<groupId>com.github.brainlag</groupId>
<artifactId>nsq-client</artifactId>
<version>1.0.0.ALPHA</version>
</dependency>
```

## TODO:
auth
ssl
....
* auth
* ssl
* ....

## Consumer

Expand Down
15 changes: 13 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.brainlag.nsq</groupId>
<groupId>com.github.brainlag</groupId>
<artifactId>nsq-client</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0.ALPHA</version>

<name>JavaNSQClient</name>
<description>Fast Java client for NSQ.</description>
Expand Down Expand Up @@ -88,6 +88,17 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand Down
42 changes: 40 additions & 2 deletions src/test/java/com/github/brainlag/nsq/NSQProducerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.brainlag.nsq.exceptions.NSQException;
import com.github.brainlag.nsq.lookup.NSQLookup;
import com.google.common.base.Throwables;
import org.apache.logging.log4j.LogManager;
import org.junit.Test;

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

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class NSQProducerTest {

Expand All @@ -27,7 +29,7 @@ private NSQConfig getDeflateConfig() {
}

@Test
public void testProduceOneMsg() throws NSQException, TimeoutException, InterruptedException {
public void testProduceOneMsgSnappy() throws NSQException, TimeoutException, InterruptedException {
AtomicInteger counter = new AtomicInteger(0);
NSQLookup lookup = new NSQLookup();
lookup.addAddr("localhost", 4161);
Expand Down Expand Up @@ -106,7 +108,43 @@ public void testProduceMoreMsg() throws NSQException, TimeoutException, Interrup
while (counter.get() < 1000) {
Thread.sleep(500);
}
assertEquals(1000, counter.get());
assertTrue(counter.get() >= 5000);
consumer.shutdown();
}

@Test
public void testParallelProducer() throws NSQException, TimeoutException, InterruptedException {
AtomicInteger counter = new AtomicInteger(0);
NSQLookup lookup = new NSQLookup();
lookup.addAddr("localhost", 4161);

NSQConsumer consumer = new NSQConsumer(lookup, "test3", "testconsumer", (message) -> {
LogManager.getLogger(this).info("Processing message: " + new String(message.getMessage()));
counter.incrementAndGet();
message.finished();
});
consumer.start();

for (int n = 0; n < 5; n++) {
new Thread(() -> {
NSQProducer producer = new NSQProducer();
producer.addAddress("localhost", 4150);
producer.start();
for (int i = 0; i < 1000; i++) {
String msg = randomString();
try {
producer.produce("test3", msg.getBytes());
} catch (NSQException | TimeoutException e) {
Throwables.propagate(e);
}
}
producer.shutdown();
}).start();
}
while (counter.get() < 5000) {
Thread.sleep(500);
}
assertEquals(5000, counter.get());
consumer.shutdown();
}

Expand Down

0 comments on commit 38c7555

Please sign in to comment.