2010-12-29 5 views
3

HornetQ와 스프링 애플리케이션에 포함시킬 가능성을 평가하려고합니다. 간단한 설정으로 시작하려면 다음과 같이 초기화하려고합니다. 나는 이것을 할 수있는 방법에 대한 많은 문서를 찾지 못했고, '할 수있다'는 사실을 제외하고는.스프링에 HornetQ 포함하기

나는 봄 3 HornetQ 2.1.1GA

내 스프링 구성을 사용하고하는 것은 그러나 프로그래머가 될 것 간단한 청소기 구성 나은 경우, 다음과 같습니다. 내가 먼저 최소한의 접근 방식을 원하고 그 때 나는 오류가 점점 오전이 설정으로

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> 


<bean name="mbeanServer" class="java.lang.management.ManagementFactory" factory-method="getPlatformMBeanServer" /> 

<bean name="fileConfiguration" class="org.hornetq.core.config.impl.FileConfiguration" init-method="start" destroy-method="stop" /> 

<bean name="hornetQSecurityManagerImpl" class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl" /> 

<!-- The core server --> 
<bean name="hornetQServerImpl" class="org.hornetq.core.server.impl.HornetQServerImpl"> 
<constructor-arg ref="fileConfiguration" /> 
<constructor-arg ref="mbeanServer" /> 
<constructor-arg ref="hornetQSecurityManagerImpl" /> 
</bean> 

<!-- The JMS server --> 
<bean name="jmsServerManagerImpl" class="org.hornetq.jms.server.impl.JMSServerManagerImpl" init-method="start" destroy-method="stop" > 
<constructor-arg ref="hornetQServerImpl" /> 
</bean> 

    <bean name="connectionFactory" class="org.hornetq.jms.client.HornetQConnectionFactory" > 
<constructor-arg> 
    <bean class="org.hornetq.api.core.TransportConfiguration"> 
    <constructor-arg value="org.hornetq.integration.transports.netty.NettyConnectorFactory" /> 
    <constructor-arg> 
    <map key-type="java.lang.String" value-type="java.lang.Object"> 
    <entry key="port" value="5445"></entry> 
    </map> 
    </constructor-arg> 
    </bean> 
</constructor-arg> 
</bean> 

<bean name="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> 
<property name="connectionFactory" ref="connectionFactory"></property> 
</bean> 

</beans> 

을 .: 구축 :

SEVERE: Unable to deploy node [queue: null] DLQ 
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial 
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) 
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) 
... 
29-Dec-2010 18:16:34 org.hornetq.core.logging.impl.JULLogDelegate error 
SEVERE: Unable to deploy node [queue: null] ExpiryQueue 
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial 
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) 
... 
9-Dec-2010 18:16:34 org.hornetq.core.logging.impl.JULLogDelegate error 
SEVERE: Unable to deploy node [queue: null] ExampleQueue 
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial 
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) 
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) 
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) 

그것의 JNDI 관련된 분명 뭔가해야합니다,하지만 난 감사하겠습니다 적절한 최소한의 구성으로 시작한 다음 나중에 확장하십시오. HornetQ 구성 파일은 배포와 함께 제공되는 기본 구성 파일입니다 (기본 대기열, 기본 사용자 등)

답변

2

서버에 추가하려는 JMS 대기열을 정의하고 다음에 대해 JNDI 바인딩의 빈 목록을 지정해야합니다. 각 대기열. 이렇게하려면 JMSConfigurationImpl을 JMSServerManagerImpl Bean 정의에 추가하십시오. 당신이 "testqueue"라는 큐 정의해야하는 경우 예를 들어, : 두 번째와 세 번째 생성자 인수 대기열 및 주제 설정의 목록을 가지고 있기 때문에

<bean id="hornetQJmsConfig" class="org.hornetq.jms.server.config.impl.JMSConfigurationImpl"> 
    <constructor-arg index="0"> 
     <list/> 
    </constructor-arg> 
    <!-- Queue configurations --> 
    <constructor-arg index="1"> 
     <list> 
     <bean class="org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl"> 
      <!-- Name --> 
      <constructor-arg index="0" value="testqueue"/> 
      <!-- Selector --> 
      <constructor-arg index="1"><null/></constructor-arg> 
      <!-- Durable queue --> 
      <constructor-arg index="2" value="true"/> 
      <!-- JNDI bindings, empty list for none --> 
      <constructor-arg index="3"><list/></constructor-arg> 
     </bean> 
     </list> 
    </constructor-arg> 
    <!-- Topic configurations --> 
    <constructor-arg index="2"> 
     <list/> 
    </constructor-arg> 
    </bean> 

을 당신이 원하는대로, 당신은 많은 대기열 및 주제를 추가 할 수 있습니다. 하나 또는 두 개 이상인 경우 Spring 템플리트 객체를 만드는 것이 가장 좋습니다.