本文整理匯總了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;
}
示例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;
}
示例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());
}
}