Skip to content

Commit

Permalink
Merge pull request #123 from ananjaykumar2/mod/unused-code-rmoved
Browse files Browse the repository at this point in the history
remove unused code
  • Loading branch information
ankitmashu authored Nov 22, 2024
2 parents 447fcd5 + 2693cbf commit a8e904d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public MessageProcessorImpl(

@Override
public Future<JsonObject> processAuditEventMessages(JsonObject message) {
LOGGER.info("message processing starts : ");
LOGGER.info("processAuditEventMessages started()");
JsonObject queries = queryBuilder(message);
LOGGER.debug("message processing {}", queries);
LOGGER.debug("auditing queries : {}", queries);
queries.put(DELIVERY_TAG, message.getLong(DELIVERY_TAG));
queries.put(ORIGIN, message.getString(ORIGIN));
Promise<JsonObject> promise = Promise.promise();
Expand All @@ -52,10 +52,11 @@ public Future<JsonObject> processAuditEventMessages(JsonObject message) {
.onComplete(
dbHandler -> {
if (dbHandler.succeeded()) {
LOGGER.info("Inserted successfully for the Origin {}", message.getString(ORIGIN));
LOGGER.info(
"Log audited successfully for the Origin {}", message.getString(ORIGIN));
promise.complete(dbHandler.result());
} else {
LOGGER.error(dbHandler.cause());
LOGGER.error("Failed databaseOperations : {}", dbHandler.cause().getMessage());
promise.fail(dbHandler.cause());
}
});
Expand Down Expand Up @@ -99,7 +100,6 @@ private Future<JsonObject> databaseOperations(JsonObject queries) {
LOGGER.trace("databaseOperations started");
Promise<JsonObject> promise = Promise.promise();
Future<JsonObject> insertInPostgres = postgresService.executeWriteQuery(queries);
LOGGER.debug("Queries from origin is {} ", queries.getString(ORIGIN));
insertInPostgres
.onSuccess(
insertInImmudbHandler -> {
Expand All @@ -110,7 +110,7 @@ private Future<JsonObject> databaseOperations(JsonObject queries) {
promise.complete(queries);
} else {
LOGGER.error(
"Failed: unable to update immudb table for server origin" + " {}",
"Failed: unable to update immudb table for server origin : {}",
queries.getString(ORIGIN));
Future<JsonObject> deleteFromPostgres =
postgresService.executeDeleteQuery(queries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String buildPostgresWriteQuery(JsonObject request) {
.replace("$2", userId)
.replace("$3", api)
.replace("$4", method)
.replace("$5", body.toString())
.replace("$5", body.encode())
.replace("$6", Long.toString(responseSize))
.replace("$7", utcTime.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ private void consume() {
RabbitMQConsumer mqConsumer = receiveResultHandler.result();
mqConsumer.handler(
message -> {
long startTime = System.currentTimeMillis();
mqConsumer.pause();
LOGGER.debug("message consumption paused.");
JsonObject request = new JsonObject();
Expand All @@ -64,27 +63,18 @@ private void consume() {
.body()
.toJsonObject()
.put(DELIVERY_TAG, deliveryTag);
LOGGER.debug("Log received {}", request);
LOGGER.info(
"message received from {}", request.getString(ORIGIN));
"Log received from {}", request.getString(ORIGIN));
Future<JsonObject> processResult =
msgService.processAuditEventMessages(request);
processResult.onComplete(
handler -> {
if (handler.succeeded()) {
long endTime =
System.currentTimeMillis(); // End time
long duration =
endTime - startTime; // Time difference
LOGGER.info(
"Audit message published in databases. Time taken: "
+ duration
+ " ms");
client.basicAck(
handler.result().getLong(DELIVERY_TAG), false);
mqConsumer.resume();
LOGGER.debug("message consumption resumed");
successCount++;
LOGGER.info(" success count == " + successCount);
} else {
LOGGER.error(
"Error while publishing messages for processing "
Expand All @@ -109,8 +99,6 @@ private void consume() {
mqConsumer.resume();
LOGGER.debug("message consumption resumed");
}
totalCount++;
LOGGER.info(" total count == " + totalCount);
});
} else {
LOGGER.error(
Expand Down

0 comments on commit a8e904d

Please sign in to comment.