You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Stefano Bagnara <ap...@bago.org> on 2007/04/14 19:21:35 UTC

non blocking dns and mina based application

Hi all,

I just found a really interesting companion for mina applications, named 
dnsjnio[1]. It is a set of utilities built around dnsjava and 
distributed[2] under the MPL license to reuse 2 single threads for 
resolving concurrently a queue of dns lookups.

Basically his exported interface is INonblockingResolver:
---
void sendAsync(Message message, Object id, ResolverListener 
resolverListener);
Object sendAsync(final Message query, final ResponseQueue responseQueue);
void sendAsync(final Message query, Object id, final ResponseQueue 
responseQueue);
void sendAsync(final Message query, Object id, int timeout, boolean 
useTCP, final ResponseQueue responseQueue);
---

If I understood correcty the sourcecode the preferred way is the one 
using the ResponseQueue.

You send any number of requests to sendAsync and then you can query the 
ResponseQueue.isEmpty to know if any result has been received or simply 
call ResponseQueue.remove to pop a result (this one blocks until one is 
available).

Now I wonder what could be the best way to interact with such an 
interface from a MINA based protocol: we have an SMTPClient that should 
use it to resolve the MX servers and the A records before connecting and 
an SMTPServer that runs a lot of DNS checks (anti-spam, e.g: SPF 
lookups, resolvable sender, existing mx for sender domain, etc) for each 
incoming connections.

Do you have any hint for me?

Is there anyone else already using this library? I guess that blocking 
dns calls is probably a major pitfall for most mina based applications: 
how did you solved the blocking issue in DNS if not using this library?

Thank you,
Stefano

[1] 
http://blog.nominet.org.uk/tech/2006/08/08/nonblocking-extensions-to-dnsjava/
[2] http://download.nominet.org.uk/dnsjnio/


Re: non blocking dns and mina based application

Posted by Trustin Lee <tr...@gmail.com>.
Hi Stefano,

On 4/15/07, Stefano Bagnara <ap...@bago.org> wrote:
> Hi all,
>
> I just found a really interesting companion for mina applications, named
> dnsjnio[1]. It is a set of utilities built around dnsjava and
> distributed[2] under the MPL license to reuse 2 single threads for
> resolving concurrently a queue of dns lookups.
>
> Basically his exported interface is INonblockingResolver:
> ---
> void sendAsync(Message message, Object id, ResolverListener
> resolverListener);
> Object sendAsync(final Message query, final ResponseQueue responseQueue);
> void sendAsync(final Message query, Object id, final ResponseQueue
> responseQueue);
> void sendAsync(final Message query, Object id, int timeout, boolean
> useTCP, final ResponseQueue responseQueue);
> ---
>
> If I understood correcty the sourcecode the preferred way is the one
> using the ResponseQueue.
>
> You send any number of requests to sendAsync and then you can query the
> ResponseQueue.isEmpty to know if any result has been received or simply
> call ResponseQueue.remove to pop a result (this one blocks until one is
> available).
>
> Now I wonder what could be the best way to interact with such an
> interface from a MINA based protocol: we have an SMTPClient that should
> use it to resolve the MX servers and the A records before connecting and
> an SMTPServer that runs a lot of DNS checks (anti-spam, e.g: SPF
> lookups, resolvable sender, existing mx for sender domain, etc) for each
> incoming connections.
>
> Do you have any hint for me?

Actually, I added a similar feature last week to MINA
2.0.0-M1-SNAPSHOT.  It will be available in MINA 2.0.0.  You could try
the feature and give me feedback.

Please refer to the following JIRA page to find out how to use it:

https://issues.apache.org/jira/browse/DIRMINA-92#action_12488311

There are two usages.  What you are looking for is the second one.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6