티스토리 뷰

728x170

 포스팅은 EJB Clustering에 대한 가이드입니다.



I.  시스템 구성

Nodeclustering, ejb clustering, Transaction test 를 위한 구성 및 테스트를 위해 작성했습니다.

 

1. 구축 환경 

 

 


    세부내용

    

  

2. 환경 설정

1) tx_test.jsp

1. transaction init

UserTransaction tx = (UserTransaction) ctx_.lookup("java:comp/UserTransaction");

 

2. transaction begin

tx.begin();

 

3. DB lookup

ds1=(DataSource)ctx.lookup("jdbc/ediappXA");

      conDs=ds1.getConnection();

      stmt=conDs.createStatement();

// insert 1

                

4. remote ejb call

FrontBeanRemote remote = (FrontBeanRemote) ctx.lookup("webedi.interface");

 

5. local ejb call

      TestSessionBeanLocal localBean =        (TestSessionBeanLocal)ctx.lookup(TestBean);

ds2=(DataSource)ctx.lookup("jdbc/ediappXA");

      conDs=ds2.getConnection();

      stmt=conDs.createStatement();

      // insert 2

 

6. transaction end

tx.commit();  or  tx.rollback();

  

2) remote ejb (EJB 3.0)

[ejb 선언]

 

@Stateless(mappedName = "webedi.interface")

@TransactionManagement(TransactionManagementType.CONTAINER)

@TransactionAttribute(TransactionAttributeType.REQUIRED)

 


[ejb clusterting 설정 jeus-ejb-dd.xml]


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<jeus-ejb-dd xmlns="http://www.tmaxsoft.com/xml/ns/jeus" version="6.0">

    <beanlist>

          <jeus-bean>

             <ejb-name>FrontBean</ejb-name>

             <clustering>

                    <enable-clustering>true</enable-clustering>

             </clustering>

          </jeus-bean>

    </beanlist>

</jeus-ejb-dd>


[jndi 확인 내용]


[ibmtest:/user/mkko/jeus68/config/ibmtest]$ ja

jndilist

JEUS 6.0 (Fix#8) administration tool

ibmtest>List of the context /

        name : __jeus_cl@43_webedi.interface#_remote_biz_home_$addr$_ibmtest:9736, class : jeus.jndi.jns.util.RMIStubWrapper

        name : __jeus_cl@43_webedi.interface#sample.ejb.FrontBeanRemote_$addr$_ibmtest:9736, class : javax.naming.Reference

        name : __jeus_cl@43_webedi.interface_$addr$_ibmtest:9736, class : javax.naming.Reference

        name : jdbc, class : javax.naming.Reference

        name : mgmt, class : javax.naming.Reference

        name : tbds, class : jeus.jndi.jns.common.PropertyReference

        name : test, class : jeus.jndi.jns.common.PropertyReference

        name : webedi.interface, class : jeus.jndi.jns.common.DynamicLinkRef

        name : webedi.interface#_remote_biz_home, class : jeus.jndi.jns.common.DynamicLinkRef

        name : webedi.interface#sample.ejb.FrontBeanRemote, class : jeus.jndi.jns.common.DynamicLinkRef

        end of list

 

ibmtest>


  

3) local ejb (EJB 3.0)

[ejb 선언]

 

@Stateless(mappedName = "TestBean")

@TransactionManagement(TransactionManagementType.CONTAINER)

@TransactionAttribute(TransactionAttributeType.REQUIRED)

 

[ejb clusterting 설정 jeus-ejb-dd.xml]


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<jeus-ejb-dd xmlns="http://www.tmaxsoft.com/xml/ns/jeus" version="6.0">

    <beanlist>

          <jeus-bean>

             <ejb-name>TestSessionBean</ejb-name>

             <single-vm-only>true</single-vm-only>

          </jeus-bean>

    </beanlist>

</jeus-ejb-dd>

 

     4) JEUS Node clustering 설정 (EJB Clustering을 위해 설정)

[JEUSMain.xml]


1.  aix JEUS

<node>

      <name>ibmtest</name>

     … container 설정 등 요약

   </node>

<node>

      <name>suntest</name>   : 다른 내용은 따로 없어도 됨

   </node>

 

2. sun JEUS

<node>

      <name>suntest</name>

     … container 설정 등 요약

   </node>

<node>

      <name>ibmtest</name>   : 다른 내용은 따로 없어도 됨

   </node>

 

[vhost.properties]


1.  aix JEUS

jeus.vhost.enabled=true

ibmtest=ibmtest:9736

suntest=192.168.1.220:22736

 

2. sun JEUS

jeus.vhost.enabled=true

suntest=suntest:22736

ibmtest=192.168.1.221:9736


[application code 수정내용]


import java.util.*;

import javax.naming.InitialContext;

 

Properties props = null;

                        InitialContext ctx = null;

                        props = new Properties();

                        props.put("java.naming.factory.initial", "jeus.jndi.JNSContextFactory");

                        props.put("java.naming.provider.url", "ibmtest:9736, suntest:22736");

                        ctx = new InitialContext(props);

 

[jndi 등록 내용]


[ibmtest:/user/mkko/jeus68/config/ibmtest]$ ja

ibmtest>jndilist

List of the context /

        name : __jeus_cl@43_webedi.interface#_remote_biz_home_$addr$_ibmtest:9736, class : jeus.jndi.jns.util.RMIStubWrapper

        name : __jeus_cl@43_webedi.interface#sample.ejb.FrontBeanRemote_$addr$_ibmtest:9736, class : javax.naming.Reference

        name : __jeus_cl@43_webedi.interface_$addr$_ibmtest:9736, class : javax.naming.Reference

        name : __jeus_cl@45_webedi.interface#_remote_biz_home_$addr$_suntest:22736, class : jeus.jndi.jns.util.RMIStubWrapper

        name : __jeus_cl@45_webedi.interface#sample.ejb.FrontBeanRemote_$addr$_suntest:22736, class : javax.naming.Reference

        name : __jeus_cl@45_webedi.interface_$addr$_suntest:22736, class : javax.naming.Reference

        name : jdbc, class : javax.naming.Reference

        name : mgmt, class : javax.naming.Reference

        name : tbds, class : jeus.jndi.jns.common.PropertyReference

        name : test, class : jeus.jndi.jns.common.PropertyReference

        name : webedi.interface, class : jeus.jndi.jns.common.DynamicLinkRef

        name : webedi.interface#_remote_biz_home, class : jeus.jndi.jns.common.DynamicLinkRef

        name : webedi.interface#sample.ejb.FrontBeanRemote, class : jeus.jndi.jns.common.DynamicLinkRef

        end of list

 

 비고내용

    -Djeus.jndi.clusterlink.selection-policy = locallinkPreference/roundrobin/random

    # default value : locallinkPreference 입니다.

  

5)  XA DataSource 설정

[JEUSMain.xml]


<database>

            <vendor>oracle</vendor>

            <export-name>jdbc/ediappXA</export-name>

            <data-source-class-name>oracle.jdbc.xa.client.OracleXADataSource</data-source-class-name>

            <data-source-type>XADataSource</data-source-type>

            <database-name>ora10g</database-name>

            <port-number>1521</port-number>

            <server-name>192.168.1.220</server-name>

            <user>scott</user>

                <password>tiger</password>

                <driver-type>thin</driver-type>

                <stmt-query-timeout>3600000</stmt-query-timeout>

                <connection-pool>

                    <pooling>

                        <min>2</min>

                        <max>30</max>

                        <step>1</step>

                        <period>3600000</period>

                    </pooling>

                </connection-pool>

</database> 


 비고내용

LocalXADataSource로 설정 하는 경우 동일 container에서 전체 transaction 처리가 되는 경우 사용 가능.(process가 다른 경우 resource manager가 달라져서 사용할 수 없음)

그리드형
댓글
댓글쓰기 폼