Skip to content

Can't wrap JobRepository in a tracing representation #3899

Closed
@marcingrzejszczak

Description

@marcingrzejszczak

The problem

I can't wrap the JobRepository used by JobBuilderFactory or StepBuilderFactory, the default one is being used.

Same type of a problem as presented here #816 .

related Sleuth code:
https://github.com/spring-cloud/spring-cloud-sleuth/blob/issues_%231904_batch_with_job_repository/spring-cloud-sleuth-autoconfigure/src/main/java/org/springframework/cloud/sleuth/autoconfig/instrument/batch/TraceBatchAutoConfiguration.java#L57-L60

Implementation issues

AbstractBatchConfiguration creates JobBuilderFactory and StepBuilderFactory as fields.

	@Override
	public void afterPropertiesSet() throws Exception {
		this.jobBuilderFactory = new JobBuilderFactory(jobRepository());
		this.stepBuilderFactory = new StepBuilderFactory(jobRepository(), transactionManager());
	}

JobRepository is being injected directly to it from the method bean defitinion

	@Bean
	public abstract JobRepository jobRepository() throws Exception;

Potential solutions

  • do not expose the bean unconditionally
  • inject any JobRepository not the concrete one
  • do not create JobBuilderFactory nor StepBuilderFactory via new.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions