我试图让我的 jms 客户端通过 ssl 工作,但是在配置 jboss 之后我有一个异常
log4j:WARN 找不到记录器 (org.jboss.logging) 的附加程序。log4j:WARN 请正确初始化 log4j 系统。log4j:WARN 见 http://logging.apache.org/log4j/1.2/faq.html#noconfig了解更多信息。2013 年 3 月 21 日下午 4:20:26 cz.bleble.DummyJMS 主要信息:尝试获取连接工厂“jms/RemoteConnectionFactory” 2013 年 3 月 21 日下午 4:20:27 cz.bleble.DummyJMS 主要信息:找到连接工厂“ JNDI 中的 jms/RemoteConnectionFactory” 2013 年 3 月 21 日下午 4:20:27 cz.bleble.DummyJMS 主要信息:尝试获取目标“jms/queue/Online” 2013 年 3 月 21 日下午 4:20:27 cz.bleble.DummyJMS主要信息:在 JNDI 中找到目标“jms/queue/Online” 2013 年 3 月 21 日下午 4:20:27 cz.bleble.DummyJMS 主要严重:无法创建会话工厂 15:20:27,908 信息 [org.jboss.as.命名](远程处理“esekilx5066”任务 3)JBAS011806:收到通道结束通知,关闭远程连接 5c0673b4 到 /192.168.4.25 的通道通道 ID 12d4350a(入站):63316 线程“主”javax.jms.JMSException 中的异常:无法在 org.hornetq.jms.client.HornetQConnectionFactory.createConnection( HornetQConnectionFactory.java:119) 在 cz.bleble.DummyJMS.main(DummyJMS.java:94) 原因:HornetQException[errorCode=2 message=无法连接到服务器。尝试使用所有可用的服务器。] 在 org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:775) 在 org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601) ...还有 2 个 无法在 cz.bleble.DummyJMS 的 org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119) 的 org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605) 创建会话工厂。 main(DummyJMS.java:94) 原因:HornetQException[errorCode=2 message=无法连接到服务器。尝试使用所有可用的服务器。] 在 org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:775) 在 org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601) ...还有 2 个 无法在 cz.bleble.DummyJMS 的 org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119) 的 org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605) 创建会话工厂。 main(DummyJMS.java:94) 原因:HornetQException[errorCode=2 message=无法连接到服务器。尝试使用所有可用的服务器。] 在 org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:775) 在 org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601) ...还有 2 个 createConnection(HornetQConnectionFactory.java:119) at cz.bleble.DummyJMS.main(DummyJMS.java:94) 原因:HornetQException[errorCode=2 message=无法连接到服务器。尝试使用所有可用的服务器。] 在 org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:775) 在 org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601) ...还有 2 个 createConnection(HornetQConnectionFactory.java:119) at cz.bleble.DummyJMS.main(DummyJMS.java:94) 原因:HornetQException[errorCode=2 message=无法连接到服务器。尝试使用所有可用的服务器。] 在 org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:775) 在 org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601) ...还有 2 个
这是我的客户:
package cz.bleble;
import java.util.logging.Logger;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
public final class DummyJMS {
private static final Logger LOG = Logger.getLogger(DummyJMS.class.getName());
private static final String DEFAULT_MESSAGE = "Hello, World!";
private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
private static final String DEFAULT_DESTINATION = "jms/queue/Online";
private static final String DEFAULT_MESSAGE_COUNT = "1";
private static final String DEFAULT_USERNAME = "user";
private static final String DEFAULT_PASSWORD = "pass";
private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
private static final String PROVIDER_URL = "remote://192.168.4.25:4447";
public static void main(final String[] args) throws Exception {
ConnectionFactory connectionFactory = null;
Connection connection = null;
Session session = null;
MessageProducer producer = null;
MessageConsumer consumer = null;
Destination destination = null;
TextMessage message = null;
Context context = null;
try {
// Set up the context for the JNDI lookup
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "true");
env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));
env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", DEFAULT_USERNAME));
env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", DEFAULT_PASSWORD));
env.put("jboss.naming.client.ejb.context", true);
context = new InitialContext(env);
// Perform the JNDI lookups
String connectionFactoryString = System.getProperty("connection.factory", DEFAULT_CONNECTION_FACTORY);
LOG.info("Attempting to acquire connection factory \"" + connectionFactoryString + "\"");
connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryString);
LOG.info("Found connection factory \"" + connectionFactoryString + "\" in JNDI");
String destinationString = System.getProperty("destination", DEFAULT_DESTINATION);
LOG.info("Attempting to acquire destination \"" + destinationString + "\"");
destination = (Destination) context.lookup(destinationString);
LOG.info("Found destination \"" + destinationString + "\" in JNDI");
// Create the JMS connection, session, producer, and consumer
connection = connectionFactory.createConnection(System.getProperty("username", DEFAULT_USERNAME), System.getProperty("password", DEFAULT_PASSWORD));
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(destination);
consumer = session.createConsumer(destination);
connection.start();
int count = Integer.parseInt(System.getProperty("message.count", DEFAULT_MESSAGE_COUNT));
String content = System.getProperty("message.content", DEFAULT_MESSAGE);
LOG.info("Sending " + count + " messages with content: " + content);
// Send the specified number of messages
for (int i = 0; i < count; i++) {
message = session.createTextMessage(content);
producer.send(message);
}
// Then receive the same number of messages that were sent
for (int i = 0; i < count; i++) {
message = (TextMessage) consumer.receive(5000);
LOG.info("Received message with content " + message.getText());
}
} catch (Exception e) {
LOG.severe(e.getMessage());
throw e;
} finally {
// closing the connection takes care of the session, producer, and consumer
if (connection != null) {
connection.close();
}
if (context != null) {
context.close();
}
}
}
}
这是我来自 jboss 的standalone.xml 的平安
<server xmlns="urn:jboss:domain:1.3">
<extensions>
...
<extension module="org.jboss.as.messaging"/>
...
</extensions>
...
<profile>
...
<subsystem xmlns="urn:jboss:domain:messaging:1.2">
<hornetq-server>
<persistence-enabled>true</persistence-enabled>
<security-enabled>true</security-enabled>
<journal-type>NIO</journal-type>
<journal-file-size>102400</journal-file-size>
<journal-min-files>2</journal-min-files>
<connectors>
<netty-connector name="netty-throughput" socket-binding="messaging-throughput">
<param key="batch-delay" value="50"/>
</netty-connector>
<in-vm-connector name="in-vm" server-id="0"/>
<netty-connector name="netty" socket-binding="messaging">
<param key="ssl-enabled" value="true"/>
<param key="key-store-path" value="/keystore"/>
<param key="key-store-password" value="changeme"/>
</netty-connector>
</connectors>
<acceptors>
<netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
<param key="batch-delay" value="50"/>
<param key="direct-deliver" value="false"/>
</netty-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
<netty-acceptor name="netty" socket-binding="messaging">
<param key="ssl-enabled" value="true"/>
<param key="key-store-path" value="/keystore"/>
<param key="key-store-password" value="changeme"/>
<param key="trust-store-path" value="/truststore"/>
<param key="trust-store-password" value="changeme"/>
</netty-acceptor>
</acceptors>
<security-settings>
<security-setting match="#">
<permission type="send" roles="user"/>
<permission type="consume" roles="user"/>
<permission type="createDurableQueue" roles="user"/>
<permission type="deleteDurableQueue" roles="user"/>
<permission type="createNonDurableQueue" roles="user"/>
<permission type="deleteNonDurableQueue" roles="user"/>
</security-setting>
</security-settings>
<address-settings>
<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>
<address-full-policy>BLOCK</address-full-policy>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
</address-setting>
</address-settings>
<jms-connection-factories>
<connection-factory name="InVmConnectionFactory">
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/ConnectionFactory"/>
<entry name="java:/XAConnectionFactory"/>
</entries>
</connection-factory>
<connection-factory name="RemoteConnectionFactory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
</entries>
</connection-factory>
<pooled-connection-factory name="hornetq-ra">
<transaction mode="xa"/>
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/JmsXA"/>
</entries>
</pooled-connection-factory>
</jms-connection-factories>
<jms-destinations>
<jms-queue name="Online">
<entry name="java:jboss/exported/jms/queue/Online"/>
</jms-queue>
</jms-destinations>
</hornetq-server>
</subsystem>
...
</profile>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<socket-binding name="messaging" port="5445"/>
<socket-binding name="messaging-group" port="0" multicast-address="${jboss.messaging.group.address:231.7.7.7}" multicast-port="${jboss.messaging.group.port:9876}"/>
<socket-binding name="messaging-throughput" port="5455"/>
<socket-binding name="osgi-http" interface="management" port="8090"/>
<socket-binding name="remoting" port="4447"/>
...
</socket-binding-group>
</server>
有人知道我做错了什么吗?我找不到 jboss as7 over ssl 的 jms 配置和客户端的任何工作示例...