gonzalo diethelm wrote:
I would like to ask the wise members of this list for some advice. The
system I need to build will be based on several different processes
running on one or more machines. Each process will be a SEDA-like
server, having an explicit incoming message queue and a processing
thread to take care of the messages. I plan on implementing the queue
with an appropriate Java data structure and maybe a local SQLite DB if I
decide to make the queue persistent.
Q1: Perhaps I should look into some other, more standard implementation
of a queue for my processes?
JMS ? Seems to match perfectly ... Even if you receive binary messages
from your client, you might want to transfer them to a message queue
server in order to guarantee the message reliance.
The communication between each process will be over connection-oriented
TCP/IP sockets. Each process will listen on one (maybe more) ports for
connection attempts from other processes, and will also issue active
connects to other processes. The messages sent around will probably all
inherit from a base class and will be marshaled into UTF-8 text messages
with some sort of encoding. XML might be an alternative here, but it is
not a must.
Q2: Can anybody suggest a marshalling approach? Maybe an existing
library or protocol to be used?
Do you receive text messages in a specific encoding, different from
UTF-8 ? If so, you simply have to convert those messages to UTF-8.
Pretty straigthforward in Java.
Unless you mean something different from what I understand.
Q3: How would I go about implementing this model with MINA? What
specific classes should I be using for accepting incoming communications
NioAcceptor
and initiating outgoing ones?
NioConnector
Could I use these suggested classes even
for the case of implementing a process that connects to itself (for
testing purposes)?
Why not? We have some tests doing exactly that : being the client and
the server.
What would be the whole set of classes in the stack,
from accepting a connection to receiving a message and making it
available for the business logic?
Well, the best would be for you to check the tutorial, and the
presentations. It's all on the web site.
Q4: Are there any examples that might be close to these requirements?
Seeing some preexisting code would be very helpful.
Just check the samples, and the tests. Also related projects (AsyncWeb,
FtpServer, Vysper) might help you to get a grip on MINA : they are real
world apps, not just samples, and not that big (a few thousands lines of
code).
Hope it helps.
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org