【发布时间】:2014-02-19 06:37:11
【问题描述】:
我正在尝试运行嵌入在我的应用程序中的 HornetQ。以编程方式配置会导致 this 错误。
所以我一直在尝试通过 xml 文件设置配置。服务器成功启动,但尝试创建客户端会话时出现错误。
这是我的启动代码
ClientSession session = null;
try {
EmbeddedHornetQ embedded = new EmbeddedHornetQ();
try {
embedded.start();
} catch (Exception ex) {
log.error("Error starting MQServer", ex);
throw new RuntimeException(ex);
}
ClientSessionFactory sessionFactory = HornetQClient.createServerLocatorWithoutHA(
new TransportConfiguration(
InVMConnectorFactory.class.getName())).createSessionFactory();
session = sessionFactory.createSession();
final String queueName = "queue.exampleQueue";
session.createQueue(queueName, queueName, true);
}catch(Exception ex) {
log.error("error", ex);
}
return session;
当它尝试连接时,我收到此错误:
WARNING: AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal
Jan 27, 2014 9:13:49 PM org.hornetq.core.logging.impl.JULLogDelegate info
INFO: live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=../data/journal,bindingsDirectory=../data/bindings,largeMessagesDirectory=../data/large-messages,pagingDirectory=../data/paging)
Jan 27, 2014 9:13:49 PM org.hornetq.core.logging.impl.JULLogDelegate info
INFO: Waiting to obtain live lock
Jan 27, 2014 9:13:49 PM org.hornetq.core.logging.impl.JULLogDelegate info
INFO: Using NIO Journal
Jan 27, 2014 9:13:49 PM org.hornetq.core.logging.impl.JULLogDelegate warn
WARNING: Security risk! It has been detected that the cluster admin user and password have not been changed from the installation default. Please see the HornetQ user guide, cluster chapter, for instructions on how to do this.
Jan 27, 2014 9:13:49 PM org.hornetq.core.logging.impl.JULLogDelegate info
INFO: Waiting to obtain live lock
Jan 27, 2014 9:13:49 PM org.hornetq.core.logging.impl.JULLogDelegate info
INFO: Live Server Obtained live lock
Jan 27, 2014 9:13:50 PM org.hornetq.core.logging.impl.JULLogDelegate info
INFO: Started Netty Acceptor version 3.2.3.Final-r${buildNumber} localhost:5445 for CORE protocol
Jan 27, 2014 9:13:50 PM org.hornetq.core.logging.impl.JULLogDelegate info
INFO: Started Netty Acceptor version 3.2.3.Final-r${buildNumber} localhost:5455 for CORE protocol
Jan 27, 2014 9:13:50 PM org.hornetq.core.logging.impl.JULLogDelegate info
INFO: Server is now live
Jan 27, 2014 9:13:50 PM org.hornetq.core.logging.impl.JULLogDelegate info
INFO: HornetQ Server version 2.2.5.Final (HQ_2_2_5_FINAL_AS7, 121) [8d37d5e1-87d4-11e3-80c2-a5588295b5e6] started
Jan 27, 2014 9:13:50 PM org.hornetq.core.logging.impl.JULLogDelegate warn
WARNING: Tried 1 times to connect. Now giving up on reconnecting it.
2014-01-27 21:13:50,818 ERROR c.b.o.r.AppConfigModule [main] error
org.hornetq.api.core.HornetQException: Cannot connect to server(s). Tried with all available servers.
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:619) ~[hornetq-core-2.2.5.Final.jar:?]
hornetq-configuration.xml:
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq/schema/hornetq-configuration.xsd">
<paging-directory>${data.dir:../data}/paging</paging-directory>
<bindings-directory>${data.dir:../data}/bindings</bindings-directory>
<journal-directory>${data.dir:../data}/journal</journal-directory>
<journal-min-files>10</journal-min-files>
<large-messages-directory>${data.dir:../data}/large-messages</large-messages-directory>
<connectors>
<connector name="netty">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host:localhost}"/>
<param key="port" value="${hornetq.remoting.netty.port:5445}"/>
</connector>
<connector name="netty-throughput">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host:localhost}"/>
<param key="port" value="${hornetq.remoting.netty.batch.port:5455}"/>
<param key="batch-delay" value="50"/>
</connector>
</connectors>
<acceptors>
<acceptor name="netty">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host:localhost}"/>
<param key="port" value="${hornetq.remoting.netty.port:5445}"/>
</acceptor>
<acceptor name="netty-throughput">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host:localhost}"/>
<param key="port" value="${hornetq.remoting.netty.batch.port:5455}"/>
<param key="batch-delay" value="50"/>
<param key="direct-deliver" value="false"/>
</acceptor>
</acceptors>
<security-settings>
<security-setting match="#">
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="send" roles="guest"/>
</security-setting>
</security-settings>
<address-settings>
<!--default for catch all-->
<address-setting match="#">
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
<expiry-address>jms.queue.ExpiryQueue</expiry-address>
<redelivery-delay>0</redelivery-delay>
<max-size-bytes>10485760</max-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
<address-full-policy>BLOCK</address-full-policy>
</address-setting>
</address-settings>
【问题讨论】: