diff --git a/README.md b/README.md index f5fd7e901..dbd9f1c80 100644 --- a/README.md +++ b/README.md @@ -266,6 +266,8 @@ Twilio.setEdge("sydney"); This will result in the `hostname` transforming from `api.twilio.com` to `api.sydney.au1.twilio.com`. +To use multiple region within same application, refer [MultiRegionClient.md](https://github.com/twilio/twilio-java/blob/main/examples/MultiRegionClient.md) + ### Enable Debug Logging This library uses SLF4J for logging. Consult the [SFL4J documentation](http://slf4j.org/docs.html) for information about logging configuration. diff --git a/examples/MultiRegionClient.md b/examples/MultiRegionClient.md new file mode 100644 index 000000000..a5080a6e2 --- /dev/null +++ b/examples/MultiRegionClient.md @@ -0,0 +1,41 @@ +```java +package com.twilio.example; + +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.api.v2010.account.Message; +import com.twilio.type.PhoneNumber; + +public class MultiRegionExample { + public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID"); + public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN"); + + public static void main(String[] args) { + + TwilioRestClient client = new TwilioRestClient.Builder(ACCOUNT_SID, AUTH_TOKEN).region("us1").build(); + + Message message = Message + .creator( + new PhoneNumber("+1XXXXXXXXXX"), + new PhoneNumber("+1XXXXXXXXXX"), + "This is the ship that made the Kessel Run in fourteen parsecs?" + ) + .create(client); + + System.out.println(message.getSid()); + + TwilioRestClient client2 = new TwilioRestClient.Builder(ACCOUNT_SID, AUTH_TOKEN).region("au1").build(); + + Message message2 = Message + .creator( + new PhoneNumber("+1XXXXXXXXXX"), + new PhoneNumber("+1XXXXXXXXXX"), + "This is the ship that made the Kessel Run in fourteen parsecs?" + ) + .create(client2); + + System.out.println(message2.getSid()); + } +} + + +```