0

我正在使用亚马逊data pipeline来自动化一些shell活动。每天运行一次。所以,我正在配置亚马逊SNS,让我知道shell活动的最后一次运行是成功还是失败。如果,失败,然后通过电子邮件向我发送失败的原因。

因此,我能够配置SNS用于向我发送邮件。但是,我应该如何配置消息部分,SNS以便在失败的情况下,它会向我发送确切的错误?另外,如果成功,请向我发送 status SUCCESS

4

2 回答 2

0

您可以尝试使用节点引用来引用添加操作的对象http://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-pipeline-expressions.html显示了如何执行此操作。

于 2013-11-15T21:26:42.633 回答
0

好的,这是我工作的 Dynamo -> S3 导入。 https://gist.github.com/osvadimos/2954ce4c0f7fc249594c999822e639f2

关于你的问题。首先你必须创建失败/成功对象

public static PipelineObject getSNSFailActivity() {
    String name = "FailureNotify";
    String id = "FailureNotify";

    Field type = new Field()
            .withKey("type")
            .withStringValue("SnsAlarm");

    Field topicArn = new Field()
            .withKey("topicArn")
            .withStringValue("#{myTopicFail}");

    Field role = new Field()
            .withKey("role")
            .withStringValue("DataPipelineDefaultRole");

    Field subject = new Field()
            .withKey("subject")
            .withStringValue("FAIL: #{node.@scheduledStartTime}");

    Field message = new Field()
            .withKey("message")
            .withStringValue("#{myDDBTableName}");


    List<Field> fieldsList = Lists.newArrayList(type,
            role,
            topicArn,
            subject,
            message);

    return new PipelineObject()
            .withName(name)
            .withId(id)
            .withFields(fieldsList);
}

您必须将失败/成功对象的引用添加到您的 S3BackupLocation 对象

public static PipelineObject getS3BackupLocation() {
    String name = "S3BackupLocation";
    String id = "S3BackupLocation";

    Field type = new Field()
            .withKey("type")
            .withStringValue("S3DataNode");
    Field directoryPath = new Field()
            .withKey("directoryPath")
            .withStringValue("#{myOutputS3Location}#{format(@scheduledStartTime, 'YYYY-MM-dd-HH-mm-ss')}");
    Field onFail = new Field()
            .withKey("onFail")
            .withRefValue("FailureNotify");
    Field onSuccess = new Field()
            .withKey("onSuccess")
            .withRefValue("SuccessNotify");

    List<Field> fieldsList = Lists.newArrayList(type,
            directoryPath,
            onFail,
            onSuccess);

    return new PipelineObject()
            .withName(name)
            .withId(id)
            .withFields(fieldsList);
}
于 2016-08-03T07:24:03.170 回答