Announcement Announcement Module
No announcement yet.
Login or socket timeout on datasource Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Login or socket timeout on datasource

    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.

    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:
    <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']}" />
    	<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" />
    					<bean class="com.foundry.ingest.geomos.nivel.error.ItemFailureLoggerListener" />
    		<batch:step id="readNivelCoords" next="readNivelObservations">
    			<batch:tasklet transaction-manager="transactionManager" start-limit="100">
    				<batch:chunk reader="readAllNivelCoords" writer="nivelCoordWriter" commit-interval="100" />
    		<batch:step id="readNivelObservations">
    			<batch:tasklet transaction-manager="transactionManager" start-limit="100">
    				<batch:chunk reader="readAllNivelObservations" writer="nivelObservationsWriter" commit-interval="20000" />
    Solutions? Thoughts?