openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Louis MONTEIRO <jeano...@gmail.com>
Subject Re: Dynamic DataSource Selection with JPA
Date Wed, 12 Nov 2014 14:57:27 GMT
Hi Dave,

We had the same (more or less) pattern in my previous job.
We were using Apache TomEE at the time which also embeds OpenJPA as JPA
provider.

We have implemented this http://tomee.apache.org/dynamic-datasource.html
and used it for 2 different things:
- multi tenancy (kinda) support: ability to save data in different database
depending on customers (who is connected).
- read mostly pattern, but there is some restrictions mainly because of
stale data and cache

Here is an example on how to use it
http://tomee.apache.org/dynamic-datasource.html

Give it a try or at least a look and let us know.


We tried also http://ha-jdbc.github.io/ previously, but we weren't
successful.

Hope it helps


2014-11-12 15:46 GMT+01:00 Dave Westerman <dlwester@us.ibm.com>:

> I am working with a group that has an application that has a very critical
> need for high availability and performance. To make a long story short,
> they want to use DB2 HADR for availability. But they also want to use the
> DB2 HADR read-on-standby facility if the application server is co-located
> with the database server, for performance reasons.
>
> The above details aren't really important here. But what I would like to
> know is if there is a way to dynamically choose which datasource the JPA
> calls will be using at runtime, based on some algorithm. All update calls
> to a JPA entity will always use the primary datasource. But if the entity
> is only being read, then the standby datasource may be the one used if the
> servers are co-located.
>
> I'm not sure if this is even feasible with JPA, but hopefully someone here
> can tell me.
>
> Thanks!




-- 
Jean-Louis

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message