Reputation: 283
I have a Spring Batch project where I will need to save 2 keys in the Step
ExecutionContext
, which will be promoted to the Job
ExecutionContext
.
I understand from online examples, e.g. this code where you can set multiple keys.
This example is done using Java, where the ExecutionContextPromotionListener
is defined as a Java class. In my case, it's defined in an XML file
Here's the current XML configuration for the promotion listener:
<bean id="promotionListener" class="org.springframework.batch.core.listener.ExecutionContextPromotionListener">
<property name="keys" value="idA"/>
</bean>
But i now need another key to be in the ExecutionContext
.
Is this how i define it?
<bean id="promotionListener" class="org.springframework.batch.core.listener.ExecutionContextPromotionListener">
<property name="keys">
<list>
<value>idA</value>
<value>idB</value>
</list>
</property>
</bean>
This doesn't work, so i tried the following but didn't work as the compiler gave an error:
<property name="keys" values="idA,idB"/>
This doesn't work either
<property name="keys" value="idA,idB"/>
I couldn't get any online references, even on StackOverflow, for what i'm trying to implement
Appreciate any help, thanks in advance
Follow-up questions:
promotionListener
bean in multiple steps?promotionListener
bean have a String
array of keys, one is idA
, another is idB
. Can i have Step X save data using idA
& Step Z save data using idB
, where both Step X & Z have promotionListener
as the listeners. Is this allowed? Or should I use 2 separate promotionListener
s: promotionListener1
& promotionListener2
for each of the Step
s?Upvotes: 0
Views: 419
Reputation: 31730
The keys
field in ExecutionContextPromotionListener
is of type String[]
. So you need to define the keys as an array. This should help: How to define a bean of String array in Spring (using XML configuration)
Upvotes: 1