Results 1 to 6 of 6

Thread: batch namespace & exceptionHandler

  1. #1
    Join Date
    Jan 2009
    Posts
    4

    Default batch namespace & exceptionHandler

    I've been trying my very best to figure out how to set the exceptionHandler property of a "chunk" in the batch namespace but still no luck. Using the regular beans namespace, I'm able to set the exceptionHandler property of the SimpleStepFactoryBean class using the "property" node. But I can't seem to find the equivalent of it with the "batch" namespace. Am I to use AOP to handle this situation? Any suggestion is greatly appreciated.

    Thanks, and happy computing to all...

  2. #2
    Join Date
    Feb 2008
    Posts
    488

    Default

    The batch namespace doesn't provide the ability to set the execption handler property. If you need to use it, you can use the beans namespace.

    Out of curiosity, what are you using it for?

  3. #3
    Join Date
    Jan 2009
    Posts
    4

    Default

    Well, to be honest, I needed a way to log a message to my users that some of the records don't match the number of columns as set by the header. A FlatFileParseException is thrown when this is encountered in Spring Batch. I am using the batch namespace simply because the beans namespace (I think) does not provide me a way of controlling the step flow should I decide to fail a step in the job. Unless, there is a way that I don't know of, I'd gladly use my old config file which uses the beans namespace. Thanks for your help though... If it becomes a dead end, I might have to introduce some AOP ("gulp") in my steps...
    Last edited by nhoel; Jun 12th, 2009 at 11:32 AM.

  4. #4
    Join Date
    Feb 2008
    Posts
    488

    Default

    First, it is possible to mix batch and beans namespace so that you can get job flow and a custom-defined step:
    Code:
    <job id="job1">
        <step id="step1" parent="standaloneStep"/>
    </job>
    
    <beans:bean id="standaloneStep" class="...SimpleStepFactoryBean">
      ...
    </beans:bean>
    Second, you may want to use either an @OnSkipInRead or an @OnReadError listener method instead of an exception handler for what you are describing.

  5. #5
    Join Date
    Jan 2009
    Posts
    4

    Default

    Aaaahhhh, I forgot about doing that... but would the chunk node pickup the settings from SimpleStepFactoryBean, just out of curiosity? Otherwise, I'll define all my jobs objects using the beans namespace and integrate the job settings using the batch namespace. That kind of solve a lot of my problem though... Thank you very much. I'll read up more on the OnSkipInRead and OnReadError listeners. Again, thank you very much for the tip!!!

  6. #6
    Join Date
    Feb 2008
    Posts
    488

    Default

    You'll almost certainly have problems if the hierarchy for a step has mixes <tasklet/> with <property/> since using a <tasklet/> anywhere in the hierarchy forces the bean to use StepParserStepFactoryBean, which won't have the property you are setting.

    But you probably wont need any of this complexity if you use the listener...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •