Hi,
I know it has nothing to do with this thread but no one replied to my
question before.., also regarding with UDP servers.
What kind of threading model can I apply to a DatagramAcceptor? I read from
the tutorial that threading model applies just for TCP Acceptors..perhaps I
misunderstood that..
The server will have a very high network latency, dispatching thousands of
datagram packets per second (basically db inserts), so I think I will need
to have a pool of worker threads implementing IoHandler right? , How can I
accomplish this? I will also be using codec filters.
Thank you in advance.
Damian
Jeremy writes:
You answered that question for me - thank you for that. I was hoping that
I wouldn't need to deal with the sessions, but it's easy enough to deal
with. I think what you just basically described is in the chat example
that comes with MINA.
I can add a method to look up the session as described and write the data
to it. The other question that I have, is where should the method be
called from? For example, if I have a JMS consumer that consumes a
message with instructions to deliver a packet to a certain IP address,
should that method access the IoHandler through the class that created the
acceptor? (acceptor.getHandler().insertMySendMethodHere()?)
Thanks again,
Jeremy
OK I think I see now. Even though UDP is stateless, MINA still associates
a
IoSession with clients. I think all you need to do is lookup the
IoSession
associated with the client that connected to your server. You could do
this
in many ways, but you could probably just use a map with keys derived from
the IP and port for the client. So in your handler, you might want to
track
the sessions you encounter and manage this map of live sessions using the
sessionOpened() and sessionClosed() methods of your IoHandler. Just
access
the map to get the client's IoSession when you get the client IP/port info
from your JMS/Webservice message. Then send the data back to the client
by
writing to it via the IoSession.
Alex