本文整理了Java中org.apache.activemq.ActiveMQConnectionFactory.setUseAsyncSend()
方法的一些代码示例,展示了ActiveMQConnectionFactory.setUseAsyncSend()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ActiveMQConnectionFactory.setUseAsyncSend()
方法的具体详情如下:
包路径:org.apache.activemq.ActiveMQConnectionFactory
类名称:ActiveMQConnectionFactory
方法名:setUseAsyncSend
[英]Forces the use of Async Sends which adds a massive performance boost; but means that the send() method will return immediately whether the message has been sent or not which could lead to message loss.
[中]强制使用Async Sends,这将大大提高性能;但这意味着send()方法将立即返回消息是否已发送,这可能导致消息丢失。
代码示例来源:origin: activequant/aq2o
/**
* constructs an activemq transport factory that connects to a specific host
* and port.
*
* @param host
* JMS server host
* @param port
* JMS server port.
* @throws Exception
*/
public ActiveMQTransportFactory(String host, int port) throws Exception {
// failover: means that it will automatically reconnect.
String conUrl = "failover:tcp://" + host + ":" + port
+ "??wireFormat.maxInactivityDuration=0";
log.info("Constructing ActiveMQTransportFactory for " + conUrl);
connectionFactory = new ActiveMQConnectionFactory(conUrl);
connectionFactory.setProducerWindowSize(1024000);
connectionFactory.setUseAsyncSend(true);
connectionFactory.setOptimizeAcknowledge(true);
connection = connectionFactory.createTopicConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
代码示例来源:origin: pierre/meteo
public AMQConnection(final AMQPublisherConfig baseConfig)
{
useBytesMessage = new AtomicBoolean(baseConfig.getUseBytesMessage());
final String uri = baseConfig.getUri();
if (uri != null) {
this.connectionFactory = new ActiveMQConnectionFactory(uri);
this.connectionFactory.setUseAsyncSend(baseConfig.getUseAsyncSend());
}
}
代码示例来源:origin: stackoverflow.com
public void run(){
logger.debug("JMS Sender get started to send responses to activeMq...");
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user, password, url);
connectionFactory.setUseAsyncSend(true);//faster than sync
connectionFactory.setOptimizeAcknowledge(true);
Connection connection;
try{
connection = connectionFactory.createConnection();
connection.start();
/** create an activeMq for responses **/
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = session.createQueue(jmsResponseQueueName);
MessageProducer responseProducer = session.createProducer(destination);
responseProducer.setDeliveryMode(DeliveryMode.PERSISTENT); //persistent mode
while (keepRunning){
// do time-consuming work here
}
}
catch (JMSException e){
logger.error("Exception occur when sender fails to connect to activeMQ:{}", e.getMessage());
}
catch (InterruptedException ie){
logger.error("Exception occur when take response from queue...{}", ie.getMessage());
}
}
代码示例来源:origin: activequant/aq2o
/**
* constructs an activemq transport factory that connects to a specific host
* and port.
*
* @param host
* JMS server host
* @param port
* JMS server port.
* @throws Exception
*/
public ActiveMQTransportFactory(String host, int port, String username, String password) throws Exception {
// failover: means that it will automatically reconnect.
String conUrl = "failover:tcp://" + host + ":" + port
+ "??wireFormat.maxInactivityDuration=0";
log.info("Constructing ActiveMQTransportFactory for " + conUrl);
//
connectionFactory = new ActiveMQConnectionFactory(conUrl);
connectionFactory.setUserName(username);
connectionFactory.setPassword(password);
connectionFactory.setProducerWindowSize(1024000);
connectionFactory.setUseAsyncSend(true);
connectionFactory.setOptimizeAcknowledge(true);
connection = connectionFactory.createTopicConnection(username, password);
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
代码示例来源:origin: pl.edu.icm.synat/synat-platform-connector
@Override
public ConnectionFactory getConnectionFactory(final JmsConfig jmsConfig, final boolean poolable) {
final String brokerUrl = jmsConfig.getBrokerUrl();
final ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUrl);
final RedeliveryPolicy redeliveryPolicy = connectionFactory.getRedeliveryPolicy();
connectionFactory.setUseAsyncSend(true);
setupRedeliveryPolicy(redeliveryPolicy, jmsConfig);
if (poolable) {
return new PooledConnectionFactory(connectionFactory);
} else {
return connectionFactory;
}
}
代码示例来源:origin: apache/activemq-artemis
ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) getConnectionFactory();
factory.setExceptionListener(null);
factory.setUseAsyncSend(false);
this.flowControlConnection = (ActiveMQConnection) factory.createConnection();
this.flowControlConnection.start();
代码示例来源:origin: apache/activemq-artemis
@Test
public void testAsyncPublisherRecoverAfterBlock() throws Exception {
factory.setProducerWindowSize(1024 * 5);
factory.setUseAsyncSend(true);
flowControlConnection = (ActiveMQConnection) factory.createConnection();
flowControlConnection.start();
代码示例来源:origin: apache/activemq-artemis
factory.setUseAsyncSend(true);
this.flowControlConnection = (ActiveMQConnection) factory.createConnection();
this.flowControlConnection.start();
内容来源于网络,如有侵权,请联系作者删除!