本文整理匯總了Java中org.apache.activemq.ActiveMQConnectionFactory.setUserName方法的典型用法代碼示例。如果您正苦於以下問題:Java ActiveMQConnectionFactory.setUserName方法的具體用法?Java ActiveMQConnectionFactory.setUserName怎麽用?Java ActiveMQConnectionFactory.setUserName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.activemq.ActiveMQConnectionFactory
的用法示例。
在下文中一共展示了ActiveMQConnectionFactory.setUserName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: connectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //導入方法依賴的package包/類
@Bean(name="connectionFactory")
public ConnectionFactory connectionFactory(){
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
// activeMQConnectionFactory.setUseAsyncSend(true);
activeMQConnectionFactory.setUserName(jmsUserName);
activeMQConnectionFactory.setPassword(jmsPassword);
activeMQConnectionFactory.setBrokerURL(jmsBrokerUrl);
// 默認重複投遞6次將轉發到死信隊列,改為無限次數
// RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
// redeliveryPolicy.setMaximumRedeliveries(-1);
//
// activeMQConnectionFactory.setRedeliveryPolicy(redeliveryPolicy);
PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(activeMQConnectionFactory);
pooledConnectionFactory.setMaxConnections(jmsMaxPooledConnections);
// CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(pooledConnectionFactory);
// cachingConnectionFactory.setSessionCacheSize(10);
return pooledConnectionFactory;
}
示例2: buildOpsMQListenerContainer
import org.apache.activemq.ActiveMQConnectionFactory; //導入方法依賴的package包/類
private SensorListenerContainer buildOpsMQListenerContainer(String host) {
int port = Integer.valueOf(System.getProperty(OPSMQ_PORT_PARAM, "61616"));
String opsmqPass = System.getenv(OPSMQ_PASS_ENV_VAR);
if (opsmqPass == null) {
throw new RuntimeException(OPSMQ_PASS_ENV_VAR + " env var needs to be set!");
}
ActiveMQConnectionFactory opsmqConnectionFactory = new ActiveMQConnectionFactory();
opsmqConnectionFactory.setBrokerURL(opsMQURI.build(host, port));
opsmqConnectionFactory.setUserName(OPSMQ_USER);
opsmqConnectionFactory.setPassword(opsmqPass);
SensorListenerContainer listenerContainer = new SensorListenerContainer();
listenerContainer.setConnectionFactory(opsmqConnectionFactory);
listenerContainer.setMaxConcurrentConsumers(Integer.valueOf(System.getProperty(OPSMQ_MAX_SESSIONS, "24")));
listenerContainer.setConcurrentConsumers(Integer.valueOf(System.getProperty(OPSMQ_MAX_SESSIONS, "24")));
listenerContainer.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
listenerContainer.setMessageListener(this.sensorListener);
return listenerContainer;
}
示例3: connect
import org.apache.activemq.ActiveMQConnectionFactory; //導入方法依賴的package包/類
public void connect() throws JMSException {
LOG.info("Connecting to broker {} on user {}", brokerURL, username);
final ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerURL);
connectionFactory.setUserName(username);
connectionFactory.setPassword(password);
connectionFactory.setTrustAllPackages(true);
connection = connectionFactory.createConnection();
connection.start();
}