Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
cb5b385
Added activemq and tabbitmq private lambda java sam project
indranil-banerjee-aws Oct 13, 2025
01f0715
fixed ActiveMQ Private Lambda Java SAM project
indranil-banerjee-aws Oct 15, 2025
b581668
Fixed ActiveMQ Private Lambda Java SAM project
indranil-banerjee-aws Oct 16, 2025
87b3305
Fixed ActiveMQ Private Lambda Java SAM project
indranil-banerjee-aws Oct 18, 2025
e43e02f
Fixed ActiveMQ Private Lambda Java SAM Project
indranil-banerjee-aws Oct 18, 2025
61ede02
Revert "Fixed ActiveMQ Private Lambda Java SAM Project"
indranil-banerjee-aws Oct 18, 2025
2f7e2e9
Fixed ActiveMQ Private Lambda Java SAM Project
indranil-banerjee-aws Oct 18, 2025
275c1ac
Fixed ActiveMQ Private Lambda Java SAM Project
indranil-banerjee-aws Oct 20, 2025
a5b0fe9
Fixed ActiveMQ Private Lambda Java SAM Project
indranil-banerjee-aws Oct 20, 2025
7aad9e2
Added CloudFormation template and other artifacts for RabbitMQ Privat…
indranil-banerjee-aws Oct 21, 2025
f38ba2d
Fixed RabbitMQ Private Lambda Java SAM Project CFT
indranil-banerjee-aws Oct 21, 2025
fc84434
Fixed RabbitMQ Private Lambda Java SAM Project
indranil-banerjee-aws Oct 22, 2025
cd17336
Fixed RabbitMQ Private Lambda Java SAM Project CFT
indranil-banerjee-aws Oct 22, 2025
7c5328a
Fixed RabbitMQ Private Lambda Java SAM Project CFT
indranil-banerjee-aws Oct 22, 2025
7442d2d
Fixed CloudFormation template for RabbitMQ Private Lambda Java SAM Pr…
indranil-banerjee-aws Oct 22, 2025
b37e665
Fixed Readme files
indranil-banerjee-aws Oct 25, 2025
fbb33b9
Fixed Readme files
indranil-banerjee-aws Oct 25, 2025
224fbf0
Fixed Readme files
indranil-banerjee-aws Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
870 changes: 870 additions & 0 deletions activemq-private-lambda-java-sam/ActiveMQAndClientEC2.yaml

Large diffs are not rendered by default.

170 changes: 170 additions & 0 deletions activemq-private-lambda-java-sam/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

node_modules
npm-debug.log
package-lock.json
package
*out.yml
out.json
bucket-name.txt
target
build
.gradle
*.zip
bin
obj
Gemfile.lock
lib
__pycache__
*.pyc
.classpath
.factorypath
.project
.settings/*
.aws
.sam
.aws-sam
samconfig.toml
__init__.py
.DS_Store
.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazonaws.services.lambda.samples.events.activemq</groupId>
<artifactId>ActiveMQConsumer</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>A sample Lambda ActiveMQ consumer</name>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-dynamodb -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>1.12.445</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.7.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>5.15.8</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.15.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration></configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.amazonaws.services.lambda.samples.events.activemq;

import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Item;
import com.amazonaws.services.dynamodbv2.document.PutItemOutcome;
import com.amazonaws.services.dynamodbv2.document.Table;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.events.ActiveMQEvent;

public class DynamoDBUpdater {

String dynamoDBTableName;
AmazonDynamoDB client;
DynamoDB dynamoDB;
Table dynamoTable;


public DynamoDBUpdater(String dynamoDBTableName) {
super();
if (null == dynamoDBTableName) {
this.dynamoDBTableName = "ACTIVEMQ_LAMBDA_DYNAMO_TABLE";
} else {
this.dynamoDBTableName = dynamoDBTableName;
}
String AWS_SAM_LOCAL = System.getenv("AWS_SAM_LOCAL");
if (null == AWS_SAM_LOCAL) {
this.client = AmazonDynamoDBClientBuilder.standard().build();
} else {
this.client = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration("http://127.0.0.1:8000", "")).build();
this.dynamoDBTableName = "ACTIVEMQ_LAMBDA_DYNAMO_TABLE";
}
//this.client = AmazonDynamoDBClientBuilder.standard().build();
this.dynamoDB = new DynamoDB(client);
this.dynamoTable = dynamoDB.getTable(this.dynamoDBTableName);
}

public PutItemOutcome insertIntoDynamoDB(ActiveMQEvent.ActiveMQMessage msg, Person thisPerson, LambdaLogger logger, long receiveTime, String eventSource, String eventSourceARN) {
logger.log("Now inserting a row in DynamoDB for messageID = " + msg.getMessageID());
Item item = new Item();
item.withPrimaryKey("MessageID", msg.getMessageID());
item.withString("EventSource", eventSource);
item.withString("EventSourceARN", eventSourceARN);
item.withString("Firstname", thisPerson.getFirstname());
item.withString("Lastname", thisPerson.getLastname());
item.withString("Company", thisPerson.getCompany());
item.withString("Street", thisPerson.getStreet());
item.withString("City", thisPerson.getCity());
item.withString("County", thisPerson.getCounty());
item.withString("State", thisPerson.getState());
item.withString("Zip", thisPerson.getZip());
item.withString("Cellphone", thisPerson.getCellPhone());
item.withString("Homephone", thisPerson.getHomePhone());
item.withString("Email", thisPerson.getEmail());
item.withString("Website", thisPerson.getWebsite());
item.withString("CorrelationID", msg.getCorrelationID());
item.withString("MessageType", msg.getMessageType());
if (null == msg.getReplyTo()) {
item.withNull("ReplyTo");
} else {
item.withString("ReplyTo", msg.getReplyTo());
}
if (null == msg.getType()) {
item.withNull("Type");
} else {
item.withString("Type", msg.getType());
}
item.withLong("BrokerInTime", msg.getBrokerInTime());
item.withLong("BrokerOutTime", msg.getBrokerOutTime());
item.withInt("DeliveryMode", msg.getDeliveryMode());
item.withLong("Expiration", msg.getExpiration());
item.withInt("Priority", msg.getPriority());
item.withLong("TimeStamp", msg.getTimestamp());
item.withString("Queue", msg.getDestination().getPhysicalName());
item.withBoolean("WhetherRedelivered", msg.getRedelivered());
item.withLong("ReceiveTime", receiveTime);
logger.log("Now done inserting a row in DynamoDB for messageID = " + msg.getMessageID());
return dynamoTable.putItem(item);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//Lambda Runtime delivers a batch of messages to the lambda function
//Each batch of messages has two fields EventSource and EventSourceARN
//Each batch of messages also has a field called Records
//The Records is a map with multiple keys and values
//Each key is a combination of the Topic Name and the Partition Number
//One batch of messages can contain messages from multiple partitions

/*
To simplify representing a batch of Kafka messages as a list of messages
We have created a Java class called KafkaMessage under the models package
Here we are mapping the structure of an incoming Kafka event to a list of
objects of the KafkaMessage class
*/

package com.amazonaws.services.lambda.samples.events.activemq;

import java.util.Base64;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.ActiveMQEvent;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

// Handler value: example.HandlerSQS
public class HandlerActiveMQ implements RequestHandler<ActiveMQEvent, String>{
String dynamoDBTableName = System.getenv("DYNAMO_DB_TABLE");
DynamoDBUpdater ddbUpdater = new DynamoDBUpdater(dynamoDBTableName);
boolean addToDynamoDB;
ObjectMapper objectMapper = new ObjectMapper();
@Override
public String handleRequest(ActiveMQEvent event, Context context)
{
LambdaLogger logger = context.getLogger();
logger.log("Begin Event *************");
try {
logger.log(objectMapper.writeValueAsString(event));
} catch (JsonProcessingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
logger.log("End Event ***************");
for(ActiveMQEvent.ActiveMQMessage msg : event.getMessages()){
try {
addToDynamoDB = true;
long currentTime = System.currentTimeMillis();
logger.log("Begin Message *************");
logger.log(objectMapper.writeValueAsString(msg));
logger.log("End Message ***************");
logger.log("Begin Message Body *************");
String base64EncodedData = msg.getData();
String decodedData = "";
if (null != base64EncodedData) {
byte[] decodedDataBytes = Base64.getDecoder().decode(base64EncodedData);
decodedData = new String(decodedDataBytes);
}
logger.log(decodedData);
logger.log("End Message Body ***************");
logger.log("EventSource = " + event.getEventSource());
logger.log("EventSourceARN = " + event.getEventSourceArn());
logger.log("CorrelationID = " + msg.getCorrelationID());
logger.log("MessageID = " + msg.getMessageID());
logger.log("MessageType = " + msg.getMessageType());
logger.log("ReplyTo = " + msg.getReplyTo());
logger.log("Type = " + msg.getType());
logger.log("BrokerInTime = " + msg.getBrokerInTime());
logger.log("BrokerOutTime = " + msg.getBrokerOutTime());
logger.log("DeliveryMode = " + msg.getDeliveryMode());
logger.log("Expiration = " + msg.getExpiration());
logger.log("Priority = " + msg.getPriority());
logger.log("TimeStamp = " + msg.getTimestamp());
logger.log("Queue = " + msg.getDestination().getPhysicalName());
logger.log("WhetherRedelivered = " + msg.getRedelivered());
Person thisPerson = objectMapper.readValue(decodedData, Person.class);
//Person thisPerson = gson.fromJson(decodedData, Person.class);
logger.log("This person = " + thisPerson.toJson());
String AWS_SAM_LOCAL = System.getenv("AWS_SAM_LOCAL");
if ((null == AWS_SAM_LOCAL) && (addToDynamoDB)) {
ddbUpdater.insertIntoDynamoDB(msg, thisPerson, logger, currentTime, event.getEventSource(), event.getEventSourceArn());
}
} catch (Exception e) {
logger.log("An exception happened - " + e.getMessage());
return "500";
}
}
return "200";
}
}
Loading