0
import AwsConfig;
import com.google.inject.Inject;
import io.reactivex.rxjava3.core.Completable;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import software.amazon.awssdk.services.sqs.SqsAsyncClient;
import software.amazon.awssdk.services.sqs.model.SendMessageRequest;


@Slf4j
@RequiredArgsConstructor(onConstructor = @__({@Inject}))
public class SQSClass {
  final AwsConfig awsConfig;
  SqsAsyncClient sqsClient = SqsAsyncClient.create();


  private String getUserRegisteredSqsArn() {
    return "https://sqs." + awsConfig.getRegion() + ".amazonaws.com/" + awsConfig.getAccountId() + "/my_queue" ;
  }

  public Completable publishMessage(String messageBody) {
    SendMessageRequest request = SendMessageRequest.builder()
        .queueUrl(getUserRegisteredSqsArn())
        .messageBody(messageBody)
        .build();
    return Completable.fromFuture(sqsClient.sendMessage(request));
  }
}

This is my piece of code that's used to dump a message into aws sqs.

I'm making a function call of this class like this SQSClass.publishMessage(MySQSMessage.toString()).subscribe(); And this call is blocking my event loop somehow. I'm unable to understand why this is a blocking call. can someone please help

venkatesh .b
  • 83
  • 1
  • 1
  • 7

0 Answers0