java - jms Could not connect to broker URL: tcp://localhost:61616.
伊谢尔伦
伊谢尔伦 2017-04-17 16:25:56
0
0
863

看jms消息服务 代码如下
报错的地方是 QueueConnection qcConnection = qFactory.createQueueConnection();
jodi的配置是 :

java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url=tcp://loclhost:61616
java.naming.security.principal=system
java.naming.cesurity.credentials=manager

#connectionFactoryNames=QueueCF
topic.topic1 = jms.topic1

connectionFactoryNames = QueueCF
queue.LoanRequestQ = jms.LoanRequestQ
queue.LoanResponseQ = jms.LoanResponseQ

代码如下 :



package chapter4.p2p;

import java.util.Enumeration;

import javax.jms.ConnectionMetaData;
import javax.jms.JMSException;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/*
 * 获取 jndi中的元数据
 */
public class MetaData {
    public static void main(String[] args) {
        try {
            Context context = new InitialContext();
            QueueConnectionFactory qFactory  = (QueueConnectionFactory) context.lookup("QueueCF");
            System.out.println(qFactory);
            
            // createQueueConnection() 报了 Could not connect to broker URL: tcp://10.183.47.191:61616. Reason: java.net.ConnectException: Connection refused
            QueueConnection qcConnection  = qFactory.createQueueConnection();
            qcConnection.start();
            
            ConnectionMetaData metaData = qcConnection.getMetaData();
            System.out.println("jms version " + metaData.getJMSMajorVersion()+"."+metaData.getJMSMinorVersion());
            System.out.println("jms provider " + metaData.getJMSProviderName());
            System.out.println("jmsx properties supported :");
            Enumeration e = metaData.getJMSXPropertyNames();
            while (e.hasMoreElements()) {
                System.out.println(" " + e.nextElement());
            }
        } catch (NamingException e) {
            
            e.printStackTrace();
        } catch (JMSException e) {
            e.printStackTrace();
            System.exit(1);
        }
        
    }
}

百度l mac下擦找端口 lsof -i tcp:61616 但是一直没显示信息 ,请问这个是什么问题呢 ?是端口占用还是jndi的配置不对 ?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

모든 응답(0)
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿