Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file removed .DS_Store
Binary file not shown.
118 changes: 0 additions & 118 deletions .mvn/wrapper/MavenWrapperDownloader.java

This file was deleted.

Binary file removed .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repositories {
url = uri('https://repo.maven.apache.org/maven2')

}
maven {
maven {
url "https://fynarfin.jfrog.io/artifactory/fyn-libs-release-local"
}

Expand Down
Binary file removed src/.DS_Store
Binary file not shown.
Binary file removed src/main/.DS_Store
Binary file not shown.
Binary file removed src/main/java/.DS_Store
Binary file not shown.
Binary file removed src/main/java/org/.DS_Store
Binary file not shown.
Binary file removed src/main/java/org/mifos/.DS_Store
Binary file not shown.
23 changes: 23 additions & 0 deletions src/main/java/org/mifos/processor/bulk/OperationsAppConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.mifos.processor.bulk;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class OperationsAppConfig {

@Value("${operations-app.contactpoint}")
public String operationAppContactPoint;

@Value("${operations-app.endpoints.batch-transaction}")
public String batchTransactionEndpoint;

public String batchTransactionUrl;

@PostConstruct
private void setup() {
batchTransactionUrl = operationAppContactPoint + batchTransactionEndpoint;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.mifos.processor.bulk.camel.routes;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.zeebe.client.ZeebeClient;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.RouteDefinition;
import org.mifos.processor.bulk.OperationsAppConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public abstract class BaseRouteBuilder extends RouteBuilder {

@Autowired
public ObjectMapper objectMapper;

@Autowired
public OperationsAppConfig operationsAppConfig;

@Autowired
ZeebeClient zeebeClient;

public Logger logger = LoggerFactory.getLogger(this.getClass());

public RouteDefinition getBaseExternalApiRequestRouteDefinition(String routeId, HttpRequestMethod httpMethod) {
return from(String.format("direct:%s", routeId))
.id(routeId)
.log("Starting external API request route: " + routeId)
.removeHeader("*")
.setHeader(Exchange.HTTP_METHOD, constant(httpMethod.text))
.setHeader("X-Date", simple(ZonedDateTime.now( ZoneOffset.UTC ).format( DateTimeFormatter.ISO_INSTANT )))
.setHeader("Content-Type", constant("application/json"));
}

protected enum HttpRequestMethod {
GET("GET"),
POST("POST"),
PUT("PUT"),
DELETE("DELETE")
;

private final String text;

HttpRequestMethod(String text) {
this.text = text;
}

@Override
public String toString() {
return text;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.mifos.processor.bulk.camel.routes;

import org.mifos.processor.bulk.zeebe.ZeebeProcessStarter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import static org.mifos.processor.bulk.zeebe.ZeebeVariables.BATCH_ID;

@Component
public class ProcessorStartRoute extends BaseRouteBuilder{

@Autowired
private ZeebeProcessStarter zeebeProcessStarter;

@Value("${bpmn.flows.bulk-processor}")
private String workflowId;

private Logger logger = LoggerFactory.getLogger(this.getClass());

@Override
public void configure() throws Exception {
setup();
}

private void setup() {
from("rest:POST:/bulk/transfer/{requestId}/{fileName}")
.process(exchange -> {
String fileName = exchange.getIn().getHeader("fileName", String.class);
String requestId = exchange.getIn().getHeader("requestId", String.class);
String batchId = UUID.randomUUID().toString();

logger.info("\n\n Filename: " + fileName + " \n\n");
logger.info("\n\n BatchId: " + batchId + " \n\n");

Map<String, Object> variables = new HashMap<>();
variables.put(BATCH_ID, batchId);
variables.put("fileName", fileName);
variables.put("requestId", requestId);

zeebeProcessStarter.startZeebeWorkflow(workflowId, "", variables);
});
}
}
12 changes: 3 additions & 9 deletions src/main/java/org/mifos/processor/bulk/camel/routes/Routes.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.*;

@Component
public class Routes extends RouteBuilder {

@Autowired
ZeebeClient zeebeClient;

@Value("${operations-app-config.host}")
String operationsAppHost;
public class Routes extends BaseRouteBuilder {

@Value("${config.minimum-successful-tx-ratio}")
double minimumSuccessfulTxRatio;
Expand All @@ -42,7 +36,7 @@ private void routeCheckTransactions() {
.id(id)
.log("Fetching transaction details")
//set request params
.to(operationsAppHost+ "/api/v1/batch/transactions")
.toD(operationsAppConfig.batchTransactionEndpoint)
.process(exchange -> {
// get response body
JSONObject transfers = new JSONObject(exchange.getIn().getBody(String.class));
Expand Down Expand Up @@ -80,7 +74,7 @@ private void routeSampleTransactions() {
.process(exchange -> {
exchange.getIn().setHeader("batchId", exchange.getProperty(BATCH_ID));
})
.toD(operationsAppHost + "/api/v1/batch/transactions")
.toD(operationsAppConfig.batchTransactionEndpoint)
.process(exchange -> {
// get response body

Expand Down
15 changes: 9 additions & 6 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ zeebe:
broker:
contactpoint: "zeebe-zeebe-gateway:26500"

operations-app:
contactpoint: "https://ops-bk.ibank.financial"
endpoints:
batch-transaction: "/api/v1/batch/transactions"

cloud:
aws:
enabled: true
credentials:
access-key: ${AWS_ACCESS_KEY:AKIAX32JM37TYOG3QUJU}
secret-key: ${AWS_SECRET_KEY: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}
access-key: ${AWS_ACCESS_KEY:AKIAX32JM37TZOJ5AKFB}
secret-key: ${AWS_SECRET_KEY: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}
region:
static: us-east-2
stack:
Expand All @@ -58,9 +63,7 @@ bpmn:
international-remittance-payee: "international_remittance_payee_process-{dfspid}"
international-remittance-payer: "international_remittance_payer_process-{dfspid}"
debit-party-process: "debit_party_process-{dfspid}"

operations-app-config:
host: ""
bulk-processor: "bulk_processor-ibank-usa"

config:
minimum-successful-tx-ratio: 0.90
minimum-successful-tx-ratio: 0.90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mifos.pheeprocessorbulk;
package org.mifos.processor;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down