요즘은 UDP multicast가 가능하더라도 데이터 통신이 차단되는 경우가 있다. 이런경우 TCP로 연결하면 해결된다.
하지만 TCP로 변경하기에 앞서 web.xml
내에 <distributable/>
설정이 제대로 되어있는지 먼저 확인부터 하도록 한다.
JBOSS-CLI 명령어를 통한 설정방법
# Delete previous settings /subsystem=jgroups/channel=ee:write-attribute(name=stack,value=udp) /subsystem=jgroups/stack=tcpping:remove /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=jgroups-host-b:remove /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=jgroups-host-a:remove # Define the socket bindings # 이부분에 클러스터로 묶어줄 멤버를 정의한다. port-offset에 유의하여 늘어난만큼 적용해줘야 한다. (기본값 7600) /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=jgroups-host-a:add(host=10.61.151.153,port=7600) /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=jgroups-host-b:add(host=10.61.151.154,port=7600) batch # Add the tcpping stack /subsystem=jgroups/stack=tcpping:add /subsystem=jgroups/stack=tcpping/transport=TCP:add(socket-binding=jgroups-tcp) # 위에서 정의한 클러스터 멤버 이름을 입력한다. /subsystem=jgroups/stack=tcpping/protocol=TCPPING:add(socket-bindings=[jgroups-host-a,jgroups-host-b]) /subsystem=jgroups/stack=tcpping/protocol=MERGE3:add /subsystem=jgroups/stack=tcpping/protocol=FD_SOCK:add /subsystem=jgroups/stack=tcpping/protocol=FD_ALL:add /subsystem=jgroups/stack=tcpping/protocol=VERIFY_SUSPECT:add /subsystem=jgroups/stack=tcpping/protocol=pbcast.NAKACK2:add /subsystem=jgroups/stack=tcpping/protocol=UNICAST3:add /subsystem=jgroups/stack=tcpping/protocol=pbcast.STABLE:add /subsystem=jgroups/stack=tcpping/protocol=pbcast.GMS:add /subsystem=jgroups/stack=tcpping/protocol=MFC:add /subsystem=jgroups/stack=tcpping/protocol=FRAG2:add # Set tcpping as the stack for the ee channel /subsystem=jgroups/channel=ee:write-attribute(name=stack,value=tcpping) run-batch reload
XML 파일내의 정의 내용
JBoss EAP 7.0 버전과 7.2 버전이 약간 다르므로 공식문서를 참고바람.
<stack name="tcpping"> <transport type="TCP" socket-binding="jgroups-tcp"/> <socket-discovery-protocol type="TCPPING" socket-bindings="jgroups-host-a jgroups-host-b"/> <protocol type="MERGE3"/> <protocol type="FD_SOCK"/> <protocol type="FD_ALL"/> <protocol type="VERIFY_SUSPECT"/> <protocol type="pbcast.NAKACK2"/> <protocol type="UNICAST3"/> <protocol type="pbcast.STABLE"/> <protocol type="pbcast.GMS"/> <protocol type="MFC"/> <protocol type="FRAG2"/> </stack> ... <outbound-socket-binding name="jgroups-host-a"> <remote-destination host="10.61.151.153" port="7700"/> <!-- port-offset 에 의해 추가된 만큼 반영되어야 함 --> </outbound-socket-binding> <outbound-socket-binding name="jgroups-host-b"> <remote-destination host="10.61.151.154" port="7700"/> <!-- port-offset 에 의해 추가된 만큼 반영되어야 함 --> </outbound-socket-binding> </socket-binding-group>