當前位置: 首頁>>代碼示例>>Java>>正文


Java RMQConnectionFactory類代碼示例

本文整理匯總了Java中com.rabbitmq.jms.admin.RMQConnectionFactory的典型用法代碼示例。如果您正苦於以下問題:Java RMQConnectionFactory類的具體用法?Java RMQConnectionFactory怎麽用?Java RMQConnectionFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RMQConnectionFactory類屬於com.rabbitmq.jms.admin包,在下文中一共展示了RMQConnectionFactory類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createConnectionFactory

import com.rabbitmq.jms.admin.RMQConnectionFactory; //導入依賴的package包/類
@Override
public ConnectionFactory createConnectionFactory() throws JMSException {
    RMQConnectionFactory cf = new RMQConnectionFactory();
    if (_host != null) {
        cf.setHost(_host);
        cf.setPort(_port != null ? _port.intValue() : (_ssl ? 5671 : 5672));
        cf.setVirtualHost(_virtualHost);
        cf.setUsername(_userName);
        cf.setPassword(_password);
        if (_ssl) {
            try {
                cf.useSslProtocol();
            } catch (NoSuchAlgorithmException e) {
                throw new JMSException("SSL not supported!");
            }
        }
    }
    if (_uri != null) {
        cf.setUri(_uri);
    }
    return cf;
}
 
開發者ID:erik-wramner,項目名稱:JmsTools,代碼行數:23,代碼來源:RabbitJmsConsumer.java

示例2: connectionFactory

import com.rabbitmq.jms.admin.RMQConnectionFactory; //導入依賴的package包/類
@Bean
ConnectionFactory connectionFactory() {
    
    log.info("Connecting to RabbitMQ at URI:"+amqpURI);
    RMQConnectionFactory rmqcf = new RMQConnectionFactory();
    try {
        if(!"default".equals(amqpURI)) {
        rmqcf.setUri(amqpURI);
        }
        else {
            rmqcf.setHost(host);
            rmqcf.setUsername(username);
            rmqcf.setPassword(password);
            if(vhost == null || " ".equals(vhost)) { vhost="/"; }
            rmqcf.setVirtualHost(vhost);
            System.out.println("The URI: "+rmqcf.getUri());
        }
    } catch(Exception e) {
        rmqcf = null;
        log.error(e.toString());
    }
    return rmqcf;
}
 
開發者ID:sdeeg-pivotal,項目名稱:rabbitmq-jms-samples,代碼行數:24,代碼來源:SpringRabbitJMSConfig.java

示例3: init

import com.rabbitmq.jms.admin.RMQConnectionFactory; //導入依賴的package包/類
public void init() throws InitException {

        RMQConnectionFactory implFactory = new RMQConnectionFactory();

        try {
            String uri = "amqp://" + getUser() + ":" + getPassword() + "@" + getHost() + ":" + getPort();

            if (!getVhost().equals("/")) {
                uri = uri + "/" + getVhost();
            }
            implFactory.setUri(uri);
            factory = implFactory;
            connection = factory.createConnection(getUser(), getPassword());
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            dest = new RMQDestination(getDestination(), getDestType() == DestType.QUEUE , false);
            producer = session.createProducer(dest);
            connection.start();
        } catch (JMSException e) {
            throw new InitException(e.fillInStackTrace());
        }
    }
 
開發者ID:matthiaskaiser,項目名稱:jmet,代碼行數:22,代碼來源:RabbitMQTarget.java


注:本文中的com.rabbitmq.jms.admin.RMQConnectionFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。