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

查看:22
本文介绍了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.

推荐答案

可以参考这些示例来自 AWS 以形成请求.

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

或者,您可以在您的 java 代码中启用详细日志记录以查看请求.参考 thisthis 来自 AWS 的文档以启用详细日志记录.

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天全站免登陆