microsoftgraph / microsoftgraph/msgraph-sdk-java
Concurrent requests to send emails will generate duplicate emails, and the number does not match.
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Java
- Star
- 444
- Fork
- 154
- Merge trung bình
- 18 giờ 28 phút
- Pull request đã merge (30 ngày)
- 4
Mô tả
Hello!
I used Postman to iterate 160 times to send emails, and actually received 160+ emails. The number of emails received is random and does not match the number, which means duplicate emails are generated.
@PostMapping("/test") public void SysEmailController() { GraphEmailSender.testInfo(); }
`
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.microsoft.graph.models.EmailAddress;
import com.microsoft.graph.models.ItemBody;
import com.microsoft.graph.models.Message;
import com.microsoft.graph.models.Recipient;
import com.microsoft.graph.serviceclient.GraphServiceClient;
import com.microsoft.graph.users.item.sendmail.SendMailPostRequestBody;
import java.util.Collections;
import java.util.List;
public class GraphEmailSender {
// 配置参数
private static final String CLIENT_ID = "";
private static final String CLIENT_SECRET = "";
private static final String TENANT_ID = "";
private static final String SENDER_EMAIL = "";
private static final String[] SCOPES = new String[] { "https://graph.microsoft.com/.default" };
private static GraphServiceClient graphClient;
static {
try {
final ClientSecretCredential credential = new ClientSecretCredentialBuilder()
.clientId(CLIENT_ID)
.tenantId(TENANT_ID)
.clientSecret(CLIENT_SECRET)
.build();
if (null == credential) {
throw new Exception("Unexpected error");
}
graphClient = new GraphServiceClient(credential, SCOPES);
} catch (Exception e) {
System.err.println("init GraphServiceClient error: " + e.getMessage());
e.printStackTrace();
}
}
public static void testInfo() {
try {
Message message = new Message();
message.setSubject("test mail - Microsoft Graph API");
ItemBody body = new ItemBody();
body.setContent("Microsoft Graph API mail。");
message.setBody(body);
Recipient recipient = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("");
recipient.setEmailAddress(emailAddress);
List<Recipient> recipients = Collections.singletonList(recipient);
message.setToRecipients(recipients);
SendMailPostRequestBody sendMailPostRequestBody =
new SendMailPostRequestBody();
sendMailPostRequestBody.setMessage(message);
//
graphClient.users()
.byUserId(SENDER_EMAIL)
.sendMail()
.post(sendMailPostRequestBody);
System.out.println("send success!"+Thread.currentThread());
} catch (Exception e) {
System.err.println("error: " + e.getMessage());
e.printStackTrace();
}
}
}`
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với điểm vào được cung cấp @PostMapping("/test") và GraphEmailSender.testInfo(), sau đó tái hiện 160 yêu cầu sendMail đồng thời bằng mã client Microsoft Graph đã cho. So sánh số lượng yêu cầu và số lượng thư được gửi thành công để xác định hành vi nằm trong SDK hay trong ứng dụng gọi. Hoàn tất khi xác định được một lỗi SDK có thể tái hiện kèm theo một kiểm thử tập trung, hoặc có bằng chứng rõ ràng rằng không cần thay đổi SDK.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java
- Lĩnh vực
- api
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100