本文整理汇总了Java中org.apache.activemq.ActiveMQConnectionFactory.setUseAsyncSend方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQConnectionFactory.setUseAsyncSend方法的具体用法?Java ActiveMQConnectionFactory.setUseAsyncSend怎么用?Java ActiveMQConnectionFactory.setUseAsyncSend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.ActiveMQConnectionFactory
的用法示例。
在下文中一共展示了ActiveMQConnectionFactory.setUseAsyncSend方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConnectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
private static ConnectionFactory createConnectionFactory(String options, Integer maximumRedeliveries) {
// using a unique broker name improves testing when running the entire test suite in the same JVM
int id = counter.incrementAndGet();
String url = "tcp://192.168.3.103:61618";
// if (options != null) {
// url = url + "&" + options;
// }
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
// optimize AMQ to be as fast as possible so unit testing is quicker
connectionFactory.setCopyMessageOnSend(false);
connectionFactory.setOptimizeAcknowledge(true);
connectionFactory.setOptimizedMessageDispatch(true);
// When using asyncSend, producers will not be guaranteed to send in the order we
// have in the tests (which may be confusing for queues) so we need this set to false.
// Another way of guaranteeing order is to use persistent messages or transactions.
connectionFactory.setUseAsyncSend(false);
connectionFactory.setAlwaysSessionAsync(false);
if (maximumRedeliveries != null) {
connectionFactory.getRedeliveryPolicy().setMaximumRedeliveries(maximumRedeliveries);
}
// connectionFactory.setTrustAllPackages(true);
return connectionFactory;
}
示例2: createConnectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
public static ConnectionFactory createConnectionFactory(String options) {
// using a unique broker name improves testing when running the entire test suite in the same JVM
int id = counter.incrementAndGet();
String url = "vm://test-broker-" + id + "?broker.persistent=false&broker.useJmx=false";
if (options != null) {
url = url + "&" + options;
}
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
// optimize AMQ to be as fast as possible so unit testing is quicker
connectionFactory.setCopyMessageOnSend(false);
connectionFactory.setOptimizeAcknowledge(true);
connectionFactory.setOptimizedMessageDispatch(true);
connectionFactory.setTrustAllPackages(true);
// When using asyncSend, producers will not be guaranteed to send in the order we
// have in the tests (which may be confusing for queues) so we need this set to false.
// Another way of guaranteeing order is to use persistent messages or transactions.
connectionFactory.setUseAsyncSend(false);
connectionFactory.setAlwaysSessionAsync(false);
// use a pooled connection factory
PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
pooled.setMaxConnections(8);
return pooled;
}
示例3: createConnectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
public static ConnectionFactory createConnectionFactory(String options, Integer maximumRedeliveries) {
// using a unique broker name improves testing when running the entire test suite in the same JVM
int id = counter.incrementAndGet();
String url = "vm://test-broker-" + id + "?broker.persistent=false&broker.useJmx=false";
if (options != null) {
url = url + "&" + options;
}
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
// optimize AMQ to be as fast as possible so unit testing is quicker
connectionFactory.setCopyMessageOnSend(false);
connectionFactory.setOptimizeAcknowledge(true);
connectionFactory.setOptimizedMessageDispatch(true);
// When using asyncSend, producers will not be guaranteed to send in the order we
// have in the tests (which may be confusing for queues) so we need this set to false.
// Another way of guaranteeing order is to use persistent messages or transactions.
connectionFactory.setUseAsyncSend(false);
connectionFactory.setAlwaysSessionAsync(false);
if (maximumRedeliveries != null) {
connectionFactory.getRedeliveryPolicy().setMaximumRedeliveries(maximumRedeliveries);
}
connectionFactory.setTrustAllPackages(true);
return connectionFactory;
}
示例4: createConnectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
public static ConnectionFactory createConnectionFactory(String options) {
// using a unique broker name improves testing when running the entire test suite in the same JVM
int id = counter.incrementAndGet();
String url = "vm://test-broker-" + id + "?broker.persistent=false&broker.useJmx=false";
if (options != null) {
url = url + "&" + options;
}
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
// optimize AMQ to be as fast as possible so unit testing is quicker
connectionFactory.setCopyMessageOnSend(false);
connectionFactory.setOptimizeAcknowledge(true);
connectionFactory.setOptimizedMessageDispatch(true);
// When using asyncSend, producers will not be guaranteed to send in the order we
// have in the tests (which may be confusing for queues) so we need this set to false.
// Another way of guaranteeing order is to use persistent messages or transactions.
connectionFactory.setUseAsyncSend(false);
connectionFactory.setAlwaysSessionAsync(false);
// use a pooled connection factory
PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
pooled.setMaxConnections(8);
return pooled;
}
示例5: init
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
/**
* Inits the.
*
* @throws JMSException the jMS exception
*/
public void init() throws JMSException {
Properties properties = new Properties();
try {
properties.load(this.getClass().getResourceAsStream("/sink.properties"));
} catch (IOException e) {
logger.error("got: " + e.getMessage());
}
user = properties.getProperty("amq.user");
password = System.getenv("KLOOPZ_AMQ_PASS");
if (password == null) {
throw new JMSException("missing KLOOPZ_AMQ_PASS env var");
}
AMQConnectorURI connectStringGenerator = new AMQConnectorURI();
connectStringGenerator.setHost("opsmq");
connectStringGenerator.setProtocol("tcp");
connectStringGenerator.setPort(61616);
connectStringGenerator.setTransport("failover");
connectStringGenerator.setDnsResolve(true);
connectStringGenerator.setKeepAlive(true);
HashMap<String, String> transportOptions = new HashMap<>();
transportOptions.put("initialReconnectDelay", "1000");
transportOptions.put("startupMaxReconnectAttempts", mqConnectionStartupRetries);
transportOptions.put("timeout", mqConnectionTimeout);
transportOptions.put("useExponentialBackOff", "false");
connectStringGenerator.setTransportOptions(transportOptions);
url = connectStringGenerator.build();
showParameters();
// Create the connection.
ActiveMQConnectionFactory amqConnectionFactory = new ActiveMQConnectionFactory(user, password, url);
amqConnectionFactory.setUseAsyncSend(true);
PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(amqConnectionFactory);
pooledConnectionFactory.setMaxConnections(amqConnectionPoolSize);
pooledConnectionFactory.setIdleTimeout(10000);
for (int i = 0; i < poolsize; i++) {
JmsTemplate producerTemplate = new JmsTemplate(pooledConnectionFactory);
producerTemplate.setSessionTransacted(false);
int shard = i + 1;
Destination perfin = new org.apache.activemq.command.ActiveMQQueue(queueBase + "-" + shard);
producerTemplate.setDefaultDestination(perfin);
producerTemplate.setDeliveryPersistent(false);
producers[i] = producerTemplate;
}
}
示例6: connectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
@Bean
public ConnectionFactory connectionFactory() {
// Using an in memory ms queue for easy of demonstration
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
// Uncomment the following line if a real, standalone ActiveMQ JMS queue should be used
//ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61616");
activeMQConnectionFactory.setUseAsyncSend(true);
activeMQConnectionFactory.setAlwaysSessionAsync(true);
activeMQConnectionFactory.setStatsEnabled(true);
return new CachingConnectionFactory(activeMQConnectionFactory);
}
示例7: connectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
@Bean
public ConnectionFactory connectionFactory() {
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
activeMQConnectionFactory.setUseAsyncSend(true);
activeMQConnectionFactory.setAlwaysSessionAsync(true);
activeMQConnectionFactory.setStatsEnabled(true);
return new CachingConnectionFactory(activeMQConnectionFactory);
}
示例8: activeMQConnFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
@Bean
public ActiveMQConnectionFactory activeMQConnFactory() {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl);
factory.setUseAsyncSend(true);
return factory;
}
示例9: serverActiveMQConnectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
@Bean
public ActiveMQConnectionFactory serverActiveMQConnectionFactory() {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl);
factory.setUseAsyncSend(true);
return factory;
}
示例10: createPersistentConnectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
public static ConnectionFactory createPersistentConnectionFactory(String options) {
// using a unique broker name improves testing when running the entire test suite in the same JVM
int id = counter.incrementAndGet();
// use an unique data directory in target
String dir = "target/activemq-data-" + id;
// remove dir so its empty on startup
FileUtil.removeDir(new File(dir));
String url = "vm://test-broker-" + id + "?broker.persistent=true&broker.useJmx=false&broker.dataDirectory=" + dir;
if (options != null) {
url = url + "&" + options;
}
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
// optimize AMQ to be as fast as possible so unit testing is quicker
connectionFactory.setCopyMessageOnSend(false);
connectionFactory.setOptimizeAcknowledge(true);
connectionFactory.setOptimizedMessageDispatch(true);
connectionFactory.setUseAsyncSend(true);
connectionFactory.setAlwaysSessionAsync(false);
connectionFactory.setTrustAllPackages(true);
// use a pooled connection factory
PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
pooled.setMaxConnections(8);
return pooled;
}
示例11: createPersistentConnectionFactory
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
public static ConnectionFactory createPersistentConnectionFactory(String options) {
// using a unique broker name improves testing when running the entire test suite in the same JVM
int id = counter.incrementAndGet();
// use an unique data directory in target
String dir = "target/activemq-data-" + id;
// remove dir so its empty on startup
FileUtil.removeDir(new File(dir));
String url = "vm://test-broker-" + id + "?broker.persistent=true&broker.useJmx=false&broker.dataDirectory=" + dir;
if (options != null) {
url = url + "&" + options;
}
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
// optimize AMQ to be as fast as possible so unit testing is quicker
connectionFactory.setCopyMessageOnSend(false);
connectionFactory.setOptimizeAcknowledge(true);
connectionFactory.setOptimizedMessageDispatch(true);
connectionFactory.setUseAsyncSend(true);
connectionFactory.setAlwaysSessionAsync(false);
// use a pooled connection factory
PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
pooled.setMaxConnections(8);
return pooled;
}
示例12: init
import org.apache.activemq.ActiveMQConnectionFactory; //导入方法依赖的package包/类
@PostConstruct
public void init() {
factory = new ActiveMQConnectionFactory(appConfig.getBrokerURL());
factory.setUseAsyncSend(appConfig.isUseAsyncSend());
}