I have a few camel routes that call an external web service, i need to manage a session pool for this web service, keeping a few sessions open and reusing idle ones each time a camel route needs one.
Which is "safer" : - managing/persisting the session data in a db using JDBC for example or - implementing a static or singleton pool using apache-commons pool for example
Your session in WebService is represented by some SessionID, which you need to save/pool.So you basically need to pool WebService response (or part of it) which is returned by login operation. This response may leave in pool no longer then session timeout on WebService side.
If your WebService session is valid for days on server side and you want to recover your opened sessions after e.g. crash on client side, or you want to share opened sessions among several clients via DB, then I would use DB.
Otherwise if you have only one client, or it is OK that each client has it's own small cache, I would use in-memory pool. As subalternative you may think about sharing this pool among clients / multiple applications by means of Ehcache/Terracotta. And, by the way, these caches allow you to dump the pool contents contents to disk, which might be a good alternative to DB out-of-the-box.