I have a python script which connects to AWS MQ and collect message. All my connections are perfectly aligned and Execution result is success. But result returned by my function execution is "null". Updated error logs:-
{
"errorType": "ConnectFailedException",
"stackTrace": [
" File \"/var/task/one_purchasing.py\", line 21, in lambda_handler\n conn.connect(login='test_mq', passcode='test_secure_mq',wait=True)\n",
" File \"/var/task/stomp/connect.py\", line 164, in connect\n Protocol11.connect(self, *args, **kwargs)\n",
" File \"/var/task/stomp/protocol.py\", line 340, in connect\n self.transport.wait_for_connection()\n",
" File \"/var/task/stomp/transport.py\", line 327, in wait_for_connection\n raise exception.ConnectFailedException()\n"
]
}
Updated Python Lambda function:-
import time
import boto3
import stomp
import json
kinesis_client = boto3.client('kinesis')
class Listener(stomp.ConnectionListener):
def on_error(self, headers, message):
print('received an error "%s"' % message)
kinesis_client.put_record(
StreamName='OnePurchasing',
Data=u'{}\r\n'.format(message).encode('utf-8'),
PartitionKey='0'
)
def on_message(self, headers, message):
print('received a message "%s"' % message)
def lambda_handler(event, context):
conn = stomp.Connection(host_and_ports=[('b-fa99d7c5-4714-4441-8166-47aae158281a-1.mq.eu-central-1.amazonaws.com', 61614)])
lst = Listener()
conn.set_listener('Listener', lst)
conn.set_ssl(for_hosts=[('b-fa99d7c5-4714-4441-8166-47aae158281a-1.mq.eu-central-1.amazonaws.com', 61614)])
conn.start()
print('CONNECTION Started')
conn.connect(login='test_mq', passcode='test_secure_mq',wait=True)
print('CONNECTION established')
conn.subscribe(destination='/queue/OnePurchasing', id=1, ack='auto')
print('CONNECTION Subscribed')
time.sleep(10)
conn.disconnect()
return
Could anyone tell me how can I debug more to get the message from MQ
MQ URL message screen shot