1
1
package com .genexus .cloud .serverless .azure .handler ;
2
+ import com .genexus .cloud .serverless .Helper ;
2
3
import com .genexus .cloud .serverless .model .*;
3
4
4
5
import com .microsoft .azure .functions .annotation .*;
9
10
import java .util .*;
10
11
11
12
public class AzureBlobStorageHandler extends AzureEventHandler {
13
+
14
+ EventMessages msgs = new EventMessages ();
15
+ String rawMessage ="" ;
16
+
12
17
public AzureBlobStorageHandler () throws Exception {
13
18
super ();
14
19
}
@@ -17,28 +22,35 @@ public void run(
17
22
@ BindingName ("name" ) String name ,
18
23
final ExecutionContext context
19
24
) throws Exception {
25
+
20
26
context .getLogger ().info ("GeneXus Blob Storage trigger handler. Function processed: " + context .getFunctionName () + " Invocation Id: " + context .getInvocationId ());
27
+ setupServerlessMappings (context .getFunctionName ());
21
28
22
- EventMessages msgs = new EventMessages ();
23
- EventMessage msg = new EventMessage ();
24
- msg .setMessageId (context .getInvocationId ());
25
- msg .setMessageSourceType (EventMessageSourceType .BLOB );
29
+ switch (executor .getMethodSignatureIdx ()) {
30
+ case 0 :
26
31
27
- Instant nowUtc = Instant . now ();
28
- msg .setMessageDate ( Date . from ( nowUtc ));
29
- msg .setMessageData ( Base64 . getEncoder (). encodeToString ( content ) );
32
+ EventMessage msg = new EventMessage ();
33
+ msg .setMessageId ( context . getInvocationId ( ));
34
+ msg .setMessageSourceType ( EventMessageSourceType . BLOB );
30
35
31
- List <EventMessageProperty > msgAtts = msg .getMessageProperties ();
36
+ Instant nowUtc = Instant .now ();
37
+ msg .setMessageDate (Date .from (nowUtc ));
38
+ msg .setMessageData (Base64 .getEncoder ().encodeToString (content ));
32
39
33
- msgAtts .add (new EventMessageProperty ("Id" , context .getInvocationId ()));
34
- msgAtts .add (new EventMessageProperty ("name" , name ));
40
+ List <EventMessageProperty > msgAtts = msg .getMessageProperties ();
35
41
36
- msgs .add (msg );
42
+ msgAtts .add (new EventMessageProperty ("Id" , context .getInvocationId ()));
43
+ msgAtts .add (new EventMessageProperty ("name" , name ));
37
44
38
- setupServerlessMappings (context .getFunctionName ());
45
+ msgs .add (msg );
46
+ break ;
47
+ case 1 :
48
+ case 2 :
49
+ rawMessage = Base64 .getEncoder ().encodeToString (content );
50
+ }
39
51
40
52
try {
41
- EventMessageResponse response = dispatchEvent (msgs , Base64 . getEncoder (). encodeToString ( content ) );
53
+ EventMessageResponse response = dispatchEvent (msgs , rawMessage );
42
54
if (response .hasFailed ()) {
43
55
logger .error (String .format ("Messages were not handled. Error: %s" , response .getErrorMessage ()));
44
56
throw new RuntimeException (response .getErrorMessage ()); //Throw the exception so the runtime can Retry the operation.
@@ -47,6 +59,5 @@ public void run(
47
59
logger .error ("HandleRequest execution error" , e );
48
60
throw e ; //Throw the exception so the runtime can Retry the operation.
49
61
}
50
-
51
62
}
52
63
}
0 commit comments