class SampleDataJmsMessageListener {

    @JmsListener(id = HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE,
        containerFactory = "jmsListenerContainerFactory",
        destination = HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE)
    public void processMessage(String payload, @Headers Map<Object, Object> allHeaders)
    {
        LOGGER.info("Message received from the JMS queue. jmsQueueName=\"{}\" jmsMessageHeaders=\"{}\" jmsMessagePayload={}",
            HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE, allHeaders, payload);

        try
        {
            // Process messages coming from S3 bucket.
            S3EventNotification s3EventNotification = S3EventNotification.parseJson(payload);
            String objectKey = URLDecoder.decode(s3EventNotification.getRecords().get(0).getS3().getObject().getKey(), CharEncoding.UTF_8);
            long fileSize = s3EventNotification.getRecords().get(0).getS3().getObject().getSizeAsLong();
            // parse the objectKey, it should be in the format of namespace/businessObjectDefinitionName/fileName
            String[] objectKeyArrays = objectKey.split("/");
            Assert.isTrue(objectKeyArrays.length == 3, String.format("S3 notification message %s is not in expected format", objectKey));

            String namespace = objectKeyArrays[0];
            String businessObjectDefinitionName = objectKeyArrays[1];
            String fileName = objectKeyArrays[2];
            String path = namespace + "/" + businessObjectDefinitionName + "/";
            BusinessObjectDefinitionSampleFileUpdateDto businessObjectDefinitionSampleFileUpdateDto =
                    new BusinessObjectDefinitionSampleFileUpdateDto(path, fileName, fileSize);

            String convertedNamespaece = convertS3KeyFormat(namespace);
            String convertedBusinessObjectDefinitionName = convertS3KeyFormat(businessObjectDefinitionName);

            BusinessObjectDefinitionKey businessObjectDefinitionKey =
                    new BusinessObjectDefinitionKey(convertedNamespaece, convertedBusinessObjectDefinitionName);
            try
            {
                businessObjectDefinitionService.updateBusinessObjectDefinitionEntitySampleFile(businessObjectDefinitionKey,
                        businessObjectDefinitionSampleFileUpdateDto);
            }
            catch (ObjectNotFoundException ex)
            {
                LOGGER.info("Failed to find the business object definition, next try the original namespace and business oject defination name " + ex);
                // if Business object definition is not found, use the original name space and bdef name
                businessObjectDefinitionKey = new BusinessObjectDefinitionKey(namespace, businessObjectDefinitionName);
                businessObjectDefinitionService.updateBusinessObjectDefinitionEntitySampleFile(businessObjectDefinitionKey,
                        businessObjectDefinitionSampleFileUpdateDto);
            }
        }
        catch (RuntimeException | IOException e)
        {
            LOGGER.error("Failed to process message from the JMS queue. jmsQueueName=\"{}\" jmsMessagePayload={}",
                    HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE, payload, e);
        }
    }

}