JBoss Messaging - 해당되는 글 2건
JBoss 의 JMS서버의 queue를 모니터링하는 JMX Code입니다. jsp파일로 되어 있으며 복사해서 사용하면 됩니다.

아래의 파일이 실행되어 모니터링되려면 $SERVER_HOME/deploy/jboss-messaging.sar/messaging-service.xml 파일의 다음의 attribute를 true로 바꿔야 합니다.
<attribute name="EnableMessageCounters">true</attribute>

그리고 메시지를 샘플링하는 주기를 적절하게 주면 됩니다.
<attribute name="MessageCounterSamplePeriod">5000</attribute>


<%@ page language="java" contentType="text/html; charset=UTF-8"   pageEncoding="UTF-8" import="javax.naming.*, java.util.*,javax.management.*,org.jboss.jms.server.destination.*,org.jboss.jmx.adaptor.rmi.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--meta http-equiv="refresh" content="5"-->
<link href="style.css" rel=stylesheet type="text/css">
<title>Insert title here</title>
</head>
 
<body leftmargin=15 topmargin=10>
<center><p>
<br>
 
<table width="600" cellpadding="7" cellspacing="0" border="1" bordercolordark="WHITE" bordercolorlight="BLACK">
<tr bgcolor=#E8EEEC>
<%
    String type = "Queue";
 
    Hashtable<String,String> env = new Hashtable<String,String>();
    String factory = "org.jboss.security.jndi.JndiLoginInitialContextFactory";
    env.put(Context.INITIAL_CONTEXT_FACTORY, factory);
    String url = "jnp://127.0.0.1:1099";
    env.put(Context.PROVIDER_URL, url);
    env.put(Context.SECURITY_CREDENTIALS, "admin");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    Context ctx = new InitialContext(env);
    RMIAdaptor server = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor");
%>
 
<td align center>Queue Name</td>
<td align center>Total Count</td>
<td align center>Current Count</td>
<td align center>Consumer Count</td>
<td align center>Delivering Count</td>
</tr>
<tr>
<td align center>queue/A</td>
<%
    String queueName = "A";
 
    // Get the MBeanInfo for the JNDIView MBean
    String targetName = "jboss.messaging.destination:service=" + type + ",name=" + queueName;
    ObjectName objName = ObjectName.getInstance(targetName);
 
    QueueMBean queueMBean = (QueueMBean) MBeanServerInvocationHandler.newProxyInstance(server, objName, QueueMBean.class, false);
 
    int totalMessageCount = 0;
    int currentMessageCount = 0;
 
    totalMessageCount = queueMBean.getMessageCounter().getCount();
    currentMessageCount = queueMBean.getMessageCount();
%>
<td align center><%= totalMessageCount %></td>
<td align center><%= currentMessageCount %></td>
<td align center><%= queueMBean.getConsumerCount() %></td>
<td align center><%= queueMBean.getDeliveringCount() %></td>
</tr>
<tr>
<td align center>queue/B</td>
<%
    queueName = "B";
 
    // Get the MBeanInfo for the JNDIView MBean
    targetName = "jboss.messaging.destination:service=" + type + ",name=" + queueName;
    objName = ObjectName.getInstance(targetName);
 
    queueMBean = (QueueMBean) MBeanServerInvocationHandler.newProxyInstance(server, objName, QueueMBean.class, false);
 
    totalMessageCount = 0;
    currentMessageCount = 0;
 
    totalMessageCount = queueMBean.getMessageCounter().getCount();
    currentMessageCount = queueMBean.getMessageCount();
%>
<td align center><%= totalMessageCount %></td>
<td align center><%= currentMessageCount %></td>
<td align center><%= queueMBean.getConsumerCount() %></td>
<td align center><%= queueMBean.getDeliveringCount() %></td>
</tr>
</table>
|

이 문제를 해결하기 위하여 Spring JMS의 configuration을 수정하여야 합니다. 기본적으로 Spring은 Connection URL을 여러 개(예:jnp://serverip:port,serverip:port)로 주었을 때 최초의 lookup url만을 인식하여 exception이 발생하게 됐을 경우 다른 노드가 아닌 같은 노드로의 접속만을 무한대로 시도하게 되는 단점을 가지고 있습니다(Spring 3.0 개선 가능)

 이는 JBoss 뿐만 아니라 WebLogic도 같은 종류의 에러가 발생되고 있습니다. WebLogic 또한 jmsTemplate을 이용하여 URL List를 주었을 때 secondary url로 fail-over가 안되는 현상을 다음의 내용에서 확인하실 수 있습니다. (참조 : http://jira.springframework.org/browse/SPR-4720)

“I've followed this issue for few days as I face the similar problem. I came to the same workaround but it didn't work for me as I use cluster address to my weblogic cluster like t3://192.168.42.58:8001,192.168.42.58:9001

If I use single node weblogic instance, it works just fine. When I use two nodes failover still works but only when I shutdown first node and then start it again. However when I try to shutdown the first node and migrate JMS server to the second node my Spring client doesn't failover. I get this exception:

May 18, 2008 9:14:37 PM org.springframework.jms.listener.DefaultMessageListenerContainer handleListenerSetupFailure
SEVERE: Setup of JMS message listener invoker failed - trying to recover
weblogic.jms.common.JMSException: Destination not found”

 이를 해결하기 위한 방법은 다음의 configuration을 Spring JMS Configuration file에 추가도록 합니다.

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
                <!-- for server -->
                <prop key="java.naming.provider.url">10.64.160.179:1299,10.64.160.217:1299</prop>                <prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop>
            </props>
        </property>
    </bean>

 <bean id="jmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName">
            <value>/ConnectionFactory</value>
        </property>
        <property name="cache" value="false"/>
        <property name="proxyInterface" value="javax.jms.ConnectionFactory"/>
        <!-- Fails both with and without the following two elements defined -->
        <!-- <property name="lookupOnStartup" value="false" /> -->
        <!-- <property name="proxyInterface" value="javax.jms.ConnectionFactory" /> -->
        <!-- END optional -->
    </bean>



 

<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="connectionFactory">
<ref bean="cachingConnectionFactory" />
</property>
        <property name="destination"><ref bean="receiveDestination" /></property>
        <property name="concurrentConsumers" value="3" />
        <property name="recoveryInterval" value="2000" />
        <property name="messageListener" ref="messageListener" />
    </bean>


Test Sequence
1.      1번, 2번 Messaging Server를 기동시키십시오.
2.      1번의 application를 기동시키십시오. 이 때 기본적으로 1번으로 접속을 시도하게 되며 연결을 유지하게 됩니다.
3.      다음의 애플리케이션을 구동시켜 1번으로 메시지를 전송해 봅니다.
/app/test> send.sh
4.      1번의 Messaging Server를 kill.sh로 shutdown시키십시오.
5.      다음의 애플리케이션을 다시 한 번 구동시켜 메시지를 전송합니다.
/app/test> send.sh    
메시지는 자동으로 83번으로 가게 되며 이미 fail-over된 tracking-server는 83번에서 메시지를 전송받게 됩니다.

위의 fail-over상황은 server의 serverlog/server.log 파일에서 debug 모드 fail-over되는 것을 확인하실 수 있습니다.

|

놀새~'s Blog is powered by Daum & tistory