本文整理汇总了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());
}
}