简体   繁体   中英

AWS EventBridge Target Java Lambda function

I am using a Java lambda function to put a custom event to the AWS EventBridge. The target of this eventbridge is another Java lambda function. How to receive the Event in the target lambda function? I mean what is the input type in the handleRequest method I have to use? Tried using ScheduledEvent as an input type but it didn't work. Searched many EventBridge API documents but didn't get the details as how to receive the data in the Java lambda function from Eventbridge.

The below is an example for receiving the SQS Event. In the same way what type I should use for the events triggered from EventBridge?

@Override
  public String handleRequest(SQSEvent event, Context context)

I am able to access the Event as Map<String,Object>. The "detail" key in the map gives the actual values those are put in the Eventbridge.

You need to change you request handler from using RequestHandler<SQSEvent, String> to using RequestHandler<Map<String,String>, String> . This will also lead to additional changes in your class / functions.

EventBridge events (schedules or your events) will show up in the input as an json encoded string.

Personally, I find it easier to leverage the RequestStreamHandler defined in https://docs.aws.amazon.com/lambda/latest/dg/java-handler.html#java-handler-interfaces . There's also some sample code linked that you may find helpful around deserialization.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM