本文整理了Java中org.apache.activemq.ActiveMQConnectionFactory.setProducerWindowSize()
方法的一些代码示例,展示了ActiveMQConnectionFactory.setProducerWindowSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ActiveMQConnectionFactory.setProducerWindowSize()
方法的具体详情如下:
包路径:org.apache.activemq.ActiveMQConnectionFactory
类名称:ActiveMQConnectionFactory
方法名:setProducerWindowSize
暂无
代码示例来源:origin: activequant/aq2o
/**
* constructs and in-memory active mq transport factory.
*
* @throws Exception
*/
public ActiveMQTransportFactory() throws Exception {
String conUrl = "vm://localhost";
log.info("Constructing embedded ActiveMQTransportFactory for " + conUrl);
connectionFactory = new ActiveMQConnectionFactory(conUrl);
connectionFactory.setProducerWindowSize(1024000);
connection = connectionFactory.createTopicConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
代码示例来源: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: apache/activemq-artemis
@Test
public void testProducerFlowControl() throws Exception {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(urlString);
factory.setProducerWindowSize(1024 * 64);
Connection connection = factory.createConnection();
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
Queue queue = session.createQueue(queueName);
MessageProducer producer = session.createProducer(queue);
producer.send(session.createTextMessage("test"));
connection.close();
}
代码示例来源: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: apache/activemq-artemis
@Test
public void testAsyncPublisherRecoverAfterBlock() throws Exception {
factory.setProducerWindowSize(1024 * 5);
factory.setUseAsyncSend(true);
flowControlConnection = (ActiveMQConnection) factory.createConnection();
代码示例来源:origin: apache/activemq-artemis
@Test
public void test2ndPublisherWithProducerWindowSendConnectionThatIsBlocked() throws Exception {
factory.setProducerWindowSize(1024 * 64);
flowControlConnection = (ActiveMQConnection) factory.createConnection();
flowControlConnection.start();
Session session = flowControlConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queueB);
// Test sending to Queue A
// 1 few sends should not block until the producer window is used up.
fillQueue(queueA);
// Test sending to Queue B it should not block since the connection
// should not be blocked.
CountDownLatch pubishDoneToQeueuB = asyncSendTo(queueB, "Message 1");
assertTrue(pubishDoneToQeueuB.await(2, TimeUnit.SECONDS));
TextMessage msg = (TextMessage) consumer.receive();
assertEquals("Message 1", msg.getText());
msg.acknowledge();
pubishDoneToQeueuB = asyncSendTo(queueB, "Message 2");
assertTrue(pubishDoneToQeueuB.await(2, TimeUnit.SECONDS));
msg = (TextMessage) consumer.receive();
assertEquals("Message 2", msg.getText());
msg.acknowledge();
consumer.close();
}
内容来源于网络,如有侵权,请联系作者删除!