Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS gives us Amazon MQ but how can I trigger a Lambda?

Superb news about the Amazon MQ service but now the question arises on how I can trigger a Lambda function (Node.js) on a message on a specific Queue?

I was thinking if I somehow can get a SNS topic posted on a message PUT or some other trigger that can fire a Lambda to consume the message from the Queue...

Any suggestions?

like image 930
Anders Avatar asked Dec 06 '17 20:12

Anders


People also ask

How do I manually trigger AWS Lambda?

Invoke the Lambda function manually using sample Amazon S3 event data. On the Code tab, under Code source, choose the arrow next to Test, and then choose Configure test events from the dropdown list. In the Configure test event window, do the following: Choose Create new test event.

What can be used to automatically invoke an AWS Lambda function?

You can invoke Lambda functions directly using the Lambda console, a function URL HTTP(S) endpoint, the Lambda API, an AWS SDK, the AWS Command Line Interface (AWS CLI), and AWS toolkits.


2 Answers

There isn't a native way to do this. Amazon's managed ActiveMQ service is simply a managed deployment of ActiveMQ running in EC2. It has no integration with other services.

You'd need to write a queue consumer and have it running on a server and listening to the queue on ActiveMQ and publishing those messages to SNS or invoking the Lambda function directly via the Lambda API, etc.

(At least for now.)

like image 145
Michael - sqlbot Avatar answered Oct 22 '22 11:10

Michael - sqlbot


AWS recently announced

https://aws.amazon.com/about-aws/whats-new/2020/11/aws-lambda-supports-amazon-mq-apache-activemq-event-source/

We can now add Trigger as MQ in lambda. Then Configure

  • Broker url
  • Batch size
  • Queue Name
like image 39
sanket ghenand Avatar answered Oct 22 '22 11:10

sanket ghenand