Closed perrytew closed 2 years ago
I found this. I think that's my solution.
`Using a Different Client
TwilioRestClient client = new TwilioRestClient.Builder(accountSid, authToken).build();
Message message = Message.creator( new PhoneNumber("+15558881234"), // To number new PhoneNumber("+15559994321"), // From number "Hello world!" // SMS body ).create(client); // Pass the client here
System.out.println(message.getSid());`
I'm developing an integration with Twilio using your Twilio Connect.
I've been slowed by out of date documentation here: https://www.twilio.com/docs/iam/connect/quickstart/java
I just realized that all the examples elsewhere are now using the
Twilio
object, and that the TwilioRestClient is no longer a top level object.I see that the Twilio object has a static volatile rest client.
private static volatile TwilioRestClient restClient;
I don't think that's usable within our web server where the same thread may service multiple accounts during its lifetime.How does the Twilio sdk manage multiple "Twilio Connect" clients without the authorizations stomping each other? Again, I'm running a multi-threaded web server and I cannot manage clients by threads.
I quickly reviewed all the other sdks (python, C#, ruby), and they all return back a client object from their init methods. Why does the java sdk not do this?
Please advise.