我一直在尝试从存储在Amazon S3上的视频中检测面部,这些面部必须与包含要在视频中搜索的面部的集合进行匹配。
我已使用Amazon VideoDetect。
我的代码如下:

CreateCollection createCollection = new CreateCollection(collection);
createCollection.makeCollection();
AddFacesToCollection addFacesToCollection = new AddFacesToCollection(collection, bucketName, image);
addFacesToCollection.addFaces();
VideoDetect videoDetect = new VideoDetect(video, bucketName, collection);
videoDetect.CreateTopicandQueue();
try {
  videoDetect.StartFaceSearchCollection(bucketName, video, collection);
  if (videoDetect.GetSQSMessageSuccess())
    videoDetect.GetFaceSearchCollectionResults();
} catch (Exception e) {
  e.printStackTrace();
  return false;
}
videoDetect.DeleteTopicandQueue();
return true;


在StartFaceSearchCollection之前,一切似乎都可以正常工作,而且我正在获取一个jobId和一个队列。但是,当它试图四处获取GetSQSMessageSuccess时,它永远不会向我返回任何消息。
试图获取消息的代码是:

   ReceiveMessageRequest.Builder receiveMessageRequest = ReceiveMessageRequest.builder().queueUrl(sqsQueueUrl);
   messages = sqs.receiveMessage(receiveMessageRequest.build()).messages();


它具有存在的正确sqsQueueUrl。但是我没有收到任何消息。
超时给我这个例外:

software.amazon.awssdk.core.exception.SdkClientException: Unable to execute HTTP request: sqs.region.amazonaws.com
    at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:97)

Caused by: java.net.UnknownHostException: sqs.region.amazonaws.com


因此,除了SQSMessage之外,还有其他替代方法吗,我们可以通过其他方式跟踪/轮询jobId吗?还是我错过了什么?

最佳答案

使用有效的sqsQueueUrl for more接收SQS消息的简单工作代码段

ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(sqsQueueUrl);
final List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
for (final Message message : messages) {
    System.out.println("Message");
    System.out.println("  MessageId:     " + message.getMessageId());
    System.out.println("  ReceiptHandle: " + message.getReceiptHandle());
    System.out.println("  MD5OfBody:     " + message.getMD5OfBody());
    System.out.println("  Body:          " + message.getBody());
    for (final Entry<String, String> entry : message.getAttributes().entrySet()) {
        System.out.println("Attribute");
        System.out.println("  Name:  " + entry.getKey());
        System.out.println("  Value: " + entry.getValue());
    }
}
System.out.println();

关于java - 检测到Amazon s3上载的视频中的人脸时,SQSMessageSuccess中没有响应,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59748783/

10-10 11:58