int-aws: s3-outbound-channel-adapter или int-aws: s3-outbound-gateway не выдает никакой ошибки, если на уровне сегмента нет прав доступа - PullRequest
0 голосов
/ 16 мая 2019

Я столкнулся с одной проблемой как в int-aws: s3-outbound-gateway, так и в int-aws: s3-outbound-channel-adapter. Проблема в том, что если у меня нет разрешения на доступ к корзине, которое уже настроено как целевая корзина, адаптер должен выдать ошибку времени выполнения в консоли, но я не получаю никакой ошибки в консоли, и файлы не перемещаются в соответствующий пункт назначения. Не могли бы вы дать совет по этому вопросу

     <int-aws:s3-outbound-channel-adapter 
        id="moverId"
        channel="ChannelGateway" 
        transfer-manager="tf"
        bucket-expression="bucketName"
        key-expression="headers.file_name"
        command="UPLOAD">
    <int-aws:request-handler-advice-chain>
        <ref bean="retryAdvice" />
    </int-aws:request-handler-advice-chain>
</int-aws:s3-outbound-channel-adapter>

1 Ответ

0 голосов
/ 16 мая 2019

Вы не получаете никаких ошибок, потому что такая загрузка - асинхронная операция.

S3MessageHandler полностью основан на AWS S3 TransferManager. И когда мы загружаем файл в удаленное ведро, это делается с помощью этой операции:

/**
 * <p>
 * Schedules a new transfer to upload data to Amazon S3. This method is
 * non-blocking and returns immediately (i.e. before the upload has
 * finished).
 * </p>
 * <p>
 * Use the returned <code>Upload</code> object to query the progress of the
 * transfer, add listeners for progress events, and wait for the upload to
 * complete.
 * </p>
 * <p>
 * If resources are available, the upload will begin immediately. Otherwise,
 * the upload is scheduled and started as soon as resources become
 * available.
 * </p>
 * <p>
 * If you are uploading <a href="http://aws.amazon.com/kms/">AWS
 * KMS</a>-encrypted objects, you need to specify the correct region of the
 * bucket on your client and configure AWS Signature Version 4 for added
 * security. For more information on how to do this, see
 * http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#
 * specify-signature-version
 * </p>
 *
 * @param putObjectRequest
 *            The request containing all the parameters for the upload.
 * @param progressListener
 *            An optional callback listener to receive the progress of the
 *            upload.
 *
 * @return A new <code>Upload</code> object to use to check the state of the
 *         upload, listen for progress notifications, and otherwise manage
 *         the upload.
 *
 * @throws AmazonClientException
 *             If any errors are encountered in the client while making the
 *             request or handling the response.
 * @throws AmazonServiceException
 *             If any errors occurred in Amazon S3 while processing the
 *             request.
 */
public Upload upload(final PutObjectRequest putObjectRequest,
        final S3ProgressListener progressListener)

Обратите внимание на второй аргумент, если этот метод: S3MessageHandler предоставляет такой хук для вашего варианта использования:

/**
 * Specify a {@link S3ProgressListener} for upload and download operations.
 * @param s3ProgressListener the {@link S3ProgressListener} to use.
 * @see MessageS3ProgressListener
 */
public void setProgressListener(S3ProgressListener s3ProgressListener) {

И вам нужно отследить там progressChanged(ProgressEvent progressEvent) для соответствующего ProgressEventType.

...