• Link to Facebook
  • Link to LinkedIn
  • Link to X
  • Link to Youtube
  • 로그인
  • 회원가입
  •  한글 한글 한글 ko
  • English English 영어 en
OPENMARU APM
  • 오픈마루
    • 회사소개
    • 연혁
    • 오픈마루 CI
  • 제품
    • OPENMARU Cloud APM
      • Application 모니터링
      • Openshift & Kubernetes 모니터링
      • WEB/WAS 모니터링
      • URL 모니터링
      • Cubrid 모니터링
    • OPENMARU Cluster
    • OPENMARU Dashboard
  • 오픈소스
    • 쿠버네티스
    • 아파치 톰캣
    • CentOS
  • 레드햇
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat JBoss EAP
  • 가격 안내
  • 조달물품
    • G2B 딜 등록
    • 조달물품 OPENMARU APM
    • 조달물품 OPENMARU Cluster
    • 혁신장터
    • 찾아가는 클라우드 네이티브 세미나
  • 레퍼런스
  • 고객지원
  • 문서
  • 블로그
  • Click to open the search input field Click to open the search input field Search
  • Menu Menu

JBoss Data Grid PostgreSQL Cache Store 사용하기

JBoss Data Grid(infinispan)을 사용하여 PostgreSQL로 Persistence Cache Store를 설정하여 성능을 향상시키세요.

JBoss Tips & Tricks - Red Hat JBoss Enterprise Application Platform

JBoss Datagrid 퍼시스턴스 구성


Infinispan 에 저장된 데이터가 예기치 못한 장애나 서버 작업으로 인하여 유실되었을 경우를 대비해 File이나 DB 로 Persistence 하게 저장할 수 있도록 하는 Persistence 와 캐시스토어 설정과 사용방법에 대해 예제를 통하여 살펴봅니다.

이 예제는 Infinispan 6.0.1 버전을 기반으로 하였으며, JBoss Data Grid 버전으로는 6.2.0 버전에 해당합니다.

참조로 Infinispan 과 JBoss Data Grid 간의 버전 맵핑은 아래의 테이블에서 참조합니다.

JBoss by Red Hat - JBoss Enterprise Data Grid

Persistence 캐시 스토어 컴포넌트


Infinispan의 In-Memory 에 저장된 데이터를 영구히 저장하고 읽어 오는 방법으로 Persistence와 캐시 스토어를 설정할 수 있습니다.

persistence – 캐시에 데이터가 없는 경우 Persistence 데이터 저장소로 부터 데이터를 로드합니다.

캐시 스토어 ( Cache Store) – 캐시 로더를 확장 한 것으로 Persistence 데이터 저장소에 데이터를 저장하는 기능을 합니다.

캐시 저장소 유형 – 캐시 저장소 타입에는 다음과 같은 것들이 있습니다.

  • File System Based Cache Stores : 파일 기반 캐시 스토어
  • Remote Cache Stores : 리모트 캐시 스토어
  • Custom Cache Stores : 사용자 정의형 캐시 스토어
  • LevelDB Cache Store : LevelDB 캐시 스토어
  • JDBC 기반 캐시 스토어 : JdbcBinaryCacheStore, JdbcStringBasedCacheStore, JdbcMixedCacheStore

이 예제에서는 stringKeyedJdbcStore 를 이용하여 PostgreSQL DB로 Persistence 저장합니다.

실습 – Infinispan 6.0.1 ( JBoss Data Grid 6.2) 에서 Persistence를 위한 캐시 로더와 캐시 스토어 설정하기


1. 개발 환경 구성

1.1. Eclipse 개발 환경

JDBC Cache Store 를 위한 샘플 프로젝트의 형태는 아래의 그림과 같습니다.

pom.xml 파일을 작성하여 Eclipse Maven Project 로 프로젝트를 구성합니다.

Cache에 대한 정의와 DB Persistence 설정을 위한 JdbcStoreTest.xml 파일과 Cache 에 Put/Get 을 하기 위한 자바 클래인 JdbcStoreTest.java 를 작성합니다.

Eclipse 개발 환경

1.2. pom.xml 작성

Maven 프로젝트에 대한 artifact는 MyFirstDatagrid 라는 이름으로 버전 0.0.1-SNAPSHOT으로 생성하였습니다.

pom.xml 파일 내용은 아래와 같습니다.


4.0.0
MyFirstDatagrid
MyFirstDatagrid
0.0.1-SNAPSHOT

6.0.1.Final
9.1-901.jdbc4

 


org.infinispan
infinispan-core
${version.org.infinispan}


org.infinispan
infinispan-cachestore-jdbc
${version.org.infinispan}


postgresql
postgresql
${version.org.postgresql}


c3p0
c3p0
0.9.1.2


2. XML 로 namedCache 정의하기

JdbcStoreTest.xml 파일에 캐시로더와 캐시스토어로 stringKeyedJdbcStore 를 사용하며 PostgreSQL DB 에 저장하고 로드하게 됩니다.
















3. 캐시를 사용하는 자바 애플리케이션 코드 작성하기

코드의 내용은 “JdbcStoreTest.xml” 파일에서 “persistentCache”에 대한 정의 내용을 읽고 stringKeyedJdbcStore 로 정의된 PostgreSQL 에 저장된 데이터를 로딩하게 됩니다.

최초 실행 시에는 데이터베이스에 저장된 데이터가 없기 때문에 “cache.get()” 실행 시 “null” 이 출력 됩니다. 다음 로직이 1~100 까지 “cache.put”을 수행하게 cache 에 데이터가 저장됨과 동시에 JDBC 를 통하여 PostgreSQL DB 에도 데이터가 저장되게 됩니다.

애플리케이션을 두 번째 실행하게 되면 첫 번째 실행 시 DB 캐시 스토어에 저장되었던 데이터가 출력되어 최초 “null” 값이 아닌 “value99” 형태로 순차적으로 값이 출력됩니다.

JdbcStoreTest.java 코드는 아래와 같습니다.

package infinispan.sample;

import org.infinispan.Cache;
import org.infinispan.manager.DefaultCacheManager;

public class JdbcStoreTest {
public static void main (String args []) throws Exception {
Cache cache = new DefaultCacheManager ( "JdbcStoreTest.xml").getCache("persistentCache");
for (int i = 1; i <= 100; i++) { System.out.println ( "Key ="+ java.lang.Integer.toString (i) + ", Value ="+ cache.get (java.lang.Integer.toString (i))); } for (int i=1; i<=100; i++) { cache.put (java.lang.Integer.toString (i), "value"+ java.lang.Integer.toString (i)); } } } [/code] [/av_textblock] [/av_one_full] [av_one_full first min_height='' vertical_alignment='av-align-top' space='' row_boxshadow='' row_boxshadow_width='10' row_boxshadow_color='' custom_margin='' margin='0px' av-desktop-margin='' av-medium-margin='' av-small-margin='' av-mini-margin='' mobile_breaking='' mobile_column_order='' border='' border_style='solid' border_color='' radius='' min_col_height='' padding='' av-desktop-padding='' av-medium-padding='' av-small-padding='' av-mini-padding='' svg_div_top='' svg_div_top_color='#333333' svg_div_top_width='100' svg_div_top_height='50' svg_div_top_max_height='none' svg_div_top_flip='' svg_div_top_invert='' svg_div_top_front='' svg_div_top_opacity='' svg_div_top_preview='' svg_div_bottom='' svg_div_bottom_color='#333333' svg_div_bottom_width='100' svg_div_bottom_height='50' svg_div_bottom_max_height='none' svg_div_bottom_flip='' svg_div_bottom_invert='' svg_div_bottom_front='' svg_div_bottom_opacity='' svg_div_bottom_preview='' fold_type='' fold_height='' fold_more='자세히 보기' fold_less='Read less' fold_text_style='' fold_btn_align='' column_boxshadow='' column_boxshadow_width='10' column_boxshadow_color='' background='bg_color' background_color='' background_gradient_direction='vertical' background_gradient_color1='#000000' background_gradient_color2='#ffffff' background_gradient_color3='' src='' background_position='top left' background_repeat='no-repeat' highlight='' highlight_size='' fold_overlay_color='' fold_text_color='' fold_btn_color='theme-color' fold_btn_bg_color='' fold_btn_font_color='' size-btn-text='' av-desktop-font-size-btn-text='' av-medium-font-size-btn-text='' av-small-font-size-btn-text='' av-mini-font-size-btn-text='' animation='' animation_duration='' animation_custom_bg_color='' animation_z_index_curtain='100' parallax_parallax='' parallax_parallax_speed='' av-desktop-parallax_parallax='' av-desktop-parallax_parallax_speed='' av-medium-parallax_parallax='' av-medium-parallax_parallax_speed='' av-small-parallax_parallax='' av-small-parallax_parallax_speed='' av-mini-parallax_parallax='' av-mini-parallax_parallax_speed='' fold_timer='' z_index_fold='' css_position='' css_position_location='' css_position_z_index='' av-desktop-css_position='' av-desktop-css_position_location='' av-desktop-css_position_z_index='' av-medium-css_position='' av-medium-css_position_location='' av-medium-css_position_z_index='' av-small-css_position='' av-small-css_position_location='' av-small-css_position_z_index='' av-mini-css_position='' av-mini-css_position_location='' av-mini-css_position_z_index='' link='' linktarget='' link_hover='' title_attr='' alt_attr='' mobile_display='' mobile_col_pos='0' id='' custom_class='' template_class='' aria_label='' av_uid='av-oudpoz' sc_version='1.0'] [av_textblock fold_type='' fold_height='' fold_more='자세히 보기' fold_less='Read less' fold_text_style='' fold_btn_align='' textblock_styling_align='' textblock_styling='' textblock_styling_gap='' textblock_styling_mobile='' size='' av-desktop-font-size='' av-medium-font-size='' av-small-font-size='' av-mini-font-size='' font_color='' color='' fold_overlay_color='' fold_text_color='' fold_btn_color='theme-color' fold_btn_bg_color='' fold_btn_font_color='' size-btn-text='' av-desktop-font-size-btn-text='' av-medium-font-size-btn-text='' av-small-font-size-btn-text='' av-mini-font-size-btn-text='' fold_timer='' z_index_fold='' id='' custom_class='' template_class='' av_uid='av-luxxqzmd' sc_version='1.0' admin_preview_bg='']

4-2. Postgres 에 저장된 데이터 확인해 보기

최초 실행 후에는 Persistence 데이터가 PostgreSQL 에 저장된 것을 확인 할 수 있습니다.

stringKeyedJdbcStore 형태로 캐시스토어를 사용하게 되면 데이터베이스에는 key 값을 Primary 로 하여 Value 는 Binary 로 저장됩니다.

Postgres 에 저장된 데이터 확인해 보기

각 레코드는 아래의 그림과 같이 저장됩니다.

Postgres 에 저장된 레코드

Reference & Related Links


  • Red Hat JBoss Data Grid 6.2 Administration and Configuration Guide - https://access.redhat.com/site/documentation/en-US/Red_Hat_JBoss_Data_Grid/6.2/html-single/Administration_and_Configuration_Guide/index.html#sect-JdbcStringBasedStores
  • Red Hat JBoss Data Grid Version Information – https://access.redhat.com/site/documentation/en-US/Red_Hat_JBoss_Data_Grid/6.2/html/Getting_Started_Guide/Red_Hat_JBoss_Data_Grid_Version_Information.html
  • JBoss Datagrid download – https://access.redhat.com/jbossnetwork/restricted/listSoftware.html?downloadType=distributions&product=data.grid&productChanged=yes

JBoss Enterprise Data Grid

JBoss Data Grid 데모 – 빠른 시작 가이드

2014-03-19/카테고리: JBoss, Tech Talk/작성자: 오픈마루 마케팅1
자세히 보기
https://i0.wp.com/www.openmaru.io/wp-content/uploads/2024/04/010_jboss_eap_datagrid_title.jpg?fit=380%2C302&ssl=1 302 380 오픈마루 마케팅1 https://www.openmaru.io/wp-content/uploads/2020/11/logo@2x.png 오픈마루 마케팅12014-03-19 23:49:162024-04-16 13:41:01JBoss Data Grid 데모 – 빠른 시작 가이드
NoSQL 데이터베이스 분류와 제품들 – SQL 없는 데이터베이스

NoSQL 데이터베이스 분류와 제품들 – SQL 없는 데이터베이스

2014-03-19/카테고리: JBoss, Tech Talk/작성자: 오픈마루 마케팅1
자세히 보기
https://i0.wp.com/www.openmaru.io/wp-content/uploads/2024/04/011_nosql_title.jpg?fit=380%2C302&ssl=1 302 380 오픈마루 마케팅1 https://www.openmaru.io/wp-content/uploads/2020/11/logo@2x.png 오픈마루 마케팅12014-03-19 00:01:462024-04-16 13:41:12NoSQL 데이터베이스 분류와 제품들 – SQL 없는 데이터베이스
JBoss Enterprise Data Grid

JBoss Data Grid PostgreSQL Cache Store 사용하기

2014-03-17/카테고리: JBoss/작성자: 오픈마루 마케팅1
자세히 보기
https://i0.wp.com/www.openmaru.io/wp-content/uploads/2024/04/010_jboss_eap_datagrid_title.jpg?fit=380%2C302&ssl=1 302 380 오픈마루 마케팅1 https://www.openmaru.io/wp-content/uploads/2020/11/logo@2x.png 오픈마루 마케팅12014-03-17 23:22:382024-04-16 13:41:24JBoss Data Grid PostgreSQL Cache Store 사용하기
Page 21 of 24«‹1920212223›»

이 글 공유하기:

  • 페이스북에 공유하려면 클릭하세요. (새 창에서 열림) Facebook
  • 클릭하여 X에서 공유 (새 창에서 열림) X
  • 클릭하여 친구에게 이메일로 링크 보내기 (새 창에서 열림) 전자우편
  • 인쇄하기 (새 창에서 열림) 인쇄
  • Reddit으로 공유하기 (새 창에서 열림) 레딧
  • Pinterest에서 공유하려면 클릭하세요 (새 창에서 열림) Pinterest
  • Telegram에 공유하려면 클릭하세요. (새 창에서 열림) Telegram
  • WhatsApp에 공유하려면 클릭하세요. (새 창에서 열림) WhatsApp

이것이 좋아요:

좋아하기 가져오는 중...

Recent Posts

  • RHEL on WSL 출시! 윈도우에서도 Red Hat 환경을 쉽게 구축하세요 2025-06-05
  • [세미나] 복잡한 MSA, AI로 쉽게 해결할 수 있는 방법 공개! 2025-06-02
  • 윈도우 Subsystem에서 RHEL 사용하기 | RHEL WSL 가이드 2025-05-29
  • Java 앱 배포, 더 빠르고 간편하게 – JBoss EAP 8.1 베타 2025-05-22
  • JBoss EAP 8.1 베타 | 엔터프라이즈 Java 애플리케이션 현대화 2025-05-12

Categories

  • APM
  • Cloud
  • Cloud Native Seminar
  • Cluster
  • gift
  • JBoss
  • Kubernetes
    • Container
  • Linux
  • Microservices Architecture
  • News
  • Newsletter
  • OPENMARU
    • Dashboard
  • OpenShift
  • Red Hat
  • Seminar
    • gift
  • Tech Talk
  • 발표자료
  • 분류되지 않음
  • 오픈나루 공지사항
  • 오픈소스

이메일로 블로그 구독하기

이 블로그를 구독하고 이메일로 새글의 알림을 받으려면 이메일 주소를 입력하세요

태그

APM cloud Cloud Native Container Docker Hybrid Cloud jboss JBoss EAP Kubernetes Kubernetes 모니터링 linux MSA Native OPENMARU OPENMARU APM OpenShift Openshift Promotion PaaS PaaS 플랫폼 Red Hat redhat RHEL tomcat Virtualization WAS Wildfly 가상화 네이티브 도커 레드햇 리눅스 모니터링 브리핑 세미나 오픈마루 오픈마루 APM 오픈시프트 주간 진짜 클라우드 컨테이너 쿠버네티스 클라우드 클라우드 네이티브 클라우드네이티브 클라우드 네이티브 세미나

Search

Search Search

오픈마루

04778 서울시 성동구 뚝섬로1길 31 906 호
(성수동1가, 서울숲M타워)

Tel : 02-469-5426 | Fax : 02-469-7247
Email : sales@openmaru.io

  • OPENMARU CLOUD APM
    • Application 모니터링
    • Openshift & Kubernetes 모니터링
    • WEB/WAS 모니터링
    • URL 모니터링
    • Cubrid 모니터링
  • 가격안내
  • 고객 레퍼런스
  • 고객지원
    • 문서
    • 사용자가이드
    • 기술지원
  • 블로그
  • 이용약관
  • 개인정보처리방침
  • 서비스수준협약
  • 회사소개
Copyright © OPENMARU, Inc. All Rights Reserved. - powered by Enfold WordPress Theme
  • Link to Facebook
  • Link to LinkedIn
  • Link to X
  • Link to Youtube
Link to: 룰 엔진으로 선언적 프로그래밍 – Drools 6.0 Link to: 룰 엔진으로 선언적 프로그래밍 – Drools 6.0 룰 엔진으로 선언적 프로그래밍 – Drools 6.0JBoss Tips & Tricks - Red Hat JBoss Enterprise Application Platform Link to: NoSQL 데이터베이스 분류와 제품들 – SQL 없는 데이터베이스 Link to: NoSQL 데이터베이스 분류와 제품들 – SQL 없는 데이터베이스 NoSQL 데이터베이스 분류와 제품들 – SQL 없는 데이터베이스NoSQL 데이터베이스 분류와 제품들 – SQL 없는 데이터...
Scroll to top Scroll to top Scroll to top
  • 한글
  • English
%d