Hi Alexey,
On Fri, Feb 22, 2013 at 8:36 PM, Oleksiy Stashok
<oleksiy.stashok_at_oracle.com> wrote:
> Hi Tigran,
>
>
>
> On 22.02.13 02:22, Tigran Mkrtchyan wrote:
>>
>> Hi,
>>
>> I have in the code following lines:
>>
>> context.write(context.getAddress(), buffer, null);
>>
>> is it safe to replace with:
>>
>> connection = context.getConnection();
>> remoteAddress = (InetSocketAddress)context.getAddress();
>>
>> connection.write(remoteAddress, buffer, null);
>>
>> The main difference is that point where I use connection is much later
>> and executed by other thread ( e.q. I am building in async reply
>> mechanism).
>>
>> Well, it works but I want to be sure that it's reliable.
>
> ctx.write(...) is basically writing message starting from the *current*
> (FilterChainContext) filter downstream.
> connection.write(...) writes the message start from the *last* Filter in
> chain downstream.
>
Ok, I do this in the last filter:
@Override
public NextAction handleRead(final FilterChainContext ctx) throws
IOException {
final RpcCall call = ctx.getMessage();
_asyncExecutorService.execute( new Runnable() {
@Override
public void run() {
program.dispatchCall(call);
}
});
return ctx.getInvokeAction();
}
is the be best practice, or there is another to do the processing. The
main reason is that we get multiple requests over the same TCP
connection and some of them may take quite some time, while the others
have to be processed independently.
Tigran.
> WBR,
> Alexey.
>
>>
>> Thanks,
>> Tigran.
>
>