Announcement Announcement Module
No announcement yet.
Inject a reference to the notifications message channel in batch listener Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inject a reference to the notifications message channel in batch listener

    Greeting :-)

    According with the spring-xd documentation, in Retrieve job notifications section, I need to create my own Batch listener and directly inject a reference to the notifications message channel in order to customize behaviour.

    I created the following listener:

    public class MyListener implements JobExecutionListener {
        private SubscribableChannel channel;
        public void setChannel(SubscribableChannel channel) {
   = channel;
        public void beforeJob(JobExecution jobExecution) {
        public void afterJob(JobExecution jobExecution) {
            System.out.println("Testing 1");
            channel.send((Message<?>) jobExecution);

    And the following xml configuration:

        <batch:job id="job">
            <batch:step id="helloSpringXDStep">
                <batch:tasklet ref="helloSpringXDTasklet" />
                <batch:listener ref="myListener"/>
        <!--<beans profile="xd.jobExecutionListener">-->
            <!--<bean id="xd.jobExecutionListener" class="">-->
                <!--<constructor-arg index="0" ref="xd.job.jobExecutionEvents"/>-->
                <!--<constructor-arg index="1" ref="xd.job.aggregatedEvents"/>-->
            <!--<int:publish-subscribe-channel id="xd.job.jobExecutionEvents" />-->
        <bean id="myListener" class="org.springframework.springxd.samples.batch.MyListener">
            <property name="channel" ref="xd.job.jobExecutionEvents"/>
        <bean id="helloSpringXDTasklet"
            class="org.springframework.springxd.samples.batch.Hello1" />
    The commented code is a copy paste from spring-xd source code. I tried to reference with "xd.job.jobExecutionEvents" and with "xd.job.aggregatedEvents" however I'm getting a NoSuchBeanDefinitionException for both references when creating the job. What reference is the documentation talking about?

    Thank you

  • #2
    Sorry for the delay. We are in the process of moving to Stack Overflow as our "forum":

    However, I do want to point out that we now provide simple support for adding a TAP anywhere you may want to listen to job events:

    If you have any further questions, please post on SO.