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/

Reply via email to