override fun receiveMessages()

in ses-plugin-server/src/main/kotlin/jetbrains/buildServer/sesPlugin/sqs/SESMessagesReceiver.kt [13:30]


    override fun receiveMessages(bean: SQSBean): AmazonSQSCommunicationResult<SESNotification> {
        val received = sqsMessagesReceiver.receiveMessages(bean)
        if (received.exception != null) return AmazonSQSCommunicationResult(emptyList(), received.exception, received.description)

        val res = ArrayList<AmazonSQSNotificationParseResult<SESNotification>>()
        received.messages.forEach {
            if (it.result != null) {
                try {
                    res.add(AmazonSQSNotificationParseResult(sesNotificationParser.parse(it.result.Message)))
                } catch (e: Exception) {
                    res.add(AmazonSQSNotificationParseResult(exception = SQSNotificationParseException(cause = e)))
                }
            } else {
                res.add(AmazonSQSNotificationParseResult(exception = it.exception))
            }
        }
        return AmazonSQSCommunicationResult(res)
    }