Skip to content

A Problem about random value of step's StepName  #3677

Closed
@rikushin

Description

@rikushin

I have a problem about random value of step's StepName.

I extend Spring Batch to call OS shell like .sh and .bat files from tasklet.
I also define a custom tag in xml configuration file to hold the information about OS shell.
But I don't define job and step tags in xml configuration file, and use BeanParser to just get
a bean of TaskletStep. The xml configuration file is as below.
<beans>
<externalcommand="sampleExtJob.bat"/>
</beans>

I found that Spring Batch create and set the step name using a random value like below
(inner bean)#236c8f48
It works fine until when I use spring Boot 2.2 and Spring Batch 4.2.0.

In Spring Batch 4.2, the Micrometer will collect metrics for job steps.
Micrometer use step name as a part of key to store metrics to MeterRegistry.
But because the step name is random, when I run the job repeatedly,
metrics data will increase continuously to cause a OutOfMemory.

So I try to set my own step name by defining job and step tags in xml configuration file,
<beans>
<job xmlns="http://www.springframework.org/schema/batch" id="extJob" >
<step id="stepDefault">
<tasklet ref="tasklet"/>
</step>
</job>
<bean id="tasklet" class="com.example.ExternalJobTasklet"/>
<external command="sampleExtJob.bat"/>
</beans>

and I can get the correct step name from TaskletStep that created by BeanParser,
but when step execution, the step name is overwritten by the random value as above.

Can spring batch not use random value to set step name for me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidLegacy label from JIRA. Superseded by "status: declined"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions