use of org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory in project activemq-artemis by apache.
the class BridgeTestBase method setUpAdministeredObjects.
protected void setUpAdministeredObjects() throws Exception {
cff0LowProducerWindow = new ConnectionFactoryFactory() {
@Override
public ConnectionFactory createConnectionFactory() throws Exception {
ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
// Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
cf.setReconnectAttempts(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
cf.setProducerWindowSize(100);
return cf;
}
};
cff0 = new ConnectionFactoryFactory() {
@Override
public ConnectionFactory createConnectionFactory() throws Exception {
ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
// Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
cf.setReconnectAttempts(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
return cf;
}
};
cff0xa = new ConnectionFactoryFactory() {
@Override
public Object createConnectionFactory() throws Exception {
ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
// Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
cf.setReconnectAttempts(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
return cf;
}
};
cf0 = (ConnectionFactory) cff0.createConnectionFactory();
cf0xa = (XAConnectionFactory) cff0xa.createConnectionFactory();
cff1 = new ConnectionFactoryFactory() {
@Override
public ConnectionFactory createConnectionFactory() throws Exception {
ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY, params1));
// Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
cf.setReconnectAttempts(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
return cf;
}
};
cff1xa = new ConnectionFactoryFactory() {
@Override
public XAConnectionFactory createConnectionFactory() throws Exception {
ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY, params1));
// Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
cf.setReconnectAttempts(0);
cf.setBlockOnNonDurableSend(true);
cf.setBlockOnDurableSend(true);
cf.setCacheLargeMessagesClient(true);
return cf;
}
};
cf1 = (ConnectionFactory) cff1.createConnectionFactory();
cf1xa = (XAConnectionFactory) cff1xa.createConnectionFactory();
sourceQueueFactory = new DestinationFactory() {
@Override
public Destination createDestination() throws Exception {
return (Destination) context0.lookup("/queue/sourceQueue");
}
};
sourceQueue = (Queue) sourceQueueFactory.createDestination();
targetQueueFactory = new DestinationFactory() {
@Override
public Destination createDestination() throws Exception {
return (Destination) context1.lookup("/queue/targetQueue");
}
};
targetQueue = (Queue) targetQueueFactory.createDestination();
sourceTopicFactory = new DestinationFactory() {
@Override
public Destination createDestination() throws Exception {
return (Destination) context0.lookup("/topic/sourceTopic");
}
};
sourceTopic = (Topic) sourceTopicFactory.createDestination();
localTargetQueueFactory = new DestinationFactory() {
@Override
public Destination createDestination() throws Exception {
return (Destination) context0.lookup("/queue/localTargetQueue");
}
};
localTargetQueue = (Queue) localTargetQueueFactory.createDestination();
}
use of org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory in project activemq-artemis by apache.
the class AcknowledgementTest method testNonBlockingAckPerf.
/**
* Ensure no blocking calls in acknowledge flow when block on acknowledge = false.
* This is done by checking the performance compared to blocking is much improved.
*/
@Test
public void testNonBlockingAckPerf() throws Exception {
getJmsServerManager().createConnectionFactory("testsuitecf1", false, JMSFactoryType.CF, NETTY_CONNECTOR, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, true, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/testsuitecf1");
getJmsServerManager().createConnectionFactory("testsuitecf2", false, JMSFactoryType.CF, NETTY_CONNECTOR, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, true, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/testsuitecf2");
ActiveMQJMSConnectionFactory cf1 = (ActiveMQJMSConnectionFactory) getInitialContext().lookup("/testsuitecf1");
cf1.setBlockOnAcknowledge(false);
ActiveMQJMSConnectionFactory cf2 = (ActiveMQJMSConnectionFactory) getInitialContext().lookup("/testsuitecf2");
cf2.setBlockOnAcknowledge(true);
int messageCount = 100;
long sendT1 = send(cf1, queue1, messageCount);
long sendT2 = send(cf2, queue2, messageCount);
long time1 = consume(cf1, queue1, messageCount);
long time2 = consume(cf2, queue2, messageCount);
log.info("BlockOnAcknowledge=false MessageCount=" + messageCount + " TimeToConsume=" + time1);
log.info("BlockOnAcknowledge=true MessageCount=" + messageCount + " TimeToConsume=" + time2);
Assert.assertTrue(time1 < (time2 / 2));
}
use of org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory in project activemq-artemis by apache.
the class ReferenceableTest method testReferenceCF.
@Test
public void testReferenceCF() throws Exception {
Reference cfRef = ((Referenceable) cf).getReference();
String factoryName = cfRef.getFactoryClassName();
Class<?> factoryClass = Class.forName(factoryName);
ObjectFactory factory = (ObjectFactory) factoryClass.newInstance();
Object instance = factory.getObjectInstance(cfRef, null, null, null);
ProxyAssertSupport.assertTrue(instance instanceof ActiveMQConnectionFactory);
ActiveMQJMSConnectionFactory cf2 = (ActiveMQJMSConnectionFactory) instance;
simpleSendReceive(cf2, queue1);
}
use of org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory in project activemq-artemis by apache.
the class RestDeserializationTest method jmsSendMessage.
private void jmsSendMessage(Serializable value, String destName, boolean isQueue) throws JMSException {
ConnectionFactory factory = new ActiveMQJMSConnectionFactory("tcp://localhost:61616");
String jmsDest;
if (isQueue) {
jmsDest = QUEUE_QUALIFIED_PREFIX + destName;
} else {
jmsDest = TOPIC_QUALIFIED_PREFIX + destName;
}
Destination destination = ActiveMQDestination.fromPrefixedName(jmsDest);
Connection conn = factory.createConnection();
try {
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
ObjectMessage message = session.createObjectMessage();
message.setStringProperty(HttpHeaderProperty.CONTENT_TYPE, "application/xml");
message.setObject(value);
producer.send(message);
} finally {
conn.close();
}
}
use of org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory in project activemq-artemis by apache.
the class JMSClientTestSupport method createCoreConnection.
private Connection createCoreConnection(String connectionString, String username, String password, String clientId, boolean start) throws JMSException {
ActiveMQJMSConnectionFactory factory = new ActiveMQJMSConnectionFactory(connectionString);
Connection connection = trackJMSConnection(factory.createConnection(username, password));
connection.setExceptionListener(new ExceptionListener() {
@Override
public void onException(JMSException exception) {
exception.printStackTrace();
}
});
if (clientId != null && !clientId.isEmpty()) {
connection.setClientID(clientId);
}
if (start) {
connection.start();
}
return connection;
}
Aggregations