本文整理了Java中org.apache.activemq.ActiveMQConnectionFactory.setAlwaysSyncSend()
方法的一些代码示例,展示了ActiveMQConnectionFactory.setAlwaysSyncSend()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ActiveMQConnectionFactory.setAlwaysSyncSend()
方法的具体详情如下:
包路径:org.apache.activemq.ActiveMQConnectionFactory
类名称:ActiveMQConnectionFactory
方法名:setAlwaysSyncSend
[英]Set true if always require messages to be sync sent
[中]如果始终需要同步发送消息,则设置为true
代码示例来源:origin: streampipes/streampipes-ce
protected Connection startJmsConnection(String url) {
try {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
connectionFactory.setAlwaysSyncSend(false);
Connection connect = connectionFactory.createConnection();
connect.start();
return connect;
} catch (JMSException e) {
throw new AssertionError("Failed to establish the JMS-Connection!", e);
}
}
}
代码示例来源:origin: org.streampipes/streampipes-messaging-jms
protected Connection startJmsConnection(String url) {
try {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
connectionFactory.setAlwaysSyncSend(false);
Connection connect = connectionFactory.createConnection();
connect.start();
return connect;
} catch (JMSException e) {
throw new AssertionError("Failed to establish the JMS-Connection!", e);
}
}
}
代码示例来源:origin: at.researchstudio.sat/won-core
public synchronized ConnectionFactory configureCachingConnectionFactory(ActiveMQConnectionFactory connectionFactory) {
// for non-persistent messages setting "AlwaysSyncSend" to true makes it slow, but ensures that a producer is immediately informed
// about the memory issues on broker (is blocked or gets exception depending on <systemUsage> config)
// see more info http://activemq.apache.org/producer-flow-control.html
connectionFactory.setAlwaysSyncSend(false);
// disable timestamps by default so that ttl of messages is not checked
connectionFactory.setDisableTimeStampsByDefault(true);
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(connectionFactory);
cachingConnectionFactory.setCacheConsumers(true);
cachingConnectionFactory.setCacheProducers(true);
return cachingConnectionFactory;
}
代码示例来源:origin: apache/activemq-artemis
@Test
public void testSimpleSendReceive() throws Exception {
factory.setAlwaysSyncSend(true);
flowControlConnection = (ActiveMQConnection) factory.createConnection();
flowControlConnection.start();
Session session = flowControlConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queueA);
// Test sending to Queue B it should not block.
CountDownLatch pubishDoneToQeueuA = asyncSendTo(queueA, "Message 1");
assertTrue(pubishDoneToQeueuA.await(2, TimeUnit.SECONDS));
TextMessage msg = (TextMessage) consumer.receive();
assertEquals("Message 1", msg.getText());
msg.acknowledge();
pubishDoneToQeueuA = asyncSendTo(queueA, "Message 2");
assertTrue(pubishDoneToQeueuA.await(2, TimeUnit.SECONDS));
msg = (TextMessage) consumer.receive();
assertEquals("Message 2", msg.getText());
msg.acknowledge();
consumer.close();
}
代码示例来源:origin: apache/activemq-artemis
@Test
public void test2ndPublisherWithSyncSendConnectionThatIsBlocked() throws Exception {
factory.setAlwaysSyncSend(true);
flowControlConnection = (ActiveMQConnection) factory.createConnection();
flowControlConnection.start();
Session session = flowControlConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queueB);
// Test sending to Queue A
// 1st send should not block. But the rest will.
fillQueue(queueA);
// Test sending to Queue B it should not block.
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();
}
内容来源于网络,如有侵权,请联系作者删除!