-
Notifications
You must be signed in to change notification settings - Fork 19
Queue API Implementation (AWS SQS) #582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
087f784
Initial implementation QueueAPI
ggallotti b576b3b
Refactoring
ggallotti 986968d
Add more unittest
ggallotti 258ab73
Add SDTs models.
ggallotti 023ec0d
Refacroting. More UnitTest. GeneXus API Implementation.
ggallotti a73f7eb
Missing Methods implementation
ggallotti abe1930
Add Queue Azure Maven Project
ggallotti 006b644
Project restructure
ggallotti 4ace819
DynamicExecute
ggallotti 569bffe
Merge branch 'master' into queue-api
ggallotti 5ac49f4
Minor refactoring
ggallotti 57f9e7b
Remove ununsed file
ggallotti 4024cfe
Merge branch 'queue-api' of https://github.com/genexuslabs/JavaClasse…
ggallotti 086d29a
Reformat code
ggallotti c64756a
Move folders to root
ggallotti 05cafc7
Added log and required http client impl
ggallotti 1907b86
Remvoe AWS dependency from Azure Project
ggallotti d62bba9
Bump AWS SDK Version
ggallotti 333a49b
Refactoring Pom version
ggallotti 824dbb2
Merge branch 'master' into queue-api
ggallotti 3aff46b
Use same AWS version as DynamoDB project
ggallotti a27a4e6
Maven dependencies
ggallotti db17b38
Merge branch 'master' into queue-api
ggallotti 0064bde
DeleteMessage Signature modification
ggallotti 58ba890
Merge branch 'master' into queue-api
ggallotti 9cb4760
Merge branch 'master' into queue-api
ggallotti 9c7fd77
Remove redundant isLevelEnabled when is not neccesrry
ggallotti 9b98346
Remove not needed dependency
ggallotti dcebb09
Merge branch 'master' into queue-api
ggallotti 678412f
Fix Issues after Gradle Build System
ggallotti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
common/src/main/java/com/genexus/services/ServiceConfigurationException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.genexus.services; | ||
|
|
||
| public class ServiceConfigurationException extends Throwable { | ||
| public ServiceConfigurationException(String errorMessage) { | ||
| super(errorMessage); | ||
| } | ||
| } |
91 changes: 91 additions & 0 deletions
91
common/src/main/java/com/genexus/services/ServiceSettingsReader.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| package com.genexus.services; | ||
|
|
||
| import com.genexus.diagnostics.core.ILogger; | ||
| import com.genexus.diagnostics.core.LogManager; | ||
|
|
||
| import com.genexus.util.Encryption; | ||
| import com.genexus.util.GXService; | ||
|
|
||
|
|
||
| public class ServiceSettingsReader { | ||
| private static ILogger logger = LogManager.getLogger(ServiceSettingsReader.class); | ||
|
|
||
| private GXService service; | ||
| private String name; | ||
| private String serviceTypeName; | ||
|
|
||
| public ServiceSettingsReader(String serviceType, String instanceName, GXService service) { | ||
| service = service; | ||
| name = instanceName; | ||
| serviceTypeName = serviceType; | ||
| } | ||
|
|
||
| public String getEncryptedPropertyValue(String propertyName, String alternativePropertyName) throws ServiceConfigurationException { | ||
| String value = getEncryptedPropertyValue(propertyName, alternativePropertyName, null); | ||
| if (value == null) { | ||
| String errorMessage = String.format("Service configuration error - Property name %s must be defined", resolvePropertyName(propertyName)); | ||
| logger.fatal(errorMessage); | ||
| throw new ServiceConfigurationException(errorMessage); | ||
| } | ||
| return value; | ||
| } | ||
|
|
||
| public String getEncryptedPropertyValue(String propertyName, String alternativePropertyName, String defaultValue) { | ||
| String encryptedOrUnEncryptedValue = getPropertyValue(propertyName, alternativePropertyName, defaultValue); | ||
| String decryptedValue = encryptedOrUnEncryptedValue; | ||
| if (encryptedOrUnEncryptedValue != null && encryptedOrUnEncryptedValue.length() > 0) { | ||
| try { | ||
| String decryptedTemp = Encryption.tryDecrypt64(encryptedOrUnEncryptedValue); | ||
| decryptedValue = (decryptedTemp != null) ? decryptedTemp : encryptedOrUnEncryptedValue; | ||
| } catch (Exception e) { | ||
| logger.warn("Could not decrypt property name: " + resolvePropertyName(propertyName)); | ||
| } | ||
| } | ||
| return decryptedValue; | ||
| } | ||
|
|
||
| public String getPropertyValue(String propertyName, String alternativePropertyName) throws ServiceConfigurationException { | ||
| String value = getPropertyValue(propertyName, alternativePropertyName, null); | ||
| if (value == null) { | ||
| String errorMessage = String.format("Service configuration error - Property name %s must be defined", resolvePropertyName(propertyName)); | ||
| logger.fatal(errorMessage); | ||
| throw new ServiceConfigurationException(errorMessage); | ||
| } | ||
| return value; | ||
| } | ||
|
|
||
| public String getPropertyValue(String propertyName, String alternativePropertyName, String defaultValue) { | ||
| String value = readFromEnvVars(propertyName, alternativePropertyName); | ||
| if (value != null) { | ||
| return value; | ||
| } | ||
| String resolvedPtyName = resolvePropertyName(propertyName); | ||
| if (service != null) { | ||
| value = this.service.getProperties().get(resolvedPtyName); | ||
| if (value == null || value.length() == 0) { | ||
| value = this.service.getProperties().get(alternativePropertyName); | ||
| } | ||
| } | ||
| return value != null ? value : defaultValue; | ||
| } | ||
|
|
||
| private String readFromEnvVars(String propertyName, String alternativePropertyName) { | ||
| if (service != null && !service.getAllowOverrideWithEnvVarSettings()) { | ||
| return null; | ||
| } | ||
|
|
||
| String value = System.getenv(resolvePropertyName(propertyName)); | ||
| if (value == null) { | ||
| value = System.getenv(alternativePropertyName); | ||
| } | ||
| return value; | ||
| } | ||
|
|
||
| private String resolvePropertyName(String propertyName) { | ||
| return String.format("%s_%s_%s", serviceTypeName, name, propertyName); | ||
| } | ||
|
|
||
| public String getName() { | ||
| return this.name; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <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/xsd/maven-4.0.0.xsd"> | ||
| <parent> | ||
| <artifactId>parent</artifactId> | ||
| <groupId>com.genexus</groupId> | ||
| <version>${revision}${changelist}</version> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>gxqueue</artifactId> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>gxclassR</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>gxcommon</artifactId> | ||
| <version>${project.version}</version> | ||
| <scope>compile</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <finalName>gxqueue</finalName> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jar-plugin</artifactId> | ||
| <version>3.1.1</version> | ||
| <configuration> | ||
| <archive> | ||
| <manifest> | ||
| <addClasspath>false</addClasspath> | ||
| </manifest> | ||
| <manifestEntries> | ||
| <Build-Time>${maven.build.timestamp}</Build-Time> | ||
| <Build-User>GeneXus</Build-User> | ||
| <Build-Java>${java.version}</Build-Java> | ||
| <Build-OS>${os.name}</Build-OS> | ||
| <Build-Label>${project.version}</Build-Label> | ||
| <Build-Path>${basedir}</Build-Path> | ||
| </manifestEntries> | ||
| </archive> | ||
| <excludes> | ||
| <exclude>**/com/genexusmessaging/**</exclude> | ||
| </excludes> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| </project> |
93 changes: 93 additions & 0 deletions
93
gxqueue/src/main/java/com/genexus/messaging/queue/Convert.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| package com.genexus.messaging.queue; | ||
|
|
||
| import com.genexus.GXBaseCollection; | ||
|
|
||
| import com.genexus.messaging.queue.model.DeleteMessageResult; | ||
| import com.genexus.messaging.queue.model.MessageQueueOptions; | ||
| import com.genexus.messaging.queue.model.SendMessageResult; | ||
| import com.genexus.messaging.queue.model.SimpleQueueMessage; | ||
| import com.genexus.util.GXProperties; | ||
| import com.genexus.util.GXProperty; | ||
| import com.genexusmessaging.genexusmessagingqueue.simplequeue.SdtMessage; | ||
| import com.genexusmessaging.genexusmessagingqueue.simplequeue.SdtMessageOptions; | ||
| import com.genexusmessaging.genexusmessagingqueue.simplequeue.SdtMessageProperty; | ||
| import com.genexusmessaging.genexusmessagingqueue.simplequeue.SdtMessageResult; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class Convert { | ||
|
|
||
| protected static SimpleQueueMessage toSimpleQueueMessage(SdtMessage msg) { | ||
| return new SimpleQueueMessage() {{ | ||
| String id = msg.getgxTv_SdtMessage_Messageid(); | ||
| setMessageId((id.isEmpty())? java.util.UUID.randomUUID().toString() :id); | ||
| setMessageBody(msg.getgxTv_SdtMessage_Messagebody()); | ||
| setMessageHandleId(msg.getgxTv_SdtMessage_Messagehandleid()); | ||
| if (msg.getgxTv_SdtMessage_Messageattributes() != null) { | ||
| setMessageAttributes(toGXProperties(msg.getgxTv_SdtMessage_Messageattributes())); | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| protected static MessageQueueOptions toMessageQueueOptions(SdtMessageOptions receiveOptions) { | ||
| MessageQueueOptions mqOptions = new MessageQueueOptions() {{ | ||
| setMaxNumberOfMessages(receiveOptions.getgxTv_SdtMessageOptions_Maxnumberofmessages()); | ||
| setWaitTimeout(receiveOptions.getgxTv_SdtMessageOptions_Waittimeout()); | ||
| setTimetoLive(receiveOptions.getgxTv_SdtMessageOptions_Timetolive()); | ||
| setDelaySeconds(receiveOptions.getgxTv_SdtMessageOptions_Delayseconds()); | ||
| setVisibilityTimeout(receiveOptions.getgxTv_SdtMessageOptions_Visibilitytimeout()); | ||
| }}; | ||
| return mqOptions; | ||
| } | ||
|
|
||
|
|
||
| protected static SdtMessageResult toSdtMessageResult(SendMessageResult mResult) { | ||
| SdtMessageResult r = new SdtMessageResult(); | ||
| r.setgxTv_SdtMessageResult_Messageid(mResult.getMessageId()); | ||
| r.setgxTv_SdtMessageResult_Servermessageid(mResult.getMessageServerId()); | ||
| r.setgxTv_SdtMessageResult_Messagestatus(mResult.getMessageSentStatus()); | ||
| return r; | ||
| } | ||
|
|
||
| protected static GXBaseCollection<SdtMessageProperty> toSdtMessagePropertyCollection(GXProperties msgProps) { | ||
| GXBaseCollection<SdtMessageProperty> props = new GXBaseCollection<SdtMessageProperty>(); | ||
| for (int i = 0; i < msgProps.count(); i++) { | ||
| GXProperty propertyItem = msgProps.item(i); | ||
| SdtMessageProperty msgProperty = new SdtMessageProperty(); | ||
| msgProperty.setgxTv_SdtMessageProperty_Propertykey(propertyItem.getKey()); | ||
| msgProperty.setgxTv_SdtMessageProperty_Propertyvalue(propertyItem.getValue()); | ||
| props.add(msgProperty); | ||
| } | ||
| return props; | ||
| } | ||
|
|
||
| protected static GXProperties toGXProperties(GXBaseCollection<SdtMessageProperty> msgProps) { | ||
| GXProperties props = new GXProperties(); | ||
| for (SdtMessageProperty prop : msgProps) { | ||
| props.add(prop.getgxTv_SdtMessageProperty_Propertykey(), prop.getgxTv_SdtMessageProperty_Propertyvalue()); | ||
| } | ||
| return props; | ||
| } | ||
|
|
||
| public static SdtMessage toSdtMessage(SimpleQueueMessage simpleQueueMessage) { | ||
| SdtMessage msg = new SdtMessage(); | ||
| msg.setgxTv_SdtMessage_Messageattributes(toSdtMessagePropertyCollection(simpleQueueMessage.getMessageAttributes())); | ||
| msg.setgxTv_SdtMessage_Messagehandleid(simpleQueueMessage.getMessageHandleId()); | ||
| msg.setgxTv_SdtMessage_Messageid(simpleQueueMessage.getMessageId()); | ||
| msg.setgxTv_SdtMessage_Messagebody(simpleQueueMessage.getMessageBody()); | ||
| return msg; | ||
| } | ||
|
|
||
| public static GXBaseCollection<SdtMessageResult> toDeleteExternalMessageResultList(List<DeleteMessageResult> deletedMessages) { | ||
| GXBaseCollection<SdtMessageResult> externalList = new GXBaseCollection<>(); | ||
| for (DeleteMessageResult deletedMessage : deletedMessages) { | ||
| SdtMessageResult sdtMessageResult = new SdtMessageResult(); | ||
| sdtMessageResult.setgxTv_SdtMessageResult_Messageid(deletedMessage.getMessageId()); | ||
| sdtMessageResult.setgxTv_SdtMessageResult_Servermessageid(deletedMessage.getMessageServerId()); | ||
| sdtMessageResult.setgxTv_SdtMessageResult_Messagestatus(deletedMessage.getMessageDeleteStatus()); | ||
| externalList.add(sdtMessageResult); | ||
| } | ||
| return externalList; | ||
| } | ||
|
|
||
| } |
20 changes: 20 additions & 0 deletions
20
gxqueue/src/main/java/com/genexus/messaging/queue/IQueue.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.genexus.messaging.queue; | ||
|
|
||
| import com.genexus.messaging.queue.model.DeleteMessageResult; | ||
| import com.genexus.messaging.queue.model.MessageQueueOptions; | ||
| import com.genexus.messaging.queue.model.SendMessageResult; | ||
| import com.genexus.messaging.queue.model.SimpleQueueMessage; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface IQueue { | ||
| Integer getQueueLength(); | ||
| SendMessageResult sendMessage(SimpleQueueMessage simpleQueueMessage); | ||
| SendMessageResult sendMessage(SimpleQueueMessage simpleQueueMessage, MessageQueueOptions messageQueueOptions); | ||
| List<SendMessageResult> sendMessages(List<SimpleQueueMessage> simpleQueueMessages, MessageQueueOptions messageQueueOptions); | ||
| List<SimpleQueueMessage> getMessages(MessageQueueOptions messageQueueOptions); | ||
| DeleteMessageResult deleteMessage(String messageHandleId); | ||
|
|
||
| List<DeleteMessageResult> deleteMessages(List<String> messageHandleId); | ||
| boolean purge(); | ||
| } |
4 changes: 4 additions & 0 deletions
4
gxqueue/src/main/java/com/genexus/messaging/queue/QueueBase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.genexus.messaging.queue; | ||
|
|
||
| public class QueueBase { | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.