Database Implementation in jPOS

635 views
Skip to first unread message

Pieter Botha

unread,
Jul 23, 2012, 10:37:22 AM7/23/12
to jpos-...@googlegroups.com
Good day,

Goal: Log a transaction in a database (mysql) using the Mysql JDBC jar load balanced (multi thread).

I've looked through the blogs & forums as I can't really believe that I'm the first person encountering this problem, though I'm not finding anything related.

I've successfully established a connection to Mysql and queried the server inside a TM participant, though I'm coming across an interesting issue:
- If each participant creates it's own instance of a connection to Mysql, the Mysql will be semi flooded with connection opening and closing
- If I centralize the Mysql implementation to a single class and make it a Singleton, then everyone might across the system (single JVM) will thus wait in a serial queue (assuming my understanding that a Singleton applies to a JVM)
- If I create a thread pool (say 10) and then return a reference to that thread using my Singleton class and then reserve that thread specifically for the calling class, then other classes might end up waiting for a thread if I run out of threads. Assuming I implement it correctly, calling classes might need some form of logic to wait for a connection thread. This solution might be in danger if threads are not released appropriately. The best reference I could come up with is: http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html

Note: This is done using jPOS and not JPosEE.

Does anyone have a suggestion on how this should be done in jPOS?

Pieter

Alejandro Revilla

unread,
Jul 23, 2012, 10:48:53 AM7/23/12
to jpos-...@googlegroups.com
We use jPOS-EE, and Hibernate to handle the O/R mapping, but I guess you can do the same using directly a JDBC connection.

This document may give you some hints: http://jpos.org/private/jCard_Internals.pdf

It just describe one transaction (I think a balance inquiry), but it can help you get an idea that a full fledged jPOS switch is not trivial.

BTW, off topic, the jCard's UI (hard work of @sprevilla) is getting nice, you can check it here: http://jpos.org/jpos (user 'admin', password 'test')

--
@apr




Pieter

--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage.
Please support jPOS, contact: sa...@jpos.org
 
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users

Reply all
Reply to author
Forward
0 new messages