![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| ||||||||
| ||||||||
|
|
Hello, I'm trying to come up with a design for a system that has to integrate with a number of different customer databases on different platforms. Currently our customers are using SQL Server and Oracle databases only, but there should be no restriction on the actual DB being used by the client. |
|
... I plan to use Java and JDBC to address the portability and connectivity issues, but I have hit a problem trying to implement the exact functionality I'm looking for in a database independent manner. I'm quite new to database programming/design, so don't know what is possible, what is not, if I'm on the right track or not etc... |
|
What I want to achieve is to have a Java application running a thread that is 'listening' for changes in the database tables (and processing any change). I have spent quite a bit of time searching the newsgroups and web to find out how to do this, and have found that Oracle provide this functionality via a DBMS_ALERT package, Postgres provides a "LISTEN/NOTIFY" package for this, SQL Server provides a "sp_add_alert" package (although I'm not entirely sure this is intended for the same purpose as DBMS_ALERT or LISTEN/NOTIFY). Ideally, I'd like something that is generic in case a new database is introduced. |
|
... Is there a way of doing this? I want to avoid sleep/poll approaches as a) the DB change should be detected in real-time (not polled), |
|
... and b) the DB tables can potentially get very big and needless polling could introduce performance problems. |
|
I've looked at triggers, stored procedures, Java stored procedures etc.. but none of these things seem to be fully portable, a Java stored procedure would be nice due to the portability of the language but SQL Server doesn't support Java stored procedures (I think, there may be a version that supports Microsoft Java, which isn't portable anyway, but it supports C# and other Microsoft promoted languages). |
|
I'm slightly worried about the performance of Java anyway in a stored procedure, there can be many changes to the table per second. Triggers are used with the Alert packages mentioned above, so if trigger syntax is not portable, that's going to cause a slight problem anyway. |
|
Can anybody point me in the right direction? How should I be trying to achieve this? How do external applications usually get notified of changes in DBs? What realities should I accept (i.e., xyz can't be done, no point in trying it etc..)? Are there any capabilities in DBs that might help, for example, can the DB open a socket and pump the change down the socket, or send a signal to a process ID to notify it of a change etc...? Should I be exec'ing a client script process from a trigger to notify the external app (this could be a performance issue again)? Should I be creating another, small table, where I add the rowID of the changed row and have the external app poll that small table? I'm not sure in which direction I am supposed to be looking!! ![]() Thanks in advance, Eoin. |
#3
| ||||||||
| ||||||||
|
|
Is this a project team of ONE? This is a big endeavor. |
|
Your software is what is going to be generic to the Front end application. |
|
Define what YOU mean by real-time. (I've done lots of hard real-time programming and the way most folks use the term, they obviously do not know what real-time means in software engineering context.) |
|
That all depends on you DB features, application datamodel and implimentation, and exactly what you are polling for. Polling is not bad in all contexts. Most other DBMS if they support triggers and stored procedures are likely to be in proprietary languages, NOT java. So you better plan on having custome interfaces to each DBMS, sometimes even between versions of of the DB. |
|
You cannot worry about performance if you don't define your criteria. Are you talking about: millisecond, second, minute, hourly, or daily updates to the front end? Is this a hard real-time control application (eg. plant process control)? Or is it a dynamic user interface (stock market tracking)? |
|
What are the consequences of missed updates? (in the first example, the plant may blow up, while in the second example missing one trading pricepoint in an hour might be invisible.) |
|
You need to refine exactly what you are trying to achieve. You are worrying about the finegrain details (overhead of sockets, versus signals, versus forking new processes) when you should be concerned about the functionality you need. Make a features list. Be SPECIFIC. The term "real-time" is meaningless by itself. Describe what are the timing deadlines instead, eg "the data is wrong/useless/dangerous if it arrives at the client application XXX seconds after it is enterred in the Database." |
|
There are products out there that have much of the functionality you propose to build from scratch. Check them out. You'll save yourself and your boss a good deal of pain. |
![]() |
| Thread Tools | |
| Display Modes | |
| |