• 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

안전한 서비스 통신을 위한 필수 요소, mTLS의 이해와 필요성

안전한 서비스 통신을 위한 필수 요소, mTLS의 이해와 필요성

2025-03-20/in Tech Talk/by 오픈마루 마케팅0
Read more
https://i0.wp.com/www.openmaru.io/wp-content/uploads/2025/03/250317_mtls_title.webp?fit=380%2C302&ssl=1 302 380 오픈마루 마케팅0 https://www.openmaru.io/wp-content/uploads/2020/11/logo@2x.png 오픈마루 마케팅02025-03-20 10:44:032025-03-20 10:44:03안전한 서비스 통신을 위한 필수 요소, mTLS의 이해와 필요성

레드햇 Container Day 세미나 – 컨테이너와 AI 솔루션 소개

2025-02-13/in Red Hat, Seminar, Tech Talk/by 오픈마루 마케팅3
Read more
https://i0.wp.com/www.openmaru.io/wp-content/uploads/2025/02/%EB%A0%88%EB%93%9C%ED%97%B7-%EC%BB%A8%ED%85%8C%EC%9D%B4%EB%84%88-%EC%84%B8%EB%AF%B8%EB%82%98_thumbnail.webp?fit=381%2C303&ssl=1 303 381 오픈마루 마케팅3 https://www.openmaru.io/wp-content/uploads/2020/11/logo@2x.png 오픈마루 마케팅32025-02-13 13:06:242025-02-17 15:14:50레드햇 Container Day 세미나 – 컨테이너와 AI 솔루션 소개
가상화도 클라우드네이티브 thum

클라우드 네이티브 가상화 – 가상화도 클라우드 네이티브 시대

2024-11-15/in Cloud, Tech Talk/by 오픈마루 마케팅3
Read more
https://i0.wp.com/www.openmaru.io/wp-content/uploads/2024/11/%EA%B0%80%EC%83%81%ED%99%94%EB%8F%84-%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C%EB%84%A4%EC%9D%B4%ED%8B%B0%EB%B8%8C-thum.webp?fit=381%2C303&ssl=1 303 381 오픈마루 마케팅3 https://www.openmaru.io/wp-content/uploads/2020/11/logo@2x.png 오픈마루 마케팅32024-11-15 12:45:462024-11-15 12:45:46클라우드 네이티브 가상화 – 가상화도 클라우드 네이티브 시대
Page 1 of 24123›»

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to email a link to a friend (Opens in new window) Email
  • Click to print (Opens in new window) Print
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp

Like this:

Like Loading...

Recent Posts

  • JBoss EAP 8.1 베타 | 엔터프라이즈 Java 애플리케이션 현대화 2025-05-12
  • ChatGPT 프롬프트 엔지니어링, 이렇게 시작하세요! 2025-05-08
  • 올해 1분기, 사람들이 가장 많이 본 OPENMARU 콘텐츠는? 2025-04-17
  • 보안 강화의 다음 단게, mTLS를 아시나요? 2025-04-03
  • 성공적인 MSA 구축을 위한 핵심 전략 대공개! 테크 엣지 세미나 안내 2025-03-21

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
  • 발표자료
  • 분류되지 않음
  • 오픈나루 공지사항
  • 오픈소스

이메일로 블로그 구독하기

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

Tags

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