Skip to main content

ElastiCORE Port DSL Overview

Overview

ElastiCORE Port is an external system communication architecture designed around the Port and Adapter pattern from Domain-Driven Design (DDD). Developers simply write YAML-based DSL to declaratively define various external communication logic such as HTTP calls and DBMS queries. The ElastiCORE framework dynamically generates and injects implementations at runtime.

Port DSL provides a powerful capability to handle communication with external systems using only interfaces, without separate implementation classes.

Port Types

1. HTTP Port

  • RESTful communication with external HTTP API servers
  • JSON and multipart data handling
  • Authentication token and header management
  • 👉 HTTP Port Details

2. DBMS Port

  • Database integration for complex SQL queries
  • Native SQL and JPQL support
  • Dynamic queries, pagination, and sorting features
  • 👉 DBMS Port Details

3. gRPC Port (Proto)

  • Protocol Buffer-based gRPC service communication
  • Bidirectional server/client support
  • 👉 gRPC Port Details

Environment Configuration

build.gradle Setup

dependencies {
implementation 'io.elasticore:elasticore-base:1.6.11'
implementation 'io.elasticore.springboot3:elasticore-springboot3:1.6.11'

// For HTTP communication
implementation 'org.springframework.boot:spring-boot-starter-webflux'

// For database integration
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'mysql:mysql-connector-java' // or the appropriate DB driver
}

Application Class

import io.elasticore.springboot3.EnableElastiCore;

@EnableElastiCore
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

env.yml Configuration

env:
config:
domainName: demo
framework: springboot
mode: jpa
j2ee: jakarta

namespace:
entity: com.example.domain.entity
dto: com.example.domain.dto
repository: com.example.domain.repository
service: com.example.domain.service
control: com.example.domain.control
port: com.example.domain.port # Port namespace required

Code Generation

# ElastiCORE code generation
./gradlew elcore

Dependency Injection and Usage in Spring

@Service
public class UserService {

@Autowired
private UserApiAdapter userApiAdapter;

@Autowired
private UserDbPortService userDbPortService;

@Autowired
private CarInfoPortService carInfoPortService;

public void processUser() {
// HTTP API call
UserRequest request = new UserRequest();
request.setName("John Doe");
request.setEmail("john@example.com");
UserResponse response = userApiAdapter.createUser(request);

// DBMS query
UserSearchInput searchInput = new UserSearchInput();
searchInput.setName("John");
searchInput.setMinAge(20);
List<UserDTO> users = userDbPortService.findUsersByName(searchInput);

// gRPC call
CarInfo2Input carInput = new CarInfo2Input();
carInput.setBrand("Hyundai");
CarInfo2Output carInfo = carInfoPortService.findByBrand(carInput);
}
}

Naming Conventions

  • HTTP Port: ServiceNameAdapter or ServiceNameApiPort
  • DBMS Port: DomainDbPortService or DomainDataPort
  • gRPC Port: ServiceNameGrpcPort or ServiceNameProtoPort
  • Method names: Verb + Noun combinations
    • Query: findByName, getUser, searchOrders
    • Create: createUser, addProduct
    • Update: updateUser, modifyOrder
    • Delete: deleteUser, removeProduct