Reputation: 573
I'd like to implement a netty "slave" application that listens for requests on an outgoing websocket connection. So on bootstrap, the application would:
My question is how to boostrap the channel - I'd rather use a bootstrap object for convenience sake (I mean vs. configuring the channel by hand), but:
Any suggestions on how to bootstrap the channel without duplicating a bunch of existing *Bootstrap code?
Upvotes: 0
Views: 124
Reputation: 573
I ended up passing an EventExecutorGroup directly to the pipeline via ChannelPipeline.html.addLast() - I somehow had missed that in the api docs.
From the javadocs:
static final EventExecutorGroup group = new DefaultEventExecutorGroup(16);
...
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("decoder", new MyProtocolDecoder());
pipeline.addLast("encoder", new MyProtocolEncoder());
// Tell the pipeline to run MyBusinessLogicHandler's event handler methods
// in a different thread than an I/O thread so that the I/O thread is not blocked by
// a time-consuming task.
// If your business logic is fully asynchronous or finished very quickly, you don't
// need to specify a group.
pipeline.addLast(group, "handler", new MyBusinessLogicHandler());
Upvotes: 0