Skip to content

Commit ed6b0f6

Browse files
author
Ludvik Jerabek
committed
Update README.md
Added Region.US to show examples of service region selection.
1 parent b284273 commit ed6b0f6

1 file changed

Lines changed: 42 additions & 19 deletions

File tree

README.md

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ import io.pfpt.ser.mail.*;
4141

4242
public class Example {
4343
public static void main(String[] args) {
44-
// Initialize the Client with OAuth credentials from the config
45-
Client client = new Client("<client_id>", "<client_secret>");
44+
// Initialize the Client with OAuth credentials from the config.
45+
// Default region when not specified is Region.US
46+
Client client = new Client("<client_id>", "<client_secret>", Region.US);
4647

4748
// Use the fluent builder to construct and send an email
4849
Message message = Message.builder()
@@ -74,8 +75,9 @@ import io.pfpt.ser.mail.*;
7475

7576
public class Example {
7677
public static void main(String[] args) {
77-
// Initialize the Client with OAuth credentials from the config
78-
Client client = new Client("<client_id>", "<client_secret>");
78+
// Initialize the Client with OAuth credentials from the config.
79+
// Default region when not specified is Region.US
80+
Client client = new Client("<client_id>", "<client_secret>", Region.US);
7981

8082
// Construct logo_a attachment with dynamic content ID
8183
var logo_b = Attachment.builder()
@@ -170,23 +172,44 @@ Message message = Message.builder()
170172
```
171173

172174
## Concurrency Example
175+
173176
```java
177+
import io.pfpt.ser.mail.Region;
178+
174179
ExecutorService executorService = Executors.newFixedThreadPool(10);
175-
Client client = new Client("<client_id>", "<client_secret>");
176-
for (int i = 0; i < 10; i++) {
177-
executorService.submit(() -> {
178-
Message msg = Message.builder()
179-
.subject("Concurrent Test")
180-
.from("sender@example.com")
181-
.addTo("recipient@example.com")
182-
.addContent("Test message", Content.ContentType.TEXT)
183-
.build();
184-
SendResult result = client.send(msg).join();
185-
System.out.printf("Thread [%d] Status: %d\n", Thread.currentThread().getId(), result.getHttpResponse().statusCode());
186-
});
187-
}
188-
executorService.shutdown();
189-
executorService.awaitTermination(60, TimeUnit.SECONDS);
180+
// Initialize the Client with OAuth credentials from the config.
181+
// Default region when not specified is Region.US
182+
Client client = new Client("<client_id>", "<client_secret>", Region.US);
183+
for(
184+
int i = 0;
185+
i< 10;i++){
186+
executorService.
187+
188+
submit(() ->{
189+
Message msg = Message.builder()
190+
.subject("Concurrent Test")
191+
.from("sender@example.com")
192+
.addTo("recipient@example.com")
193+
.addContent("Test message", Content.ContentType.TEXT)
194+
.build();
195+
SendResult result = client.send(msg).join();
196+
System.out.
197+
198+
printf("Thread [%d] Status: %d\n",Thread.currentThread().
199+
200+
getId(),result.
201+
202+
getHttpResponse().
203+
204+
statusCode());
205+
});
206+
}
207+
executorService.
208+
209+
shutdown();
210+
executorService.
211+
212+
awaitTermination(60,TimeUnit.SECONDS);
190213
```
191214

192215
## Known Issues

0 commit comments

Comments
 (0)