gpt4 book ai didi

java - 将 JMS 与 JBoss 结合使用时出现 channel 结束通知异常

转载 作者:行者123 更新时间:2023-12-02 06:00:07 26 4
gpt4 key购买 nike

我正在将 JMS 与 JBoss 一起使用。但每当我运行我的消费者代码时,我总是会遇到以下异常

[org.jboss.as.naming] (Remoting "sorabh216901" task-2) JBAS011806: Channel end notification received, closing channel Channel ID 091878ba (inbound) of Remoting connection 007ce8a6 to /192.168.2.47:53318

我的消费者类别如下:

public class TopicConsumer implements MessageListener{


public static void main(String[] args) throws NamingException, JMSException {
Context context = TopicConsumer.getInitialContext();
try{
System.out.println("Entering into the main method!!!");

TopicConnectionFactory connectionFactory = (TopicConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
Topic topic = (Topic) context.lookup("jms/topic/test");
TopicConnection connection = connectionFactory.createTopicConnection("testuser", "testpassword");
TopicSession session = connection.createTopicSession(true, TopicSession.AUTO_ACKNOWLEDGE);
session.createSubscriber(topic).setMessageListener(new TopicConsumer());
connection.start();
System.out.println("Exiting from the main method!!!");
}finally{
//context.close();
}

}

public void onMessage(Message arg0) {
System.out.println("Incoming Message : " + arg0);
}


public static Context getInitialContext() throws NamingException{
Properties props = new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");
props.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
props.put(Context.PROVIDER_URL,"remote://192.168.2.47:4447");


props.put("jboss.naming.client.ejb.context", true);
// username
props.put(Context.SECURITY_PRINCIPAL, "testuser");
// password
props.put(Context.SECURITY_CREDENTIALS, "testpassword");

return new InitialContext(props);

}
}

当我运行代码时,我会在日志中获得成功的握手,即

    INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@cd0d2e, 
receiver=Remoting connection EJB receiver [connection=Remoting connection <1e03fce>,channel=jboss.ejb,nodename=sorabh216901]} on channel Channel ID 9823d1ac (outbound) of Remoting connection 004edf4a to /192.168.2.47:4447

但是程序刚刚关闭,并且在服务器日志中我收到 channel 结束通知。

请提出建议,这里有什么问题。

最佳答案

TopConsumer 的 main 方法末尾添加以下行 类:

try {
Thread.sleep(Integer.MAX_VALUE);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

这不会停止 JVM。并且您不会收到 channel 结束通知异常

关于java - 将 JMS 与 JBoss 结合使用时出现 channel 结束通知异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22743406/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com