Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Database Url assigned at Step AtomikosDataSourceBean url reset to this url - no change to url.

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

This is a continuation of an earlier resolved thread - Datasource url database name not known until after a Batch step. I moved over to using the Atomikos connection pool and the url switch is not sticking. I can't get the AtomikosDataSourceBean to refresh or recognize the url change.

The xml config for the datasource bean is:


The class follows the standard:



Doing:


gives the bean - I make the changes and try


- log shows it initializing and I output the new url to make sure and the first insert for the UymFileJdbcDao inserts in the default url found in the uymdb.properties file.

I don't think my issue is the assigning of the url but how to force the AtomikosDataSourceBean to reset or the JtaTransactionManager to refresh?

I have looked at Spring AOP Hot Swappable Target Sources in my wanders but not sure.

Any pointers, again much appreciated.

Thanks,
Peter
 
Peter Brown
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is as far as I got if anyone needs it, now re-assessing global transactions:



and it works.

I then setup an aop implementation that gets the needed oldurl from the datasource and newurl from a stepExecutionListener. The idea being that I get the first index of the stepExecutionListener array object in the aop proxy - close (if needed) and initialize with new url and the jdbcTemplate is none the wiser...

I then run the Spring Batch job and get the following:



[The 'createCompositeTransaction' and 'Coordinator not recoverable' are two lines I don't see on my test run.]

I have dug around in the Atomikos code and confirmed that Atomikos is removing the named resource on close.
I have tried setting lazy-init="false" with no change.
I have tried altering the properties file url on close thinking the init will re-read the properties file on init - no change.

Kinda want this Switching Datasources dynamically at runtime (I understand boneCP is not XA Transaction compliant)

Cheers
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic