由于依赖性很小,HornetQ可以非常容易地嵌入到其它应用中,或者加入到一些依赖注入式的框架中, 如JBoss Microcontainer,Spring或Google Guice。
每个HornetQ服务器都有自己的超高性能的持久日志(journal)用于消息和其它信息的持久化。
采用这种独特的高效日志要比采用普通数据库作为持久层的系统拥有更高的性能。
你还可以使用一个依赖注入框架来启动HornetQ,比如JBoss Microcontainer™或Spring框架™。
那如何用spring框架来启动,开发,使用HornetQ呢?
<!-- q start --> <bean name="namingServerImpl" class="org.jnp.server.NamingBeanImpl" init-method="start" destroy-method="stop"> </bean> <!-- JNDI server. Disable this if you don't want JNDI --> <bean name="namingServer" class="org.jnp.server.Main" init-method="start" destroy-method="stop"> <property name="namingInfo" ref="namingServerImpl"></property> <property name="port" value="2099"></property> <property name="bindAddress" value="localhost"></property> <property name="rmiPort" value="2098"></property> <property name="rmiBindAddress" value="localhost"></property> </bean> <!-- MBean server --> <bean name="mbeanServer" class="java.lang.management.ManagementFactory" factory-method="getPlatformMBeanServer"> </bean> <!-- The core configuration --> <bean name="fileConfiguration" class="org.hornetq.core.config.impl.FileConfiguration" init-method="start" destroy-method="stop"> </bean> <!-- The security manager --> <bean name="hornetQSecurityManagerImpl" class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl"> </bean> <!-- 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>
然后是3个Q配置文件
hornetq-configuration.xml
hornetq-jms.xml
hornetq-users.xml
一个属性文件
jndi.properties
这个都可以从发布包里找到
加一些jar,然后就可以使用了,嵌入到工程确实很方便啊