Announcement Announcement Module
Collapse
No announcement yet.
When should we use retry or skip? Is there pre-condition for using them? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • When should we use retry or skip? Is there pre-condition for using them?

    I read document for retry and skip function, and I tried it on my program.
    Then I have some questions (that maybe it seems similar to below question.)
    http://forum.springsource.org/showth...times&p=373722

    My questions are below:

    1.If exception raises , ItemProcessor and ItemWriter is called again when I use retry or skip function.
    And the items already processed by ItemProcessor are passed into ItemProcessor again.
    I think that the result is not same between success case and retried( or skipped) case.
    (for example DB data resut)
    Is it true?

    2.And if so, I think that there are pre-condition for using retry or skip function.
    Beacause I think it should be same result between no retry and retry case.
    Pre-condition example is, "Retry or skip function is able to be used when there is no ItemProcessor in the step.", etc.
    What kind of case, should we use retry or skip function?
    (Almost only for debug?)

    For example, If ItemProcessor below is made, multiple ItemProcessor call makes the result different.
    Code:
    	public Map process(Map item) throws Exception {
    		int n = (Integer)item.get("num") + 1000;
    		item.put("num", n);
    		return item;
    	}


    I am not good at English.
    I am wondering whether everyone understand what I tried to express...
    But I want to understand about skip and retry function (, I want more information).
    Thank you for your any help!

  • #2
    Ideally the processor should be built in a way that it is able to handle retry scenario. In case processor is making database updates, it will not be a problem as the update operation will be rolled back when exception is thrown. Code like sample provided by you should be avoided in processors.

    Comment


    • #3
      Originally posted by rishishehrawat View Post
      Ideally the processor should be built in a way that it is able to handle retry scenario. In case processor is making database updates, it will not be a problem as the update operation will be rolled back when exception is thrown. Code like sample provided by you should be avoided in processors.
      Thank you for your reply.
      Now I understand my mistake.
      You mentioned that ItemProcessor should not directly change item provided by ItemReader. (is this right?)

      I rewrite ItemProcessor , and I tried it.
      The result become same even if exception raises.

      Code:
      	public Map process(Map item) throws Exception {
      		int n = (Integer)item.get("user_id") + 1000;
      		Map newItem = new HashMap(item);
      		newItem.put("user_id", n);
      		return newItem;
      	}
      Thank you.

      Comment

      Working...
      X