Skip to content

Commit

Permalink
Java Azure functions (#881)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Sabrina Juarez Garcia <[email protected]>
  • Loading branch information
sjuarezgx and Sabrina Juarez Garcia authored Jan 9, 2025
1 parent 03572ae commit 08a4b8d
Show file tree
Hide file tree
Showing 85 changed files with 6,225 additions and 670 deletions.
6 changes: 6 additions & 0 deletions gxawsserverless/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gxserverlesscommon</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import com.genexus.ApplicationContext;
import com.genexus.ModelContext;
import com.genexus.cloud.serverless.*;
import com.genexus.cloud.serverless.model.EventMessageResponse;
import com.genexus.cloud.serverless.model.EventMessages;
import com.genexus.cloud.serverless.model.*;
import com.genexus.diagnostics.core.ILogger;
import com.genexus.specific.java.Connect;
import com.genexus.specific.java.LogManager;
Expand Down Expand Up @@ -64,7 +63,7 @@ private void initialize() throws Exception {
}

protected EventMessageResponse dispatchEvent(EventMessages eventMessages, String lambdaRawMessageBody) throws Exception {
String jsonStringMessages = Helper.toJSONString(eventMessages);
String jsonStringMessages = JSONHelper.toJSONString(eventMessages);

if (logger.isDebugEnabled()) {
logger.debug(String.format("dispatchEventMessages (%s) - serialized messages: %s", functionConfiguration.getEntryPointClassName(), jsonStringMessages));
Expand All @@ -74,7 +73,7 @@ protected EventMessageResponse dispatchEvent(EventMessages eventMessages, String
EventMessageResponse response = null;

try {
response = executor.execute(modelContext, eventMessages, lambdaRawMessageBody);
response = executor.execute(modelContext, eventMessages, null, lambdaRawMessageBody);
} catch (Exception e) {
logger.error(String.format("dispatchEventmessages - program '%s' execution error", entryPointClass.getName()), e);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.genexus.cloud.serverless.Helper;
import com.genexus.cloud.serverless.JSONHelper;
import com.genexus.cloud.serverless.model.*;
import com.genexus.cloud.serverless.exception.FunctionRuntimeException;
import com.genexus.cloud.serverless.model.EventMessage;
import com.genexus.cloud.serverless.model.EventMessageResponse;
import com.genexus.cloud.serverless.model.EventMessageSourceType;
import com.genexus.cloud.serverless.model.EventMessages;
import com.genexus.json.JSONObjectWrapper;
import org.apache.http.client.utils.DateUtils;

Expand All @@ -25,7 +22,7 @@ public LambdaEventBridgeHandler(String entryPointClassName) throws Exception {

@Override
public String handleRequest(Map<String, Object> stringObjectMap, Context context) {
String jsonEventRaw = Helper.toJSONString(stringObjectMap);
String jsonEventRaw = JSONHelper.toJSONString(stringObjectMap);

logger.debug("handleRequest started with event: " + jsonEventRaw);

Expand All @@ -44,7 +41,7 @@ public String handleRequest(Map<String, Object> stringObjectMap, Context context
msgItem.setMessageData(new JSONObjectWrapper(jsonEventRaw).getJSONObject("detail").toString());
}
for (Map.Entry<String, Object> entry : stringObjectMap.entrySet()) {
Helper.addEventMessageProperty(msgItem, entry.getKey(), entry.getValue().toString());
JSONHelper.addEventMessageProperty(msgItem, entry.getKey(), entry.getValue().toString());
}
msgs.add(msgItem);
response = dispatchEvent(msgs, jsonEventRaw);
Expand All @@ -63,6 +60,6 @@ public String handleRequest(Map<String, Object> stringObjectMap, Context context
logger.error(String.format("Messages were not handled. Error: %s", response.getErrorMessage()));
throw new RuntimeException(response.getErrorMessage());
}
return Helper.toJSONString(response);
return JSONHelper.toJSONString(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
import com.genexus.cloud.serverless.*;
import com.genexus.cloud.serverless.model.EventMessageProperty;
import com.genexus.cloud.serverless.model.EventMessage;
import com.genexus.cloud.serverless.model.EventMessageResponse;
import com.genexus.cloud.serverless.model.EventMessageSourceType;
import com.genexus.cloud.serverless.model.EventMessages;
import com.genexus.cloud.serverless.model.*;

import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -64,7 +60,7 @@ public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) {
String errorMessage;

try {
EventMessageResponse response = dispatchEvent(msgs, Helper.toJSONString(sqsEvent));
EventMessageResponse response = dispatchEvent(msgs, JSONHelper.toJSONString(sqsEvent));
wasHandled = !response.hasFailed();
errorMessage = response.getErrorMessage();
} catch (Exception e) {
Expand Down

This file was deleted.

Loading

0 comments on commit 08a4b8d

Please sign in to comment.