Java Code Examples for org.apache.activemq.ActiveMQConnectionFactory#setBrokerURL()
The following examples show how to use
org.apache.activemq.ActiveMQConnectionFactory#setBrokerURL() .
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: MessageOrderingTest.java From olat with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); connectionFactory.setBrokerURL("tcp://localhost:61616"); Connection connection = connectionFactory.createQueueConnection(); Session session1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Session session2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = new ActiveMQQueue("/atestqueue"); MessageProducer producer = session1.createProducer(destination); MessageConsumer consumer = session2.createConsumer(destination); consumer.setMessageListener(new MessageOrderingTest()); connection.start(); for (int i = 0; i < 10000; i++) { MapMessage message = session1.createMapMessage(); message.setInt("Counter", i); producer.send(message); System.out.println("Sent counter=" + i); } }
Example 2
Source File: BrokerXmlConfigTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { // START SNIPPET: bean // configure the connection factory using // normal Java Bean property methods ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); // configure the embedded broker using an XML config file // which is either a URL or a resource on the classpath // TODO ... //connectionFactory.setBrokerXmlConfig("file:src/sample-conf/default.xml"); // you only need to configure the broker URL if you wish to change the // default connection mechanism, which in this test case we do connectionFactory.setBrokerURL("vm://localhost"); // END SNIPPET: bean return connectionFactory; }
Example 3
Source File: SharedActiveMQResource.java From baleen with Apache License 2.0 | 6 votes |
/** * 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 4
Source File: MessageOrderingTest.java From olat with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); connectionFactory.setBrokerURL("tcp://localhost:61616"); Connection connection = connectionFactory.createQueueConnection(); Session session1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Session session2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = new ActiveMQQueue("/atestqueue"); MessageProducer producer = session1.createProducer(destination); MessageConsumer consumer = session2.createConsumer(destination); consumer.setMessageListener(new MessageOrderingTest()); connection.start(); for (int i = 0; i < 10000; i++) { MapMessage message = session1.createMapMessage(); message.setInt("Counter", i); producer.send(message); System.out.println("Sent counter=" + i); } }
Example 5
Source File: InstanceManager.java From oneops with Apache License 2.0 | 6 votes |
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 6
Source File: ProducerConnctionFactory.java From jim-framework with Apache License 2.0 | 5 votes |
public PooledConnectionFactory create(String brokerClusterUrl){ ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(); mqConnectionFactory.setBrokerURL(brokerClusterUrl); mqConnectionFactory.setTransportListener(this); //mqConnectionFactory. PooledConnectionFactory connectionFactory = new JimPooledConnectionFactory(mqConnectionFactory); connectionFactory.setMaxConnections(10); connectionFactory.setTimeBetweenExpirationCheckMillis(1000); //connectionFactory.setCreateConnectionOnStartup(true); return connectionFactory; }
Example 7
Source File: ReceiverConfig.java From spring-jms with MIT License | 5 votes |
@Bean public ActiveMQConnectionFactory receiverActiveMQConnectionFactory() { ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); activeMQConnectionFactory.setBrokerURL(brokerUrl); return activeMQConnectionFactory; }
Example 8
Source File: SenderConfig.java From spring-jms with MIT License | 5 votes |
@Bean public ActiveMQConnectionFactory senderActiveMQConnectionFactory() { ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); activeMQConnectionFactory.setBrokerURL(brokerUrl); return activeMQConnectionFactory; }
Example 9
Source File: ReceiverConfig.java From spring-jms with MIT License | 5 votes |
@Bean public ActiveMQConnectionFactory receiverActiveMQConnectionFactory() { ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); activeMQConnectionFactory.setBrokerURL(brokerUrl); return activeMQConnectionFactory; }
Example 10
Source File: SenderConfig.java From spring-jms with MIT License | 5 votes |
@Bean public ActiveMQConnectionFactory senderActiveMQConnectionFactory() { ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); activeMQConnectionFactory.setBrokerURL(brokerUrl); return activeMQConnectionFactory; }
Example 11
Source File: ReceiverConfig.java From spring-jms with MIT License | 5 votes |
@Bean public ActiveMQConnectionFactory receiverActiveMQConnectionFactory() { ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); activeMQConnectionFactory.setBrokerURL(brokerUrl); return activeMQConnectionFactory; }
Example 12
Source File: ConsumerConnctionFactory.java From jim-framework with Apache License 2.0 | 5 votes |
public PooledConnectionFactory create(String brokerClusterUrl){ ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(); mqConnectionFactory.setBrokerURL(brokerClusterUrl); mqConnectionFactory.setTransportListener(this); //mqConnectionFactory. PooledConnectionFactory connectionFactory = new JimPooledConnectionFactory(mqConnectionFactory); connectionFactory.setMaxConnections(1); connectionFactory.setCreateConnectionOnStartup(true); return connectionFactory; }
Example 13
Source File: ReceiverConfig.java From spring-jms with MIT License | 5 votes |
@Bean public ActiveMQConnectionFactory receiverActiveMQConnectionFactory() { ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); activeMQConnectionFactory.setBrokerURL(brokerUrl); return activeMQConnectionFactory; }
Example 14
Source File: SenderConfig.java From spring-jms with MIT License | 5 votes |
@Bean public ActiveMQConnectionFactory senderActiveMQConnectionFactory() { ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); activeMQConnectionFactory.setBrokerURL(brokerUrl); return activeMQConnectionFactory; }
Example 15
Source File: ITActiveMQSender.java From zipkin-reporter-java with Apache License 2.0 | 5 votes |
@Test public void checkFalseWhenBrokerIsDown() throws IOException { sender.close(); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); // we can be pretty certain ActiveMQ isn't running on localhost port 80 connectionFactory.setBrokerURL("tcp://localhost:80"); sender = builder().connectionFactory(connectionFactory).build(); CheckResult check = sender.check(); assertThat(check.ok()).isFalse(); assertThat(check.error()).isInstanceOf(IOException.class); }
Example 16
Source File: ITActiveMQSender.java From zipkin-reporter-java with Apache License 2.0 | 5 votes |
@Test public void sendFailsWithInvalidActiveMqServer() throws Exception { sender.close(); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); // we can be pretty certain ActiveMQ isn't running on localhost port 80 connectionFactory.setBrokerURL("tcp://localhost:80"); sender = builder().connectionFactory(connectionFactory).build(); thrown.expect(IOException.class); thrown.expectMessage("Unable to establish connection to ActiveMQ broker: Connection refused"); send(CLIENT_SPAN, CLIENT_SPAN).execute(); }
Example 17
Source File: JmsCommonConfig.java From Spring with Apache License 2.0 | 5 votes |
@Bean public ConnectionFactory nativeConnectionFactory(){ final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(); cf.setBrokerURL("tcp://localhost:61616"); cf.setTrustAllPackages(true); return cf; }
Example 18
Source File: ActiveMQConnectionFactoryCreator.java From yaks with Apache License 2.0 | 5 votes |
@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 19
Source File: ActiveMQSender.java From zipkin-reporter-java with Apache License 2.0 | 4 votes |
public static ActiveMQSender create(String brokerUrl) { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); connectionFactory.setBrokerURL(brokerUrl); return newBuilder().connectionFactory(connectionFactory).build(); }
Example 20
Source File: MultipleTestsWithSpringFactoryBeanTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
protected ConnectionFactory createConnectionFactory() { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(); factory.setBrokerURL("vm://localhost"); return factory; }