Announcement Announcement Module
No announcement yet.
ExecutionContext isn't saved completely Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ExecutionContext isn't saved completely

    I have a reader which extends another reader. Both shall persist their state in the execution context to make them restartable.

    The superclass reader is able to read multiple items at once and return them one-by-one to fulfill the contract of the read()-method. This is his update()-method:
    executionContext.put(BUFFERED_ITEMS_KEY, this.items);
    System.out.println("Update Buffered_Items: " + this.items);
    The inheriting reader has a cursor and counts the number of items which it already requested. He does the following in the update()-method:
    executionContext.putInt(START_FROM_KEY, this.currentStartFrom);
    System.out.println("Update Start_From: " + this.currentStartFrom);
    So whenever update is called the curser ("start from") and the buffered items are stored in the context. I can see this in the console output too.
    In my test case when I cause the job to reach its skip-limit and to abort, I only find the correct cursor position in the database but the item list is empty. How can that be?
    {"map":{"entry":[{"string":"FlatFileItemWriter.written","long":20}, {"string":"FlatFileItemWriter.current.count","long ":70},{"string":"Start_From","int":24},{"string":"Buffered_Items_fioefieiidsfie","linked-list":""}]}}
    When I watched the database content during debugging, the state was correctly saved before the abortion.

  • #2
    Solution found

    Ok folks, I found the solution by myself.
    You can't rely on the serialisation of LinkedList here. This seems to break something in the internal logic of the batch framework.

    Instead I serialised the list to a String and stored that String in the execution context. This works fine and as expected now. Ofcourse I have to extend the restart mechanism by a serialisation/deserialisation mechanism now.


    • #3
      I felt encouraged to open a bug report for this: