Skip to content

Commit

Permalink
fix:asset-state-event queue url and fixed rabbit suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ershad-paladin committed Dec 17, 2024
1 parent 5400e08 commit d939c74
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public String sendSQSMessage(SQSBaseMessage sqsMessage, String url) {
String message = objectMapper.writeValueAsString(sqsMessage);
return sendMessage(message, url);
} catch (Exception e) {
LOGGER.error("Unable to send SQS message", e);
LOGGER.error("Unable to send SQS message to URL {}: {}", url, e.getMessage(), e);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ public interface PacmanSdkConstants {
String POLICY_DISABLED_MSG = "Policy has been disabled";
String TENANT_ID = "TENANT_ID";
String TENANT_NAME = "TENANT_NAME";
String ASSET_STATE_SQS_QUEUE_URL = "ASSET_STATE_SQS_URL";
String ASSET_STATE_TRIGGER_EVENT = "ASSET_STATE_TRIGGER_EVENT";
String API_FEATURE_FLAGS = "api_feature_flags";
String ENABLE_ASSET_STATE_SERVICE_FLAG_NAME = "enableAssetStateService";
String ASSET_STATE_JOB = "asset-state-job";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,18 @@ public PolicyExecutor (String jsonString) {
logger.error("can't get the temp credentials");
}

try {
amazonDynamoDB = AmazonDynamoDBClientBuilder
.standard()
.withRegion(region)
.withCredentials(new AWSStaticCredentialsProvider(tempCredentials))
.build();
} catch (Exception e) {
logger.error("Error initializing dynamoDb client for account {} , cause : {}", baseAccount, e.getMessage(), e);
if (tempCredentials != null) {
try {
amazonDynamoDB = AmazonDynamoDBClientBuilder
.standard()
.withRegion(region)
.withCredentials(new AWSStaticCredentialsProvider(tempCredentials))
.build();
} catch (Exception e) {
logger.error("Error initializing dynamoDb client for account {} , cause : {}", baseAccount, e.getMessage(), e);
}
} else {
logger.error("Cannot initialize AmazonDynamoDB client because tempCredentials is null");
}
}

Expand Down Expand Up @@ -195,6 +199,10 @@ public static void main(String[] args) {
}

private boolean isAssetStateSvcEnabled(String tenantId) {
if (amazonDynamoDB == null) {
logger.error("not able to fetch feature flag since, AmazonDynamoDB client is not initialized");
return false;
}
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
expressionAttributeValues.put(":tenantId", new AttributeValue().withS(tenantId));
QueryRequest queryRequest = new QueryRequest()
Expand All @@ -218,7 +226,7 @@ private boolean isAssetStateSvcEnabled(String tenantId) {

private void sendAssetStateEvent(String source, String targetType) {
logger.info("sending asset state event for source: {} and target type: {}");
String queueUrl = System.getenv(ASSET_STATE_SQS_QUEUE_URL);
String queueUrl = System.getenv(ASSET_STATE_TRIGGER_EVENT);
String tenantId = System.getenv(TENANT_ID);
String tenantName = System.getenv(TENANT_NAME);
SQSManager sqsManager = SQSManager.getInstance();
Expand Down

0 comments on commit d939c74

Please sign in to comment.