title: How to configure listeners in a spring batch job in a grails project?
body: <p>I use spring batch in a grails project, and i installed a grails plugin to get it work : grails-spring-batch</p>
  
  <p>I implemtented a simple job, with a reader, a processor and a writer, and it works fine.</p>
  
  <p>But i would like to add listeners to my job steps (reader, processor and writer), in order to handle errors nicely.</p>
  
  <p>But i can't get to make my listeners beeing used ! I think i may be misusing the dsl used to define beans. With different tries on the dsl, i have sometimes errors at runtime, or sometimes no errors but the listener is not used.</p>
  
  <p>Do you know if the grails-spring-batch plugin currently allow to define listeners ? If yes, how does it work ? </p>
  
  <p>here is my spring batch conf, which uses the DSL the grails plugin provides:</p>
  
  <pre><code>batch.job(id: 'simpleJob') {
      batch.step(id: 'myStep') {
          batch.tasklet{
              batch.chunk(
                      reader: 'myReader',
                      processor: 'myProcessor',
                      writer: 'myWriter',
                      'commit-interval': 1,
                      listeners:
                              batch.listener(
                                      ref: "myReaderListener"
                              )
  
              )
          }
      }
  }
  </code></pre>
  
  <p>EDIT: a simple solution i did not think about : make my reader implements <strong>ItemReadListener,</strong> which brings the <strong>onError</strong> method, which is exactly what i try to do.</p>
  
  <p>But if the need is to put the listener logic in another bean, my question still stands.</p>