Hi, Looks like I found the solution to my question.
While trying to reproduce & debug the issue via simple unit test, I realized that my concurrency problems were caused by the way I'm using the FtpEndpoint. Actually Camel ProducerCache will ensure that each of the parallel calls gets an own FtpProducer. I was explicitly setting the FtpClient at the FtpEndpoint, which results in the same client instance (which is not thread safe) being reused for all FtpProducers. If the client is not set, FtpEndpoint will create a new FtpClient for each FtpProducer and the route works as expected. Regards, Christian -----Original Message----- From: Becker, Christian <ch.bec...@sap.com.INVALID> Sent: Wednesday, 27 July 2022 16:53 To: users@camel.apache.org Subject: Is FTP endpoint thread-safe? Hello, I'm using Camel to receive message via SOAP and send them to a FTP server (via a toD endpoint with the same FTP URL). When one message is sent, everything is fine, but when multiple messages are processed in parallel, some calls to the FTP server start failing in a random manner. From the logs I have the impression that FTP response codes from one request leak into other requests and I was wondering if the FTP endpoint is thread-safe. The Camel documentation claims that the FTP producer supports concurrency https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcamel.apache.org%2Fcomponents%2F2.x%2Fftp-component.html%23_concurrency&data=05%7C01%7Cch.becker%40sap.com%7Cd4d4a17238d147121a6508da6fdfb576%7C42f7676cf455423c82f6dc2d99791af7%7C0%7C0%7C637945303964528212%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=SMPb5lwCYHPy%2BhWSFjJr1TBSmmhnphxVBHJFZDEKSY4%3D&reserved=0 But looking at the code I see that FtpEndpoint only contains one FtpClient instance and the FAQ at https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcwiki.apache.org%2Fconfluence%2Fdisplay%2FCOMMONS%2FNet%2BFrequentlyAskedQuestions&data=05%7C01%7Cch.becker%40sap.com%7Cd4d4a17238d147121a6508da6fdfb576%7C42f7676cf455423c82f6dc2d99791af7%7C0%7C0%7C637945303964528212%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=lQjOGtICV96mcoIx7Ize5eilvnQDvf9WEmmAxkctcLw%3D&reserved=0 says: „... If you want to share a single FTPClient instance between multiple threads, you must serialize access to the object with critical sections.“ One example: FtpClient extends FTP extends SocketClient, where the instance variable _socket_ is overwritten by every connect() call. Using this from multiple threads does not seem to be safe. I did not find any synchronization or serialization in the Camel coding so far. ==> Is the FtpEndpoint thread-safe for parallel requests writing files to a FTP server? Or is this a bug? Best regards, Christian