Skip to content

Commit

Permalink
Fixed Java large payloads receive
Browse files Browse the repository at this point in the history
  • Loading branch information
jacMelloni committed Mar 5, 2019
1 parent f6e2f2e commit a65046d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Kfz24/Client/Aws/LargePayloadMessageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class LargePayloadMessageExtension
private const DEFAULT_LARGE_MESSAGE_SIZE_THRESHOLD = 250;
private const S3_BUCKET_NAME_MARKER = '-..s3BucketName..-';
private const S3_KEY_MARKER = '-..s3Key..-';
private const JAVA_S3_POINTER_STRING = 'com.amazon.sqs.javamessaging.MessageS3Pointer';

/**
* @var S3Client
Expand Down Expand Up @@ -154,7 +155,7 @@ public function deleteMessageFromS3(string $receiptHandle): void
public function messageS3PointerFromMessageBody(array $messageBody): ?MessageS3Pointer
{
if (!$this->messageBodyContainsMessageS3Pointer($messageBody)) {
return null;
return $this->fetchJavaMessageS3Pointer($messageBody);
}

$messageS3Pointer = new MessageS3Pointer();
Expand All @@ -164,6 +165,25 @@ public function messageS3PointerFromMessageBody(array $messageBody): ?MessageS3P
return $messageS3Pointer;
}

/**
* @param array $messageBody
*
* @return MessageS3Pointer|null
*/
public function fetchJavaMessageS3Pointer(array $messageBody): ?MessageS3Pointer
{
$messageS3Pointer = null;

if (isset($messageBody[0]) && $messageBody[0] === self::JAVA_S3_POINTER_STRING) {
$messageS3Pointer = new MessageS3Pointer();
$messageS3Pointer->setS3BucketName($messageBody[1]['s3BucketName']);
$messageS3Pointer->setS3Key($messageBody[1]['s3Key']);
}

return $messageS3Pointer;
}


/**
* @param string $receiptHandle
* @param MessageS3Pointer $messageS3Pointer
Expand Down

0 comments on commit a65046d

Please sign in to comment.