File corruption when using append file mode in camel file producer in JBoss Fuse 6.1

Solution Verified - Updated -

Environment

  • Red Hat JBoss Fuse 6.1

Issue

  • A camel context within blueprint is configured with multiple producer endpoints to append the content to a single file with a dynamic file name based on the current time of day. These routes are configured in a multi-threaded environment. An example route is provided below:
<to uri="file:/test?fileName=foo_${date:now:yyyyMMddHHmm}.txt&fileExist=Append" />
  • We observed that the contents of this file appear to become corrupted as the routes process. It appears that the file is not being appropriately locked which is ultimately causing the file corruption.

Resolution

Since Camel does not lock the underlying file for producers, it is not safe to append to the same file in a mult-threaded context. An RFE ENTESB-3880 has been files to enhance the file producer to lock before updating.

The recommended work around for this issue is to use unique file names for producers until the RFE is implemented.

Root Cause

Camel does not lock the underlying file for producers.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.