【问题标题】:int-aws:s3-outbound-channel-adapter or int-aws:s3-outbound-gateway is not throwing any error when there is no access permission at bucket level当存储桶级别没有访问权限时,int-aws:s3-outbound-channel-adapter 或 int-aws:s3-outbound-gateway 不会引发任何错误
【发布时间】:2019-05-16 10:42:20
【问题描述】:

我在 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>

【问题讨论】:

    标签: spring-boot spring-integration spring-integration-aws


    【解决方案1】:

    您不会收到任何错误,因为这样的上传是一个异步操作。

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-28
      • 1970-01-01
      • 2015-07-08
      • 2016-01-27
      • 1970-01-01
      • 2015-10-18
      • 2013-09-28
      相关资源
      最近更新 更多