2010-12-29 5 views
3

Ich versuche, HornetQ und die Möglichkeit der Einbettung in eine Federanwendung zu bewerten. Um mit einem einfachen Setup zu beginnen, versuche ich es nur wie folgt zu initialisieren. Ich habe nicht viel Dokumentation darüber gefunden, wie man das macht, abgesehen von der Tatsache, dass "du kannst".Einbetten von HornetQ im Frühjahr

Ich bin mit Feder 3 und HornetQ 2.1.1GA

My Spring-Konfiguration wie folgt aussieht, aber wenn Theres eine einfachere Konfiguration sauberer, es wäre besser. Ich möchte den minimalistischen Ansatz und dann darauf aufbauen

<?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> 

Mit dieser Config .: ich die Störung erhalte:

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) 

Sein etwas offensichtlich im Zusammenhang mit JNDI sein muss, aber ich würde schätzen die richtige minimalistische Konfiguration, um damit zu beginnen und später darauf zu erweitern. Die HornetQ-Konfigurationsdateien sind die Standardkonfigurationsdateien, die mit der Verteilung geliefert werden (Standardwarteschlangen, Standardbenutzer usw.)

Antwort

2

Sie müssen die JMS-Warteschlangen definieren, die Sie dem Server hinzufügen möchten, und eine leere Liste von JNDI-Bindungen angeben jede Warteschlange. Fügen Sie dazu Ihrer JMSServerManagerImpl-Bean-Definition ein JMSConfigurationImpl hinzu. Zum Beispiel, wenn Sie eine Warteschlange „heißt test“ genannt definieren müssen:

<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> 

Da der zweite und dritte Konstruktor args eine Liste der Warteschlange und das Thema Konfigurationen annehmen, können Sie beliebig viele Warteschlangen und Themen hinzufügen, wie Sie mögen. Für mehr als ein oder zwei ist es wahrscheinlich am besten, ein Spring-Vorlagenobjekt zu erstellen.