You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/email/includes/send-email-java.md
+42-42Lines changed: 42 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -210,6 +210,48 @@ Make these replacements in the code:
210
210
211
211
To send the email message, call the `beginSend` function from the `EmailClient`.
212
212
213
+
## [Async Client](#tab/async-client)
214
+
215
+
Calling `beginSend` on the async client returns a `PollerFlux` object to which you can subscribe. The callbacks defined in the subscribe method are triggered once the email sending operation is complete. **Note that the initial request to send an email will not be sent until a subscriber is set up.**
System.out.println("Error occurred while sending email: "+ error.getMessage());
239
+
}
240
+
);
241
+
});
242
+
243
+
// In a real application, you might have a mechanism to keep the main thread alive.
244
+
// For this sample we will keep the main thread alive for 30 seconds to make sure the child thread has time to receive the SUCCESSFULLY_COMPLETED status.
245
+
try {
246
+
Thread.sleep(MAIN_THREAD_WAIT_TIME.toMillis());
247
+
} catch (InterruptedException e) {
248
+
e.printStackTrace();
249
+
}
250
+
251
+
executorService.shutdown();
252
+
System.out.println("Main thread ends.");
253
+
```
254
+
213
255
## [Sync Client](#tab/sync-client)
214
256
215
257
Calling `beginSend` on the sync client returns a `SyncPoller` object, which can be used to check on the status of the operation and retrieve the result once it finishes. The initial request to send an email starts as soon as the `beginSend` method is called. **Sending an email is a long running operation. Its important to note that the `getFinalResult()` method on the poller is a blocking operation until a terminal state (`SUCCESSFULLY_COMPLETED` or `FAILED`) is reached.** We recommend that you do manual polling at an interval that's appropriate for your application needs as demonstrated in the following sample.
@@ -257,48 +299,6 @@ catch (Exception exception)
257
299
}
258
300
```
259
301
260
-
## [Async Client](#tab/async-client)
261
-
262
-
Calling `beginSend` on the async client returns a `PollerFlux` object to which you can subscribe. The callbacks defined in the subscribe method are triggered once the email sending operation is complete. **Note that the initial request to send an email will not be sent until a subscriber is set up.**
System.out.println("Error occurred while sending email: "+ error.getMessage());
286
-
}
287
-
);
288
-
});
289
-
290
-
// In a real application, you might have a mechanism to keep the main thread alive.
291
-
// For this sample we will keep the main thread alive for 30 seconds to make sure the child thread has time to receive the SUCCESSFULLY_COMPLETED status.
0 commit comments