當前位置: 首頁>>代碼示例>>Java>>正文


Java ActiveMQConnectionFactory.setBrokerURL方法代碼示例

本文整理匯總了Java中org.apache.activemq.ActiveMQConnectionFactory.setBrokerURL方法的典型用法代碼示例。如果您正苦於以下問題:Java ActiveMQConnectionFactory.setBrokerURL方法的具體用法?Java ActiveMQConnectionFactory.setBrokerURL怎麽用?Java ActiveMQConnectionFactory.setBrokerURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.activemq.ActiveMQConnectionFactory的用法示例。


在下文中一共展示了ActiveMQConnectionFactory.setBrokerURL方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
	}
 
開發者ID:eXcellme,項目名稱:eds,代碼行數:21,代碼來源:EdsCamelConfig.java

示例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;
	
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:25,代碼來源:InstanceManager.java

示例3: createCamelContext

import org.apache.activemq.ActiveMQConnectionFactory; //導入方法依賴的package包/類
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("aggStrategy", AggregationStrategies.groupedExchange());

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL(broker.getTcpConnectorUri());

    SjmsComponent sjmsComponent = new SjmsComponent();
    sjmsComponent.setConnectionFactory(connectionFactory);

    SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
    sjmsBatchComponent.setConnectionFactory(connectionFactory);

    CamelContext context = new DefaultCamelContext(registry);
    context.addComponent("sjms-batch", sjmsBatchComponent);
    context.addComponent("sjms", sjmsComponent);

    return context;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:SjmsBatchEndpointTest.java

示例4: setupCamelContext

import org.apache.activemq.ActiveMQConnectionFactory; //導入方法依賴的package包/類
@Override
protected void setupCamelContext(CamelContext camelContext) throws Exception {
    // setup the ActiveMQ component
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL("vm://localhost?broker.persistent=false&broker.useJmx=false");

    // and register it into the CamelContext
    JmsComponent answer = new JmsComponent();
    answer.setConnectionFactory(connectionFactory);
    camelContext.addComponent("jms", answer);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:12,代碼來源:MyApplication.java

示例5: testRequestReply

import org.apache.activemq.ActiveMQConnectionFactory; //導入方法依賴的package包/類
/**
 * This test is disabled as the problem can currently not be reproduced using ActiveMQ.
 * TODO Find a way to recreate the problem with ActiveMQ and fully automate the test
 * @throws Exception
 */
@Ignore
@Test
public void testRequestReply() throws Exception {
    BrokerService broker = new BrokerService();
    broker.addConnector("tcp://localhost:61616");
    broker.setPersistent(false);
    broker.setTimeBeforePurgeTempDestinations(1000);
    broker.start();

    DefaultCamelContext context = new DefaultCamelContext();
    JmsComponent jmsComponent = new JmsComponent();

    /**
     * 
     */
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL("failover://(tcp://localhost:61616)?maxReconnectAttempts=1");

    /**
     * When using Tibco EMS the problem can be recreated. As the broker is
     * external it has to be stopped and started by hand.
     */
    // TibjmsConnectionFactory connectionFactory = new TibjmsConnectionFactory();
    // connectionFactory.setReconnAttemptCount(1);

    jmsComponent.setConnectionFactory(connectionFactory);
    jmsComponent.setRequestTimeout(1000);
    jmsComponent.setReceiveTimeout(1000);
    context.addComponent("jms", jmsComponent);
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("jms:testqueue").bean(new EchoServiceImpl());
            from("direct:test").to("jms:testqueue");
        }
    });
    CamelBeanPostProcessor processor = new CamelBeanPostProcessor();
    processor.setCamelContext(context);
    processor.postProcessBeforeInitialization(this, "this");
    context.start();

    String ret = proxy.echo("test");
    Assert.assertEquals("test", ret);

    broker.stop();
    /**
     * Wait long enough for the jms client to do a full reconnect. In the
     * Tibco EMS case this means that a Temporary Destination created before
     * is invalid now
     */
    Thread.sleep(5000);

    System.in.read();
    broker.start(true);

    /**
     * Before the fix to this issue this call will throw a spring UncategorizedJmsException
     * which contains an InvalidJmsDestination
     */
    String ret2 = proxy.echo("test");
    Assert.assertEquals("test", ret2);

}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:70,代碼來源:JmsReconnectTest.java


注:本文中的org.apache.activemq.ActiveMQConnectionFactory.setBrokerURL方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。