Skip to content
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

Implemented changes to adapt routingkey template to sepia #247

Merged
merged 25 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5426661
Create main.yml for github actions to migrate from travis
jainadc9 May 24, 2022
f01dabc
Delete .travis.yml
jainadc9 May 26, 2022
4bd6c52
Merge branch 'eiffel-community:master' into master
jainadc9 Jun 15, 2022
56ff431
Removed archived repo remrem shared dependencies.
Jun 15, 2022
b466cee
Fixed review comments
jainadc9 Jun 16, 2022
1eb5c7e
Added required imports
jainadc9 Jun 20, 2022
8f0c63c
Updated documentation related to message validation
Jun 23, 2022
445f5a0
Update CHANGELOG.md
jainadc9 Jun 23, 2022
13e583b
Merge with master branch (#2)
jainadc9 Jul 6, 2022
fc8721f
Merge branch 'eiffel-community:master' into master
jainadc9 Jul 6, 2022
f1d19e7
Implemented changes to adapt routingkey template to sepia
Aug 4, 2022
b10f6f6
Fixed review comments
Dec 22, 2022
5b6c6a8
Rebase changes with master (#4)
jainadc9 Mar 1, 2023
f14096c
Merge branch 'master' into master
jainadc9 Mar 2, 2023
5dac121
Rebased changes with master
jainadc9 Aug 16, 2023
2251450
Merge branch 'master' into master
jainadc9 Aug 16, 2023
9a39ed0
Resolved review comments
jainadc9 Aug 17, 2023
ba1b0ac
Reverted local env changes
jainadc9 Aug 17, 2023
df43e5a
Added more logs
jainadc9 Aug 18, 2023
752d069
Made changes to documentation
jainadc9 Aug 18, 2023
ffd1de7
Added test case for backward compatability of sepia
jainadc9 Aug 18, 2023
d3e6c82
Fixed review comments
jainadc9 Aug 21, 2023
75db989
Edited documentation
jainadc9 Aug 21, 2023
efb88d9
Edited documentation
jainadc9 Aug 22, 2023
4fc1b93
Added Cli documentation
jainadc9 Aug 22, 2023
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.1.0
- Implemented new routing key template for Sepia.
-
## 2.0.30
- Upgrading to OpenJDK 17

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<version>2.0.12</version>
</parent>
<properties>
<eiffel-remrem-publish.version>2.0.30</eiffel-remrem-publish.version>
<eiffel-remrem-semantics.version>2.2.6</eiffel-remrem-semantics.version>
<eiffel-remrem-publish.version>2.1.0</eiffel-remrem-publish.version>
<eiffel-remrem-semantics.version>2.3.0</eiffel-remrem-semantics.version>
</properties>
<artifactId>eiffel-remrem-publish</artifactId>
<version>${eiffel-remrem-publish.version}</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class CliOptions {

static private Options options=null;
static private CommandLine commandLine;

private static final String SEMANTICS_ROUTINGKEY_TYPE_OVERRIDE_FILEPATH = "semanticsRoutingkeyTypeOverrideFilepath";
//Used for testing purposes
private static ArrayList<Integer> testErrorCodes = new ArrayList<>();

Expand Down Expand Up @@ -85,6 +85,8 @@ public static void createCLIOptions() {
options.addOption("tag", "tag", true, "tag to be used in routing key");
options.addOption("rk", "routing_key", true, "routing key of the eiffel message. When provided routing key is not generated and the value provided is used.");
options.addOption("tto", "tcp_time_out", true, "specifies tcp connection timeout, default time is 60000 milliseconds");
options.addOption("srkt", SEMANTICS_ROUTINGKEY_TYPE_OVERRIDE_FILEPATH, false, "routing key of the eiffel message. When provided routing key is not generated and the value provided is used.");

contentGroup = createContentGroup();
options.addOptionGroup(contentGroup);
}
Expand Down Expand Up @@ -252,6 +254,12 @@ public static void handleMessageBusOptions() throws HandleMessageBusException {
System.setProperty(key, tls_ver);
}

if (commandLine.hasOption(SEMANTICS_ROUTINGKEY_TYPE_OVERRIDE_FILEPATH)) {
String semanticsRoutingkeyTypeOverrideFilepath =commandLine.getOptionValue(SEMANTICS_ROUTINGKEY_TYPE_OVERRIDE_FILEPATH);
String key = PropertiesConfig.SEMANTICS_ROUTINGKEY_TYPE_OVERRIDE_FILEPATH;
jainadc9 marked this conversation as resolved.
Show resolved Hide resolved
System.setProperty(key, semanticsRoutingkeyTypeOverrideFilepath);
}

String usePersistance = "true";
if (commandLine.hasOption("np")) {
usePersistance = "false";
Expand Down Expand Up @@ -288,6 +296,7 @@ public static void clearSystemProperties() {
System.clearProperty(PropertiesConfig.CHANNELS_COUNT);
System.clearProperty(PropertiesConfig.TCP_TIMEOUT);
System.clearProperty(PropertiesConfig.WAIT_FOR_CONFIRMS_TIME_OUT);
System.clearProperty(PropertiesConfig.SEMANTICS_ROUTINGKEY_TYPE_OVERRIDE_FILEPATH);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class PropertiesConfig {
public static final String SERVICE_UNAVAILABLE = "Service Unavailable";

public static final String CREATE_EXCHANGE_IF_NOT_EXISTING = "com.ericsson.eiffel.remrem.publish.messagebus.createExchange";
public static final String SEMANTICS_ROUTINGKEY_TYPE_OVERRIDE_FILEPATH = "com.ericsson.eiffel.remrem.publish.messagebus.semanticsRoutingkeyTypeOverrideFilepath";
public static final String INVALID_EXCHANGE = "Exchange not found, Please check exchange configuration and try again";
public static final String INVALID_EXCHANGE_MESSAGE_CLI = " Unavailable. To create the exchange specify -ce or --create_exchange to true )";
public static final String INVALID_EXCHANGE_MESSAGE_SERVICE = " ExchangeName is not present, To create the exchange specify createExchangeIfNotExisting in application configuration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class RabbitMqPropertiesConfig {
@Value("${jasypt.encryptor.jasyptKeyFilePath:#{null}}")
private String jasyptKeyFilePath;

@Value("${semanticsRoutingkeyTypeOverrideFilepath:#{null}}")
private String semanticsRoutingkeyTypeOverrideFilepath;

private Map<String, RabbitMqProperties> rabbitMqPropertiesMap = new HashMap<String, RabbitMqProperties>();

@Autowired
Expand Down Expand Up @@ -154,6 +157,9 @@ private void readSpringProperties() {
rabbitMqProperties.setChannelsCount(
Integer.parseInt(channelsCount));
}

rabbitMqProperties.setRoutingkeyTypeOverrideFilePath(semanticsRoutingkeyTypeOverrideFilepath);

String waitForConfirmsTimeOut = getPropertyAsText(rabbitmqInstanceObject, PROPERTY_WAIT_FOR_CONFIRMS_TIMEOUT);
if (waitForConfirmsTimeOut != null) {
rabbitMqProperties.setWaitForConfirmsTimeOut(Long.parseLong(waitForConfirmsTimeOut));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@ public static String getRoutingKey(MsgService msgService, JsonObject json, RMQHe
String domainId = rabbitMqProperties.getDomainId();
if (rabbitMqProperties != null && rabbitMqProperties.getExchangeName() != null && rabbitMqProperties.getHost() != null
&& (cliMode || (!cliMode && StringUtils.isNotBlank(domainId)))) {
return StringUtils.defaultIfBlank(routingKey, msgService.generateRoutingKey(json, tag, domainId, userDomainSuffix));

if (StringUtils.isNotBlank(routingKey)) {
return routingKey;
} else if (StringUtils.isNotBlank(rabbitMqProperties.getRoutingkeyTypeOverrideFilePath())) {
jainadc9 marked this conversation as resolved.
Show resolved Hide resolved
String type = rabbitMqProperties.getTypeRoutingKeyFromConfiguration(msgService.getEventType(json));
if (StringUtils.isNotBlank(type)) {
return msgService.generateRoutingKey(json, tag, domainId, userDomainSuffix, type);
}
}
return msgService.generateRoutingKey(json, tag, domainId, userDomainSuffix);
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@
*/
package com.ericsson.eiffel.remrem.publish.helper;

import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.Random;
import java.util.ResourceBundle;
import java.util.concurrent.TimeoutException;
import java.util.PropertyResourceBundle;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;

import com.ericsson.eiffel.remrem.publish.config.PropertiesConfig;
Expand Down Expand Up @@ -52,6 +57,7 @@ public class RabbitMqProperties {
private String domainId;
private Integer channelsCount;
private boolean createExchangeIfNotExisting;
private String routingkeyTypeOverrideFilePath;
private Integer tcpTimeOut;
private boolean hasExchange = false;
// built in tcp connection timeout value for MB in milliseconds.
Expand All @@ -68,6 +74,10 @@ public class RabbitMqProperties {

private List<Channel> rabbitChannels;

private ResourceBundle types;
private final String TYPE = "type";
private final String DOT = ".";

Logger log = (Logger) LoggerFactory.getLogger(RMQHelper.class);

static {
Expand Down Expand Up @@ -157,7 +167,15 @@ public void setCreateExchangeIfNotExisting(boolean createExchangeIfNotExisting)
this.createExchangeIfNotExisting = createExchangeIfNotExisting;
}

public Integer getChannelsCount() {
public String getRoutingkeyTypeOverrideFilePath() {
return routingkeyTypeOverrideFilePath;
}

public void setRoutingkeyTypeOverrideFilePath(String routingkeyTypeOverrideFilePath) {
this.routingkeyTypeOverrideFilePath = routingkeyTypeOverrideFilePath;
}

public Integer getChannelsCount() {
return channelsCount;
}

Expand Down Expand Up @@ -229,9 +247,6 @@ public void init() {
factory.setUsername(username);
factory.setPassword(password);
}




if (tlsVer != null && !tlsVer.isEmpty()) {
if (tlsVer.contains("default")) {
Expand Down Expand Up @@ -259,6 +274,14 @@ public void init() {
log.error("Error occured while setting up the RabbitMq Connection. "+e.getMessage());
e.printStackTrace();
}

if (StringUtils.isNotBlank(routingkeyTypeOverrideFilePath)) {
try {
types = new PropertyResourceBundle(new FileInputStream(routingkeyTypeOverrideFilePath));
} catch (IOException e) {
log.error(e.getMessage(), e);
jainadc9 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

/**
Expand Down Expand Up @@ -337,6 +360,11 @@ private void initService() {
if (waitForConfirmsTimeOut == null ) {
waitForConfirmsTimeOut = Long.getLong(getValuesFromSystemProperties(protocol + ".rabbitmq.waitForConfirmsTimeOut"));
}

if (protocol.equalsIgnoreCase("eiffelsemantics") && routingkeyTypeOverrideFilePath == null) {
jainadc9 marked this conversation as resolved.
Show resolved Hide resolved
routingkeyTypeOverrideFilePath = getValuesFromSystemProperties(PropertiesConfig.SEMANTICS_ROUTINGKEY_TYPE_OVERRIDE_FILEPATH);
}

}


Expand All @@ -352,6 +380,7 @@ private void setValues() {
usePersitance = Boolean.getBoolean(PropertiesConfig.USE_PERSISTENCE);
createExchangeIfNotExisting = Boolean.parseBoolean(getValuesFromSystemProperties(PropertiesConfig.CREATE_EXCHANGE_IF_NOT_EXISTING));
tcpTimeOut = Integer.getInteger(PropertiesConfig.TCP_TIMEOUT);
routingkeyTypeOverrideFilePath = getValuesFromSystemProperties(PropertiesConfig.SEMANTICS_ROUTINGKEY_TYPE_OVERRIDE_FILEPATH);
jainadc9 marked this conversation as resolved.
Show resolved Hide resolved
}

private String getValuesFromSystemProperties(String propertyName) {
Expand Down Expand Up @@ -556,4 +585,30 @@ private Channel giveMeRandomChannel() throws RemRemPublishException {
factory, e);
}
}

/**
* This method is used to get routing key type based on the eventType from the configuration file
*
* @param eventType
* Eiffel eventType
* @return type based on eventType if provided in the configuration file else null
*/
public String getTypeRoutingKeyFromConfiguration(String eventType) {
if (types != null) {
String key = eventType + DOT + TYPE;
String routingKey = types.getString(key);
try {
if (!routingKey.isEmpty()) {
jainadc9 marked this conversation as resolved.
Show resolved Hide resolved
return routingKey;
}
} catch (MissingResourceException e) {
log.info("Routing key from configuration is null ");
return null;
jainadc9 marked this conversation as resolved.
Show resolved Hide resolved
}
}
log.info("Event type is null ");
return null;
}


}
1 change: 1 addition & 0 deletions publish-service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jasypt.encryptor.jasyptKeyFilePath: ""
rabbitmq.instances.jsonlist=[{ "mp": "eiffelsemantics", "host": "127.0.0.1", "port": "5672", "virtualHost": "", "username": "guest", "password": "guest", "tls": "", "exchangeName": "ertest1234", "channelsCount": "1", "domainId": "eiffelxxx", "createExchangeIfNotExisting":true,"waitForConfirmsTimeOut":"5000", "tcpTimeOut": "5000" }, \
{ "mp": "eiffel3", "host": "127.0.0.1", "port": "5672", "virtualHost": "", "username": "guest", "password": "guest", "tls": "", "exchangeName": "eiffel3", "domainId": "eiffelxxx", "channelsCount": "1", "createExchangeIfNotExisting":true,"waitForConfirmsTimeOut":"5000", "tcpTimeOut": "5000" }]

semanticsRoutingkeyTypeOverrideFilepath: <The complete file path to read properties of type and family to prepare routing key>

# properties for server used to generate messages
generate.server.uri: http://127.0.0.1:8080
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void testGenerateRoutingKey() throws Exception {
JsonParser parser = new JsonParser();
JsonElement json = parser.parse(new FileReader(file)).getAsJsonObject();
String routingKey = messageService.generateRoutingKey(json.getAsJsonObject(), null, null, null);
assertEquals("eiffel.activity.finished.notag.eiffeltest", routingKey);
assertEquals("eiffel.activity.EiffelActivityFinishedEvent.notag.eiffeltest", routingKey);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void testRoutingKey() throws Exception {
JsonElement json = parser.parse(new FileReader(file)).getAsJsonObject();
routingKey = PublishUtils.getRoutingKey(msgService, json.getAsJsonObject(), rmqHelper, "fem001", null, null);
if(routingKey != null) {
assertEquals("eiffel.activity.finished.notag.eiffeltest.fem001", routingKey);
assertEquals("eiffel.activity.EiffelActivityFinishedEvent.notag.eiffeltest.fem001", routingKey);
}
}
}
Expand Down
107 changes: 106 additions & 1 deletion wiki/markdown/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,109 @@ Binary is released via [jitPack](https://jitpack.io/#eiffel-community/eiffel-rem

The latest REMReM Publish CLI binary can be downloaded via [publish-cli.jar](https://jitpack.io/#eiffel-community/eiffel-remrem-publish).

The latest REMReM Publish Service binary can be downloaded via [publish-service.war](https://jitpack.io/#eiffel-community/eiffel-remrem-publish).
The latest REMReM Publish Service binary can be downloaded via [publish-service.war](https://jitpack.io/#eiffel-community/eiffel-remrem-publish).

jainadc9 marked this conversation as resolved.
Show resolved Hide resolved
The latest REMReM Publish uses sepia protocol. To make it compatible prior to sepia protocol versions
create a file at following location publish-service/src/main/resources/routing-key-overrides.properties
with following content

EiffelActivityCanceledEvent.family=activity
EiffelActivityCanceledEvent.type=canceled

EiffelActivityFinishedEvent.family=activity
EiffelActivityFinishedEvent.type=finished

EiffelActivityStartedEvent.family=activity
EiffelActivityStartedEvent.type=started

EiffelActivityTriggeredEvent.family=activity
EiffelActivityTriggeredEvent.type=triggered

EiffelAnnouncementPublishedEvent.family=info
EiffelAnnouncementPublishedEvent.type=announcement

EiffelArtifactCreatedEvent.family=artifact
EiffelArtifactCreatedEvent.type=created

EiffelArtifactPublishedEvent.family=artifact
EiffelArtifactPublishedEvent.type=published

EiffelArtifactReusedEvent.family=artifact
EiffelArtifactReusedEvent.type=reused

EiffelCompositionDefinedEvent.family=cm
EiffelCompositionDefinedEvent.type=composition

EiffelConfidenceLevelModifiedEvent.family=artifact
EiffelConfidenceLevelModifiedEvent.type=modified

EiffelEnvironmentDefinedEvent.family=cm
EiffelEnvironmentDefinedEvent.type=environment

EiffelFlowContextDefinedEvent.family=flowcontext
EiffelFlowContextDefinedEvent.type=defined

EiffelIssueVerifiedEvent.family=test
EiffelIssueVerifiedEvent.type=issueverified

EiffelSourceChangeCreatedEvent.family=cm
EiffelSourceChangeCreatedEvent.type=scmchange

EiffelSourceChangeSubmittedEvent.family=cm
EiffelSourceChangeSubmittedEvent.type=scmproposedchange

EiffelTestCaseCanceledEvent.family=test
EiffelTestCaseCanceledEvent.type=casecanceled

EiffelTestCaseTriggeredEvent.family=test
EiffelTestCaseTriggeredEvent.type=casetriggered

EiffelTestCaseFinishedEvent.family=test
EiffelTestCaseFinishedEvent.type=casefinished

EiffelTestCaseStartedEvent.family=test
EiffelTestCaseStartedEvent.type=casestarted

EiffelTestSuiteFinishedEvent.family=test
EiffelTestSuiteFinishedEvent.type=suitefinished

EiffelTestSuiteStartedEvent.family=test
EiffelTestSuiteStartedEvent.type=suitestarted

EiffelTestExecutionRecipeCollectionCreatedEvent.family=test
EiffelTestExecutionRecipeCollectionCreatedEvent.type=execution

EiffelAlertAcknowledgedEvent.family=alert
EiffelAlertAcknowledgedEvent.type=alertack

EiffelArtifactDeployedEvent.family=artifact
EiffelArtifactDeployedEvent.type=deployed

EiffelServiceAllocatedEvent.family=service
EiffelServiceAllocatedEvent.type=allocated

EiffelServiceDeployedEvent.family=service
EiffelServiceDeployedEvent.type=deployed

EiffelServiceDiscontinuedEvent.family=service
EiffelServiceDiscontinuedEvent.type=discontinued

EiffelServiceReturnedEvent.family=service
EiffelServiceReturnedEvent.type=returned

EiffelServiceStartedEvent.family=service
EiffelServiceStartedEvent.type=started

EiffelServiceStoppedEvent.family=service
EiffelServiceStoppedEvent.type=stopped

EiffelAlertRaisedEvent.family=alert
EiffelAlertRaisedEvent.type=raised

EiffelAlertCeasedEvent.family=alert
EiffelAlertCeasedEvent.type=ceased

EiffelIssueDefinedEvent.family=test
EiffelIssueDefinedEvent.type=issuedefined


Loading