Search in sources :

Example 1 with DownstreamMessageEvent

use of org.jboss.netty.channel.DownstreamMessageEvent in project databus by linkedin.

the class SimpleDatabusRequest method sendDownstreamAsBinary.

@Override
public void sendDownstreamAsBinary(ChannelHandlerContext ctx, ChannelFuture future) {
    ChannelBuffer buffer = toBinaryChannelBuffer();
    ctx.sendDownstream(new DownstreamMessageEvent(ctx.getChannel(), future, buffer, ctx.getChannel().getRemoteAddress()));
}
Also used : DownstreamMessageEvent(org.jboss.netty.channel.DownstreamMessageEvent) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 2 with DownstreamMessageEvent

use of org.jboss.netty.channel.DownstreamMessageEvent in project databus by linkedin.

the class MockServerChannelHandler method writeRequested.

@Override
public void writeRequested(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug("<=<=<=<=WRite requested" + e.getMessage());
        printMessage("<=<=<=<=", e);
    }
    MessageEvent newMessage = e;
    if (_saveTheFuture) {
        if (_future == null) {
            // save the real future - so we can fail it
            _future = e.getFuture();
            // to make sure client's Netty thread will not get the update - we substitute a fake future
            ChannelFuture newFuture = Channels.future(ctx.getChannel());
            newMessage = new DownstreamMessageEvent(ctx.getChannel(), newFuture, e.getMessage(), e.getRemoteAddress());
            if (LOG.isDebugEnabled())
                LOG.debug("Saving the future:" + _future);
        }
    }
    super.writeRequested(ctx, newMessage);
}
Also used : ChannelFuture(org.jboss.netty.channel.ChannelFuture) DownstreamMessageEvent(org.jboss.netty.channel.DownstreamMessageEvent) MessageEvent(org.jboss.netty.channel.MessageEvent) DownstreamMessageEvent(org.jboss.netty.channel.DownstreamMessageEvent)

Example 3 with DownstreamMessageEvent

use of org.jboss.netty.channel.DownstreamMessageEvent in project databus by linkedin.

the class SimpleDatabusResponse method writeToChannelAsBinary.

@Override
public void writeToChannelAsBinary(ChannelHandlerContext ctx, ChannelFuture future) {
    ChannelFuture realFuture = (null != future) ? future : Channels.future(ctx.getChannel());
    ChannelBuffer serializedResponse = serializeToBinary();
    DownstreamMessageEvent e = new DownstreamMessageEvent(ctx.getChannel(), realFuture, serializedResponse, ctx.getChannel().getRemoteAddress());
    ctx.sendDownstream(e);
}
Also used : ChannelFuture(org.jboss.netty.channel.ChannelFuture) DownstreamMessageEvent(org.jboss.netty.channel.DownstreamMessageEvent) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Aggregations

DownstreamMessageEvent (org.jboss.netty.channel.DownstreamMessageEvent)3 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)2 ChannelFuture (org.jboss.netty.channel.ChannelFuture)2 MessageEvent (org.jboss.netty.channel.MessageEvent)1