Interfacing with Database on Server
Frederic Bregier
fredbregier at free.fr
Fri Oct 23 03:54:05 EDT 2009
Hi,
I would suggest something in your pipeline like in that order :
- handlers for codec (your protocol on how to receive or answer information)
- handler for execution handler (OrderedMemoryAwareThreadPoolExecutor)
- handler for business
In your business, you could make all of your business code, including the
request from the DB pool.
Then you know what and when you need to answer to the client.
Another option is as you wrote:
- handlers for codec (your protocol on how to receive or answer information)
- handler for execution handler (OrderedMemoryAwareThreadPoolExecutor)
- handler for business
- handler for DB connection and queries
Then your business just pass the request (if any) to the Db Connection and
Queries handler (using downstream).
The Db Conn & Query handler if needed to answer just write the answer (in
the form you need for instance as an Object) using upstream.
Then the business get the upstream and decide or not to forward it to the
client...
But my guess is that only one handler is easier but it greatly depends on
your dev and logic...
HTH,
Frederic
vimana wrote:
>
> Hi,
>
> I'm having difficulty understanding how to interface with a DB (MySQL) on
> the Server.
> From what I've gathered, I'll need to create a connection pool (which I've
> done using Apache DBCP), add an execution handler to my pipeline (I used
> the OrderedMemoryAwareThreadPoolExecutor) and my business logic handler
> checks if the request from the client is to save something to the db or
> retrieve something from the db. I then would want the business logic
> handler to pass this request to the execution handler which will grab a
> connection from the connection pool and run the query. If the query was to
> return a result to the client then the execution handler would write the
> result back to the client. I'm not sure if this is the correct way to go
> about it and if it is how do I pass the request from the logic handler to
> execution handler (sendupstream?). And How does the execution handler
> receive the message ? Do i attach a runnable object to the context object
> associated with the channel in the business logic handler, sendupstream
> and then in the handleupstream in Executionhandler get the attachment and
> do a .execute((Runnble)ctx.getAttachment())?
>
> It would help a lot if I can get a high level overview of the correct way
> to interact with the database.
>
> Thanks!
>
-----
Hardware/Software Architect
--
View this message in context: http://n2.nabble.com/Interfacing-with-Database-on-Server-tp3874876p3877340.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list