我试图让我的jms客户端通过ssl工作,但是在配置jboss之后,我有一个例外
log4j:警告找不到logger (org.jboss.logging)的appenders。log4j:WARN请正确初始化log4j系统。更多信息请见http://logging.apache.org/log4j/1.2/faq.html#noconfig。2013年3月21日下午4:20:26 cz . ble . dummy JMS主要信息:尝试获取连接工厂“JMS/RemoteConnectionFactory”2013年3月21日下午4:20:27 cz . ble . dummy JMS主要信息:在JNDI找到连接工厂“JMS/RemoteConnectionFactory”2013年3月21日下午4:20:27 cz . ble . dummy JMS主要信息:尝试获取目标“JMS/queue/Online”3月21日 正在关闭远程处理连接5c0673b4到/192.168.4.25的信道通道ID 12d4350a(入站):63316线程“main”javax . JMS . JMS异常:无法在org . hornetq . JMS . client . hornetqconnectionfactory . createconnectioninternal(hornetqconnectionfactory . Java:605)创建会话工厂 已尝试所有可用的服务器。]at org . hornetq . core . client . impl . serverlocatorimpl . createsessionfactory(serverlocatorimpl . Java:775)at 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();
}
}
}
}
这是我的独立和平.xml从jboss
<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>
有人知道我做错了什么吗?我找不到任何 jms 共同配置和客户端的工作示例 jboss as7 通过 ssl...
嗯,我不确定我是否熟悉4447端口。我相信HornetQ在5545端口监听SSL。