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
I am trying to send batch of messages using ms graph.
I tried to execute this code and it worked correctly.
public static void main(String[] args) throws IOException
{
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("xxx")
.clientSecret("xxx")
.tenantId("xxx")
.build();
GraphServiceClient graphServiceClient = new GraphServiceClient(clientSecretCredential,"https://graph.microsoft.com/.default");
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
Message message1 = new Message();
message1.setSubject("sub1");
ItemBody body1 = new ItemBody();
body1.setContentType(BodyType.Text);
body1.setContent( "body1");
message1.setBody(body1);
Recipient recipient1 = new Recipient();
EmailAddress emailAddress1 = new EmailAddress();
emailAddress1.setAddress("xxx@gmail.com");
recipient1.setEmailAddress(emailAddress1);
message1.setToRecipients(List.of(recipient1));
SendMailPostRequestBody sendMailPostRequestBody1 = new SendMailPostRequestBody();
sendMailPostRequestBody1.setMessage(message1);
RequestInformation requestInformation1 =
graphServiceClient.users()
.byUserId("xxx")
.sendMail()
.toPostRequestInformation(sendMailPostRequestBody1);
batchRequestContent.addBatchRequestStep(requestInformation1);
Message message2 = new Message();
message2.setSubject("sub2");
ItemBody body2 = new ItemBody();
body2.setContentType(BodyType.Text);
body2.setContent("body2");
message2.setBody(body2);
Recipient recipient2 = new Recipient();
EmailAddress emailAddress2 = new EmailAddress();
emailAddress2.setAddress("xxx@gmail.com");
recipient2.setEmailAddress(emailAddress2);
message2.setToRecipients(List.of(recipient2));
SendMailPostRequestBody sendMailPostRequestBody2 = new SendMailPostRequestBody();
sendMailPostRequestBody2.setMessage(message2);
RequestInformation requestInformation2 =
graphServiceClient.users()
.byUserId("xxx")
.sendMail()
.toPostRequestInformation(sendMailPostRequestBody2);
batchRequestContent.addBatchRequestStep(requestInformation2);
graphServiceClient.getBatchRequestBuilder().post(batchRequestContent, null);
System.out.println("hello");
}
But than I added more symbols to message body and executed code again. It didn't print "hello" and recipient didn't get emails.
I tried to debug this case and found out that code execution is stucked in endless loop in PipedInputStream#awaitSpace.
What is the reason of such behavior ? Is there any way to fix it ?
This is the chunk of code which doesn't work. I just added more symbols to body1 and body2.
public static void main(String[] args) throws IOException
{
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("xxx")
.clientSecret("xxx")
.tenantId("xxx")
.build();
GraphServiceClient graphServiceClient = new GraphServiceClient(clientSecretCredential,"https://graph.microsoft.com/.default");
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
Message message1 = new Message();
message1.setSubject("sub1");
ItemBody body1 = new ItemBody();
body1.setContentType(BodyType.Text);
body1.setContent( "body1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");
message1.setBody(body1);
Recipient recipient1 = new Recipient();
EmailAddress emailAddress1 = new EmailAddress();
emailAddress1.setAddress("xxx@gmail.com");
recipient1.setEmailAddress(emailAddress1);
message1.setToRecipients(List.of(recipient1));
SendMailPostRequestBody sendMailPostRequestBody1 = new SendMailPostRequestBody();
sendMailPostRequestBody1.setMessage(message1);
RequestInformation requestInformation1 =
graphServiceClient.users()
.byUserId("xxx")
.sendMail()
.toPostRequestInformation(sendMailPostRequestBody1);
batchRequestContent.addBatchRequestStep(requestInformation1);
Message message2 = new Message();
message2.setSubject("sub2");
ItemBody body2 = new ItemBody();
body2.setContentType(BodyType.Text);
body2.setContent("body2wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww");
message2.setBody(body2);
Recipient recipient2 = new Recipient();
EmailAddress emailAddress2 = new EmailAddress();
emailAddress2.setAddress("xxx@gmail.com");
recipient2.setEmailAddress(emailAddress2);
message2.setToRecipients(List.of(recipient2));
SendMailPostRequestBody sendMailPostRequestBody2 = new SendMailPostRequestBody();
sendMailPostRequestBody2.setMessage(message2);
RequestInformation requestInformation2 =
graphServiceClient.users()
.byUserId("xxx")
.sendMail()
.toPostRequestInformation(sendMailPostRequestBody2);
batchRequestContent.addBatchRequestStep(requestInformation2);
graphServiceClient.getBatchRequestBuilder().post(batchRequestContent, null);
System.out.println("hello");
}
Expected behavior
I expect that this chunk of code will be executed correctly and two messages will be delivered to recipient.
public static void main(String[] args) throws IOException
{
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("xxx")
.clientSecret("xxx")
.tenantId("xxx")
.build();
GraphServiceClient graphServiceClient = new GraphServiceClient(clientSecretCredential,"https://graph.microsoft.com/.default");
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
Message message1 = new Message();
message1.setSubject("sub1");
ItemBody body1 = new ItemBody();
body1.setContentType(BodyType.Text);
body1.setContent( "body1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");
message1.setBody(body1);
Recipient recipient1 = new Recipient();
EmailAddress emailAddress1 = new EmailAddress();
emailAddress1.setAddress("xxx@gmail.com");
recipient1.setEmailAddress(emailAddress1);
message1.setToRecipients(List.of(recipient1));
SendMailPostRequestBody sendMailPostRequestBody1 = new SendMailPostRequestBody();
sendMailPostRequestBody1.setMessage(message1);
RequestInformation requestInformation1 =
graphServiceClient.users()
.byUserId("xxx")
.sendMail()
.toPostRequestInformation(sendMailPostRequestBody1);
batchRequestContent.addBatchRequestStep(requestInformation1);
Message message2 = new Message();
message2.setSubject("sub2");
ItemBody body2 = new ItemBody();
body2.setContentType(BodyType.Text);
body2.setContent("body2wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww");
message2.setBody(body2);
Recipient recipient2 = new Recipient();
EmailAddress emailAddress2 = new EmailAddress();
emailAddress2.setAddress("xxx@gmail.com");
recipient2.setEmailAddress(emailAddress2);
message2.setToRecipients(List.of(recipient2));
SendMailPostRequestBody sendMailPostRequestBody2 = new SendMailPostRequestBody();
sendMailPostRequestBody2.setMessage(message2);
RequestInformation requestInformation2 =
graphServiceClient.users()
.byUserId("xxx")
.sendMail()
.toPostRequestInformation(sendMailPostRequestBody2);
batchRequestContent.addBatchRequestStep(requestInformation2);
graphServiceClient.getBatchRequestBuilder().post(batchRequestContent, null);
System.out.println("hello");
}
How to reproduce
execute code with any correct credentials and email adderesses
public static void main(String[] args) throws IOException
{
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("xxx")
.clientSecret("xxx")
.tenantId("xxx")
.build();
GraphServiceClient graphServiceClient = new GraphServiceClient(clientSecretCredential,"https://graph.microsoft.com/.default");
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
Message message1 = new Message();
message1.setSubject("sub1");
ItemBody body1 = new ItemBody();
body1.setContentType(BodyType.Text);
body1.setContent( "body1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");
message1.setBody(body1);
Recipient recipient1 = new Recipient();
EmailAddress emailAddress1 = new EmailAddress();
emailAddress1.setAddress("xxx@gmail.com");
recipient1.setEmailAddress(emailAddress1);
message1.setToRecipients(List.of(recipient1));
SendMailPostRequestBody sendMailPostRequestBody1 = new SendMailPostRequestBody();
sendMailPostRequestBody1.setMessage(message1);
RequestInformation requestInformation1 =
graphServiceClient.users()
.byUserId("xxx")
.sendMail()
.toPostRequestInformation(sendMailPostRequestBody1);
batchRequestContent.addBatchRequestStep(requestInformation1);
Message message2 = new Message();
message2.setSubject("sub2");
ItemBody body2 = new ItemBody();
body2.setContentType(BodyType.Text);
body2.setContent("body2wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww");
message2.setBody(body2);
Recipient recipient2 = new Recipient();
EmailAddress emailAddress2 = new EmailAddress();
emailAddress2.setAddress("xxx@gmail.com");
recipient2.setEmailAddress(emailAddress2);
message2.setToRecipients(List.of(recipient2));
SendMailPostRequestBody sendMailPostRequestBody2 = new SendMailPostRequestBody();
sendMailPostRequestBody2.setMessage(message2);
RequestInformation requestInformation2 =
graphServiceClient.users()
.byUserId("xxx")
.sendMail()
.toPostRequestInformation(sendMailPostRequestBody2);
batchRequestContent.addBatchRequestStep(requestInformation2);
graphServiceClient.getBatchRequestBuilder().post(batchRequestContent, null);
System.out.println("hello");
}
Describe the bug
I am trying to send batch of messages using ms graph.
I tried to execute this code and it worked correctly.
public static void main(String[] args) throws IOException
{
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("xxx")
.clientSecret("xxx")
.tenantId("xxx")
.build();
GraphServiceClient graphServiceClient = new GraphServiceClient(clientSecretCredential,"https://graph.microsoft.com/.default");
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
But than I added more symbols to message body and executed code again. It didn't print "hello" and recipient didn't get emails.
I tried to debug this case and found out that code execution is stucked in endless loop in PipedInputStream#awaitSpace.
What is the reason of such behavior ? Is there any way to fix it ?
This is the chunk of code which doesn't work. I just added more symbols to body1 and body2.
public static void main(String[] args) throws IOException
{
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("xxx")
.clientSecret("xxx")
.tenantId("xxx")
.build();
GraphServiceClient graphServiceClient = new GraphServiceClient(clientSecretCredential,"https://graph.microsoft.com/.default");
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
Expected behavior
I expect that this chunk of code will be executed correctly and two messages will be delivered to recipient.
public static void main(String[] args) throws IOException
{
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("xxx")
.clientSecret("xxx")
.tenantId("xxx")
.build();
GraphServiceClient graphServiceClient = new GraphServiceClient(clientSecretCredential,"https://graph.microsoft.com/.default");
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
How to reproduce
execute code with any correct credentials and email adderesses
public static void main(String[] args) throws IOException
{
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("xxx")
.clientSecret("xxx")
.tenantId("xxx")
.build();
GraphServiceClient graphServiceClient = new GraphServiceClient(clientSecretCredential,"https://graph.microsoft.com/.default");
BatchRequestContent batchRequestContent = new BatchRequestContent(graphServiceClient);
SDK Version
6.13.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```The text was updated successfully, but these errors were encountered: