Java Code Examples for org.apache.activemq.ActiveMQConnectionFactory#setPassword()

The following examples show how to use org.apache.activemq.ActiveMQConnectionFactory#setPassword() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InstanceManager.java    From oneops with Apache License 2.0 6 votes vote down vote up
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;
	
}
 
Example 2
Source File: SharedActiveMQResource.java    From baleen with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and returns an ActiveMQ session for use in creating producers/consumers. This method
 * handles the creation of the connection factory and connection
 *
 * @throws JMSException
 */
private Connection createConnection(
    String protocol,
    String host,
    String port,
    String brokerArgs,
    String username,
    String password)
    throws JMSException {
  String brokerUri = constructBrokerUri(protocol, host, port, brokerArgs);

  // Create connection factory
  ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
  connectionFactory.setBrokerURL(brokerUri);
  connectionFactory.setUserName(username);
  connectionFactory.setPassword(password);

  // Create a connection
  connection = connectionFactory.createConnection();
  return connection;
}
 
Example 3
Source File: ActiveMQConnectionFactoryCreator.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectionFactory create(Map<String, String> properties) {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();

    if (properties.containsKey("brokerUrl")) {
        connectionFactory.setBrokerURL(properties.get("brokerUrl"));
    }

    if (properties.containsKey("username")) {
        connectionFactory.setUserName(properties.get("username"));
    }

    if (properties.containsKey("password")) {
        connectionFactory.setPassword(properties.get("password"));
    }

    return connectionFactory;
}
 
Example 4
Source File: ActiveMqManager.java    From AuTe-Framework with Apache License 2.0 5 votes vote down vote up
ActiveMqManager(String host, int port, String username, String password) throws JMSException {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL("tcp://" + host + ":" + port);
    connectionFactory.setUserName(username);
    connectionFactory.setPassword(password);

    connection = connectionFactory.createConnection();
    connection.start();
}
 
Example 5
Source File: RemoteConfiguration.java    From CogStack-Pipeline with Apache License 2.0 5 votes vote down vote up
@Bean
public ActiveMQConnectionFactory amqConnectionFactory(){
    ActiveMQConnectionFactory factory =
            new ActiveMQConnectionFactory(jmsip);
    factory.setUserName(jmsUsername);
    factory.setPassword(jmsPassword);
    factory.setCloseTimeout(jmsCloseTimeout);
    return factory;
}
 
Example 6
Source File: AppUtils.java    From trellis with Apache License 2.0 5 votes vote down vote up
public static ActiveMQConnectionFactory getJmsFactory(final NotificationsConfiguration config) {
    final ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(config.getConnectionString());
    factory.setTrustedPackages(singletonList(String.class.getPackage().getName()));
    if (config.any().containsKey(PW_KEY) && config.any().containsKey(UN_KEY)) {
        factory.setUserName(config.any().get(UN_KEY));
        factory.setPassword(config.any().get(PW_KEY));
    }
    return factory;
}
 
Example 7
Source File: JmsTestActivator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private ActiveMQConnectionFactory createConnectionFactory() {
    ActiveMQConnectionFactory connectionFactory
        = new ActiveMQConnectionFactory("vm://JmsServiceTest");
    connectionFactory.setUserName("karaf");
    connectionFactory.setPassword("karaf");
    return connectionFactory;
}
 
Example 8
Source File: JmsServiceTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static ActiveMQConnectionFactory createConnectionFactory() {
    ActiveMQConnectionFactory connectionFactory
        = new ActiveMQConnectionFactory("vm://JmsServiceTest");
    connectionFactory.setUserName("karaf");
    connectionFactory.setPassword("karaf");
    return connectionFactory;
}
 
Example 9
Source File: ConnectionFactory.java    From hazelcast-simulator with Apache License 2.0 5 votes vote down vote up
public Connection newConnection(String brokerURL, ExceptionListener exceptionListener) throws JMSException {
        String finalBrokerURL = toUrl(brokerURL);

        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(finalBrokerURL);

        // to speed things up; don't wait till it is on the socket buffer.
        // http://activemq.apache.org/async-sends.html
        connectionFactory.setUseAsyncSend(true);

        // authentication stuff.
        connectionFactory.setUserName(username);
        connectionFactory.setPassword(password);
        // we want to consume the least amount of resources possible. And there will be very low volume traffic.

        connectionFactory.setMaxThreadPoolSize(MAX_THREAD_POOL_SIZE);
        //
//        connectionFactory.setRejectedTaskHandler(new  RejectedExecutionHandler() {
//            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
//                try {
//                    executor.getQueue().put(r);
//                } catch (InterruptedException var4) {
//                    throw new RejectedExecutionException(var4);
//                }
//            }
//        });

        Connection connection = connectionFactory.createConnection();
        connection.setExceptionListener(exceptionListener);
        connection.start();
        return connection;
    }