• Jon Wu 5
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Let's say I have a Java web server application that uses a single user server@example.com to read and write all data from an org. The username / password credentials are part of the server's configuration.

My goal is to "reuse" the same connection info / session info in that I want the best performance possible and in a thread-safe manner.

If for every request, I use all this code https://github.com/forcedotcom/wsc#write-application-code to create a new connection, I think each connection will require a login to get a session ID, before making an actual request. On the other hand, I think sharing the same object from Connector.newConnection(config) would lead to issues if I wanted to different timeouts for various requests or wanted allOrNone set for some requests but not others. I've actually been using this latter method, but now want to vary some of these parameters.

What's the best way to ensure that each SOAP API request can have its own settings like timeout or allOrNone while avoiding extra SOAP API login requests? Am I overthinking this?

One thought I had was to store connection.getConfig().getSessionId() as a static volatile variable, then create each connection with that session ID and a session renewer that would update the global if the session had to be renewed. Is that a good apporach? Is there something simpler?

Thanks!
Let's say I have a Java web server application that uses a single user server@example.com to read and write all data from an org. The username / password credentials are part of the server's configuration.

My goal is to "reuse" the same connection info / session info in that I want the best performance possible and in a thread-safe manner.

If for every request, I use all this code https://github.com/forcedotcom/wsc#write-application-code to create a new connection, I think each connection will require a login to get a session ID, before making an actual request. On the other hand, I think sharing the same object from Connector.newConnection(config) would lead to issues if I wanted to different timeouts for various requests or wanted allOrNone set for some requests but not others. I've actually been using this latter method, but now want to vary some of these parameters.

What's the best way to ensure that each SOAP API request can have its own settings like timeout or allOrNone while avoiding extra SOAP API login requests? Am I overthinking this?

One thought I had was to store connection.getConfig().getSessionId() as a static volatile variable, then create each connection with that session ID and a session renewer that would update the global if the session had to be renewed. Is that a good apporach? Is there something simpler?

Thanks!