반응형
EJB - 분산기능 (한 서버에서 요청이 집중이 되면, 과부화가 될 수 있는 문제를 방지하는 차원)
서비스가 늦더라도 안정성이 항상 유지되어야 한다.
Spring에서도 분산기능을 사용할 수 있다. (REST에서 JSON으로 정보를 주고받고 하는 기술, RMI는 자바 기술인데 Remote Method Invocation 자바의 네트워크 기술 - RMI를 이용해서 웹 어플리케이션에서 분산기능을 사용할 수 있다.)
자바 계열쪽에서의 Spring을 통한 분산가능은 유지비용이 현저히 적은 규모로 들어가서 중요한 요소이다.
[ RMI ]
저쪽 컴퓨터에 있는 Method를 내 컴퓨터에 있는 것처럼 Method를 사용하고 활용할 수 있는 방식이다.
필히 Dao를 클래스가 아닌 인터페이스 객체로 만들어야 한다.
[ context-3-dao 변경하기 ]
[ VO 객체 직렬화 ]
Serializable를 통해서 객체를 직렬화 시켜야한다.
더보기
package vo;
import java.io.Serializable;
// 객체 직렬화
public class DeptVo implements Serializable {
int deptno;
String dname;
String loc;
public int getDeptno() {
return deptno;
}
public void setDeptno(int deptno) {
this.deptno = deptno;
}
public String getDname() {
return dname;
}
public void setDname(String dname) {
this.dname = dname;
}
public String getLoc() {
return loc;
}
public void setLoc(String loc) {
this.loc = loc;
}
}
[ Spring_RMI 이용하기 ]
더보기








-------------[서버설정]------------------
<bean id="calc" class="dao.CalcImpl"></bean>
<!-- RMI Service를 수행하는 객체 생성 -->
<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName"><value>Calc</value></property>
<property name="service"><ref bean="calc"/></property>
<property name="serviceInterface"><value>dao.Calc</value></property>
<!-- defaults to 1099 -->
<property name="registryPort"><value>1199</value></property>
</bean>
-----------[클라이언트 설정]--------------
<bean id="usercalc" class="user.UserCalc">
<property name="calc"><ref bean="calcService"/></property>
</bean>
<!-- RMI Server에서 원격객체를 얻어오는 설정 -->
<bean id="calcService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl"><value>rmi://203.236.209.81:1199/Calc</value></property>
<property name="serviceInterface"><value>dao.Calc</value></property>
</bean>
Port 방화벽 해제





전부 삭제된 환경 (복사한 RMIClient 프로젝트)

[ RMI 클라이언트 환경설정 ]
더보기






<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- RMI Server에서 원격객체를 얻어오는 설정 -->
<bean id="dept_dao" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl"><value>rmi://192.:1199/dept</value></property>
<property name="serviceInterface"><value>dao.DeptDao</value></property>
</bean>
</beans>
순서가 중요하니 꼭 Client를 후순위에 두자


반응형
'SpringBoot↗' 카테고리의 다른 글
Spring Boot) JPA (0) | 2024.08.08 |
---|---|
SpringBoot 환경설정 및 초기 가이드 (0) | 2024.08.07 |
Spring)Transaction - AOP (0) | 2024.08.06 |
Spring)AOP (0) | 2024.08.06 |
Spring)Rest API로 CRUD 정보 처리하기 (0) | 2024.08.05 |