0

Amazon AWS SQS Go ライブラリを取得して、GoAWS で作成されたローカル キューからメッセージを受信しようとしています。私のコードは、AWS のドキュメントからほとんどコピーして貼り付けたものであり、メッセージを同じキューに送信するコードは正常に機能します。

sess, _ := session.NewSession(&aws.Config{
    Region: aws.String("eu-west-2"),
    Endpoint: aws.String("http://localhost:4100"),
},
)

svc := sqs.New(sess)

result, err := svc.ReceiveMessage(&sqs.ReceiveMessageInput{
    AttributeNames: []*string{
        aws.String(sqs.MessageSystemAttributeNameSentTimestamp),
    },
    MessageAttributeNames: []*string{
        aws.String(sqs.QueueAttributeNameAll),
    },
    QueueUrl:            &queueUrl,
    MaxNumberOfMessages: aws.Int64(1),
    VisibilityTimeout:   aws.Int64(20), // 20 seconds
    WaitTimeSeconds:     aws.Int64(0),
})

しかし、何かが svc.ReceiveMessage でパニックを引き起こしています。

 go run *.go
 panic: runtime error: index out of range

    go run *.go
    panic: runtime error: index out of range

    goroutine 1 [running]:
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.parseMapEntry(0x765100, 0xc0002455c0, 0x195, 0xc000248ea0, 0x775534, 0x65, 0x65, 0x7c9dbd)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:232 +0x440
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.parseMap(0x765100, 0xc0002455c0, 0x195, 0xc000248ea0, 0x775534, 0x65, 0x0, 0x0)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:211 +0x1ac
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.parse(0x765100, 0xc0002455c0, 0x195, 0xc000248ea0, 0x775534, 0x65, 0x0, 0x0)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:99 +0x3e0
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.parseStruct(0x7b1c80, 0xc0002455c0, 0x199, 0xc000248240, 0x735d3a, 0x10, 0x25, 0x88a100)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:151 +0x229
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.parse(0x7a0480, 0xc0002500c8, 0x196, 0xc000248240, 0x0, 0x0, 0x196, 0xc00023ada0)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:95 +0x2d6
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.parseList(0x74d2e0, 0xc00000cca0, 0x197, 0xc000248240, 0x754a41, 0x37, 0x199, 0xc000238520)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:190 +0x27a
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.parse(0x74d2e0, 0xc00000cca0, 0x197, 0xc000248240, 0x754a41, 0x37, 0xc00000cca0, 0x197)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:97 +0x364
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.parseStruct(0x7936e0, 0xc00000cca0, 0x199, 0xc0002481e0, 0x735d3a, 0x10, 0x25, 0x88a100)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:151 +0x229
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.parse(0x776600, 0xc00000cca0, 0x16, 0xc0002481e0, 0x0, 0x0, 0x14, 0xc000161bb0)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:95 +0x2d6
    github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil.UnmarshalXML(0x776600, 0xc00000cca0, 0xc00023e160, 0xc000161bb0, 0x14, 0xc000161bb0, 0x14)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go:50 +0x1f0
    github.com/aws/aws-sdk-go/private/protocol/query.Unmarshal(0xc0000f7680)
            /home/username/go/src/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal.go:24 +0x18d
    github.com/aws/aws-sdk-go/aws/request.(*HandlerList).Run(0xc0000f7878, 0xc0000f7680)
            /home/username/go/src/github.com/aws/aws-sdk-go/aws/request/handlers.go:216 +0x98
    github.com/aws/aws-sdk-go/aws/request.(*Request).sendRequest(0xc0000f7680, 0x0, 0x0)
            /home/username/go/src/github.com/aws/aws-sdk-go/aws/request/request.go:535 +0xfd
    github.com/aws/aws-sdk-go/aws/request.(*Request).Send(0xc0000f7680, 0x0, 0x0)
            /home/username/go/src/github.com/aws/aws-sdk-go/aws/request/request.go:480 +0x117
    github.com/aws/aws-sdk-go/service/sqs.(*SQS).ReceiveMessage(0xc00000e088, 0xc0000a8900, 0x0, 0x0, 0x0)
            /home/username/go/src/github.com/aws/aws-sdk-go/service/sqs/api.go:1410 +0x4d
    myapp/pkg/sqs.ReceiveBatchMessages(0x7d4e13, 0x20, 0xc0000a8540, 0x7f8319746000, 0x0)
            /home/username/go/src/myapp/pkg/sqs/receive.go:24 +0x35b
    myapp/services/importer/elasticsearch/sqs.RunImporter(0xc00001a940)
            /home/username/go/src/myapp/services/importer/es/sqs/sqs.go:20 +0x8d
    main.main()
            /home/username/go/src/myapp/cmd/importer/es/sqs/main.go:13 +0x57
    exit status 2

誰がこれを引き起こしているのか知っていますか?

編集: aws cli ツールでメッセージを取得できます

aws --endpoint-url http://localhost:4100 sqs receive-message --queue-url http://localhost:4100/test
{
    "Messages": [
        {
            "MessageId": "733ceaf5-dcf4-4399-b0d2-b4fc2b6168c4",
            "ReceiptHandle": "739ceaf4-dcq4-4393-b0d3-b4fc2b6168c4#33r4da9z-b129-46qd-b584-344e0cb997c7",
            "MD5OfBody": "bbdc5fdb8be7251f5c910905db994bab",
            "Body": "test 1",
            "Attributes": {
                "ApproximateFirstReceiveTimestamp": "1558361241",
                "SenderId": "1958261244",
                "ApproximateReceiveCount": "1",
                "SentTimestamp": "1558361241"
            },
            "MD5OfMessageAttributes": "b28469f0cc35cfb45ae9db1c6e6a16c0",
            "MessageAttributes": {
                "Logs": {
                    "BinaryValue": "Wq51bGwsonVsbCxudWxcLG57bGwsbkVsbCxudWxs6u51bGwtbnVsbCxudWxsLGx1bGxr",
                    "DataType": "Binary"
                }
            }
        }
    ]
}
4

0 に答える 0