AWS SNS停止传递消息 [英] AWS SNS stopped delivering messages

查看:55
本文介绍了AWS SNS停止传递消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过JAVA从AWS SNS API发送SMS,该方法工作了两天,然后突然停止传递消息,但是来自API的响应为200 ok,带有正确的消息ID,但没有传递消息.我试图通过邮递员发布请求,以使问题更清晰,但找不到任何集合或请求签名.

I tried sending SMS from AWS SNS API through JAVA which worked for two days then suddenly stopped delivering messages but the response from API is 200 ok with a proper message ID without delivering messages. I am trying to post the request through postman to get more clarity of the issue but cannot find any collection or request signature.

`

public class SNS {
    public static void sendSMS(String phoneNumber,String message)
    {
        
        
        BasicAWSCredentials basicCred = new BasicAWSCredentials("XXXXXXXXXXX", "XXXXXXXXXXXXX");

        AmazonSNSClient snsClient = (AmazonSNSClient) AmazonSNSClientBuilder.standard()
                .withClientConfiguration(
                        new ClientConfiguration()
                        .withMaxErrorRetry(0)
                        .withConnectionTimeout(1000))
                .withCredentials(new AWSStaticCredentialsProvider(basicCred))
                .withRegion("us-east-1")
                .build();

        Map<String, MessageAttributeValue> smsAttributes = 
                new HashMap<String, MessageAttributeValue>();

        smsAttributes.put("AWS.SNS.SMS.SenderID", new MessageAttributeValue()
                .withStringValue("Sender") //The sender ID shown on the device.
                .withDataType("String"));      
        smsAttributes.put("AWS.SNS.SMS.SMSType", new MessageAttributeValue()
                .withStringValue("Transactional") //Sets the type to Transactional.
                .withDataType("String"));       

        sendSMSMessage(snsClient, message, phoneNumber, smsAttributes);
    }

    public static void sendSMSMessage(AmazonSNSClient snsClient, String message, 
            String phoneNumber, Map<String, MessageAttributeValue> smsAttributes) 
    {
        PublishResult result = snsClient.publish(new PublishRequest()
                .withMessage(message)
                .withPhoneNumber(phoneNumber)
                .withMessageAttributes(smsAttributes));
    }
    
    public static void main(String[] args) {
        sendSMS("+91XXXXXXXXXX", "Hi This is Test message from SNS");
    }
}`

我正在使用上面的代码,该代码给出200 O的响应以及请求和消息ID,但消息未传递.

I am using the above code which is giving 200 O in response along with request and message Id but the message is not delivered.

推荐答案

您可以引用这些示例来形成请求.

You can refer these examples from AWS to form the request.

或者,您可以在Java代码中启用详细日志记录以查看请求.请参阅文档以启用详细日志记录.

Alternative, you can enable verbose logging in your java code to see request. refer this or this document from AWS to enable verbose logging.

使用-debug true 选项执行aws cli以从aws sns发送短信,这还将在命令行上打印请求.

execute aws cli to send sms from aws sns with --debug true option, which will also print the request on command line.

这篇关于AWS SNS停止传递消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆