Announcement Announcement Module
Collapse
No announcement yet.
batch namespace & exceptionHandler Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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?

    Comment


    • #3
      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, 11:32 AM.

      Comment


      • #4
        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.

        Comment


        • #5
          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!!!

          Comment


          • #6
            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...

            Comment

            Working...
            X