Initial working commit passing jobs to spring batch
This commit is contained in:
parent
0fc2e04e65
commit
f8d699e13b
|
@ -12,6 +12,12 @@ import ca.uhn.fhir.validation.ResultSeverityEnum;
|
|||
import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
|
||||
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
|
@ -32,6 +38,35 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
|||
static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TestDstu3Config.class);
|
||||
private Exception myLastStackTrace;
|
||||
|
||||
@Autowired
|
||||
private StepBuilderFactory myStepBuilderFactory;
|
||||
|
||||
@Autowired
|
||||
private JobBuilderFactory myJobBuilderFactory;
|
||||
|
||||
@Bean
|
||||
public Job testJob() {
|
||||
return myJobBuilderFactory.get("testJob")
|
||||
.start(taskletStep())
|
||||
.build();
|
||||
}
|
||||
@Bean
|
||||
public Step taskletStep() {
|
||||
return myStepBuilderFactory.get("testSte")
|
||||
.tasklet((stepContribution, chunkContext) -> {
|
||||
System.out.println("It works!");
|
||||
return RepeatStatus.FINISHED;
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Job expungeJob() {
|
||||
return myJobBuilderFactory.get("expungeJob")
|
||||
.start(taskletStep())
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CircularQueueCaptureQueriesListener captureQueriesListener() {
|
||||
return new CircularQueueCaptureQueriesListener();
|
||||
|
|
|
@ -8,12 +8,14 @@ import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
|
|||
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
|
||||
import ca.uhn.fhir.jpa.subscription.match.deliver.resthook.SubscriptionDeliveringRestHookSubscriber;
|
||||
import ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Provenance;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
|
@ -40,8 +42,12 @@ public class TestJPAConfig {
|
|||
return daoConfig().getModelConfig();
|
||||
}
|
||||
|
||||
/*
|
||||
I had to rename this bean as it was clashing with Spring Batch `transactionManager` in SimpleBatchConfiguration
|
||||
*/
|
||||
@Bean
|
||||
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
|
||||
@Primary
|
||||
public JpaTransactionManager hapiTransactionManager(EntityManagerFactory entityManagerFactory) {
|
||||
JpaTransactionManager retVal = new JpaTransactionManager();
|
||||
retVal.setEntityManagerFactory(entityManagerFactory);
|
||||
return retVal;
|
||||
|
|
|
@ -134,8 +134,8 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
|
|||
private static IValidationSupport ourJpaValidationSupportChainDstu3;
|
||||
private static IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept> ourValueSetDao;
|
||||
|
||||
//@Autowired
|
||||
//protected IBatchJobSubmitter myBatchJobSubmitter;
|
||||
@Autowired
|
||||
protected IBatchJobSubmitter myBatchJobSubmitter;
|
||||
@Autowired
|
||||
protected ITermDeferredStorageSvc myTerminologyDeferredStorageSvc;
|
||||
@Autowired
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.hl7.fhir.instance.model.api.IIdType;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -33,6 +35,9 @@ public class ExpungeHookTest extends BaseJpaDstu3Test {
|
|||
@Autowired
|
||||
private DaoConfig myDaoConfig;
|
||||
|
||||
@Autowired
|
||||
private Job testJob;
|
||||
|
||||
PointcutLatch myEverythingLatch = new PointcutLatch(Pointcut.STORAGE_PRESTORAGE_EXPUNGE_EVERYTHING);
|
||||
PointcutLatch myExpungeResourceLatch = new PointcutLatch(Pointcut.STORAGE_PRESTORAGE_EXPUNGE_RESOURCE);
|
||||
|
||||
|
@ -92,6 +97,6 @@ public class ExpungeHookTest extends BaseJpaDstu3Test {
|
|||
|
||||
@Test
|
||||
public void testSubmitJob() {
|
||||
//myBatchJobSubmitter.runJob(null, null);
|
||||
myBatchJobSubmitter.runJob(testJob, new JobParameters());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import org.springframework.batch.core.repository.JobExecutionAlreadyRunningExcep
|
|||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
public class BatchJobSubmitterImpl implements IBatchJobSubmitter {
|
||||
|
||||
|
@ -19,7 +21,6 @@ public class BatchJobSubmitterImpl implements IBatchJobSubmitter {
|
|||
@Override
|
||||
public JobExecution runJob(Job theJob, JobParameters theJobParameters) {
|
||||
try {
|
||||
System.out.println("WTF");
|
||||
return myJobLauncher.run(theJob, theJobParameters);
|
||||
} catch (JobExecutionAlreadyRunningException theE) {
|
||||
//FIXME properly handle these
|
||||
|
|
Loading…
Reference in New Issue