Skip to content

Instantly share code, notes, and snippets.

@shiena
Last active January 13, 2016 06:46
Show Gist options
  • Save shiena/0f13ccb63288735210cd to your computer and use it in GitHub Desktop.
Save shiena/0f13ccb63288735210cd to your computer and use it in GitHub Desktop.
version '1.0-SNAPSHOT'
apply plugin: 'application'
sourceCompatibility = 1.8
mainClassName = 'Main'
repositories {
mavenCentral()
}
dependencies {
compile 'io.vertx:vertx-redis-client:3.2.0'
compile 'io.vertx:vertx-rx-java:3.2.0'
}
redis:
image: redis:3.0.4
ports:
- "6379:6379"
import io.vertx.core.json.JsonArray;
import io.vertx.redis.RedisOptions;
import io.vertx.rxjava.core.Vertx;
import io.vertx.rxjava.redis.RedisClient;
import rx.Observable;
public class Main {
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
RedisOptions options = new RedisOptions();
options.setHost("192.168.99.100");
options.setPort(6379);
Observable.range(1, 100)
.subscribe(i -> {
RedisClient client = RedisClient.create(vertx, options);
System.out.println("start " + i);
Observable<Integer> ob = Observable.range(1, 100);
Observable<Long> set = ob.flatMap(r -> client.hsetObservable("key", "field", "value"));
Observable<String> get = ob.flatMap(r -> client.hgetObservable("key", "field"));
Observable<JsonArray> key = ob.flatMap(r -> client.hkeysObservable("key"));
Observable
.merge(set, key, get)
.finallyDo(() -> client.closeObservable().subscribe())
.subscribe();
});
}
}
start
12 22, 2015 2:42:41 午前 io.vertx.core.impl.ContextImpl
重大: Unhandled exception
java.lang.ClassCastException: io.vertx.core.buffer.impl.BufferImpl cannot be cast to [Lio.vertx.redis.impl.Reply;
at io.vertx.redis.impl.Reply.asType(Reply.java:94)
at io.vertx.redis.impl.RedisConnection.handleReply(RedisConnection.java:421)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:180)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:21)
at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$28(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
12 22, 2015 2:42:41 午前 io.vertx.core.impl.ContextImpl
重大: Unhandled exception
java.lang.ClassCastException: io.vertx.core.buffer.impl.BufferImpl cannot be cast to [Lio.vertx.redis.impl.Reply;
at io.vertx.redis.impl.Reply.asType(Reply.java:94)
at io.vertx.redis.impl.RedisConnection.handleReply(RedisConnection.java:421)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:180)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:21)
at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$28(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
12 22, 2015 2:42:41 午前 io.vertx.core.impl.ContextImpl
重大: Unhandled exception
java.lang.ClassCastException: io.vertx.core.buffer.impl.BufferImpl cannot be cast to [Lio.vertx.redis.impl.Reply;
at io.vertx.redis.impl.Reply.asType(Reply.java:94)
at io.vertx.redis.impl.RedisConnection.handleReply(RedisConnection.java:421)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:180)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:21)
at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$28(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
12 22, 2015 2:42:41 午前 io.vertx.core.impl.ContextImpl
重大: Unhandled exception
java.lang.ClassCastException: io.vertx.core.buffer.impl.BufferImpl cannot be cast to [Lio.vertx.redis.impl.Reply;
at io.vertx.redis.impl.Reply.asType(Reply.java:94)
at io.vertx.redis.impl.RedisConnection.handleReply(RedisConnection.java:421)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:180)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:21)
at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$28(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
start
12 22, 2015 2:51:50 午前 io.vertx.core.impl.ContextImpl
重大: Unhandled exception
java.lang.ClassCastException: java.lang.Long cannot be cast to [Lio.vertx.redis.impl.Reply;
at io.vertx.redis.impl.Reply.asType(Reply.java:94)
at io.vertx.redis.impl.Reply.asType(Reply.java:156)
at io.vertx.redis.impl.RedisConnection.handleReply(RedisConnection.java:441)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:180)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:21)
at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$28(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
12 22, 2015 2:51:50 午前 io.vertx.core.impl.ContextImpl
重大: Unhandled exception
java.lang.ClassCastException: java.lang.Long cannot be cast to [Lio.vertx.redis.impl.Reply;
at io.vertx.redis.impl.Reply.asType(Reply.java:94)
at io.vertx.redis.impl.Reply.asType(Reply.java:156)
at io.vertx.redis.impl.RedisConnection.handleReply(RedisConnection.java:441)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:180)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:21)
at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$28(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
12 22, 2015 2:51:50 午前 io.vertx.core.impl.ContextImpl
重大: Unhandled exception
java.lang.ClassCastException: java.lang.Long cannot be cast to [Lio.vertx.redis.impl.Reply;
at io.vertx.redis.impl.Reply.asType(Reply.java:94)
at io.vertx.redis.impl.Reply.asType(Reply.java:156)
at io.vertx.redis.impl.RedisConnection.handleReply(RedisConnection.java:441)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:180)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:21)
at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$28(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
12 22, 2015 2:51:50 午前 io.vertx.core.impl.ContextImpl
重大: Unhandled exception
java.lang.ClassCastException: java.lang.Long cannot be cast to [Lio.vertx.redis.impl.Reply;
at io.vertx.redis.impl.Reply.asType(Reply.java:94)
at io.vertx.redis.impl.Reply.asType(Reply.java:156)
at io.vertx.redis.impl.RedisConnection.handleReply(RedisConnection.java:441)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:180)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:21)
at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$28(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
12 22, 2015 2:51:50 午前 io.vertx.core.impl.ContextImpl
重大: Unhandled exception
java.lang.ClassCastException: java.lang.Long cannot be cast to [Lio.vertx.redis.impl.Reply;
at io.vertx.redis.impl.Reply.asType(Reply.java:94)
at io.vertx.redis.impl.Reply.asType(Reply.java:156)
at io.vertx.redis.impl.RedisConnection.handleReply(RedisConnection.java:441)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:180)
at io.vertx.redis.impl.ReplyParser.handle(ReplyParser.java:21)
at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$28(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment