In my application there is a strong potential for a failed network connection. I need to make sure that the datasource does not infinitely wait for a connection, which is exactly what it is currently doing. My batch job hangs forever.
The problem?
org.springframework.jdbc.datasource.DriverManagerD ataSource and Apache BasicDataSource do NOT support loginTimeout or socketTimeout and I can't seem to find another parameter that will detect an invalid host / connection. As a result my spring batch job hangs forever when the ip address isn't a valid mssql database.
Stats:
I am using spring batch with JDTS as my driver to a mssql database. I cannot use queryTimeout on the spring batch steps because the problem occurs in the data source connect, not the query.
My config bean (the relevant bits) is as follow:
Solutions? Thoughts?Code:<bean id="nivelDataSourceMssql" class="org.springframework.jdbc.datasource.DriverManagerDataSource" scope="step"> <property name="driverClassName" value="${batch.mssql.driver}" /> <property name="username" value="${batch.mssql.user}" /> <property name="password" value="${batch.mssql.password}" /> <property name="url" value="${batch.mssql.connect}#{jobParameters['dburl']}:#{jobParameters['port']}/#{jobParameters['databaseName']}" /> </bean> <batch:job id="ImportAllNivel" restartable="false"> <batch:step id="readNivels" next="readNivelCoords"> <batch:tasklet transaction-manager="transactionManager" start-limit="100"> <batch:chunk reader="readAllNivel" writer="nivelSensorWriter" commit-interval="100" /> </batch:tasklet> <batch:listeners> <batch:listener> <bean class="com.foundry.ingest.geomos.nivel.error.ItemFailureLoggerListener" /> </batch:listener> </batch:listeners> </batch:step> <batch:step id="readNivelCoords" next="readNivelObservations"> <batch:tasklet transaction-manager="transactionManager" start-limit="100"> <batch:chunk reader="readAllNivelCoords" writer="nivelCoordWriter" commit-interval="100" /> </batch:tasklet> </batch:step> <batch:step id="readNivelObservations"> <batch:tasklet transaction-manager="transactionManager" start-limit="100"> <batch:chunk reader="readAllNivelObservations" writer="nivelObservationsWriter" commit-interval="20000" /> </batch:tasklet> </batch:step> </batch:job>


Reply With Quote