use of org.hornetq.api.core.TransportConfiguration in project perun by CESNET.
the class SystemQueueProcessor method startProcessingSystemMessages.
public void startProcessingSystemMessages() {
connection = null;
try {
// Step 2. Instantiate the TransportConfiguration object which
// contains the knowledge of what transport to use,
// The server port etc.
log.debug("Creating transport configuration...");
Map<String, Object> connectionParams = new HashMap<String, Object>();
if (log.isDebugEnabled()) {
log.debug("Gonna connect to the host[" + dispatcherPropertiesBean.getProperty("dispatcher.ip.address") + "] on port[" + dispatcherPropertiesBean.getProperty("dispatcher.port") + "]...");
}
connectionParams.put(TransportConstants.PORT_PROP_NAME, Integer.parseInt(dispatcherPropertiesBean.getProperty("dispatcher.port")));
connectionParams.put(TransportConstants.HOST_PROP_NAME, dispatcherPropertiesBean.getProperty("dispatcher.ip.address"));
TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams);
// Step 3 Directly instantiate the JMS ConnectionFactory object
// using that TransportConfiguration
log.debug("Creating connection factory...");
cf = (ConnectionFactory) HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration);
((HornetQConnectionFactory) cf).setUseGlobalPools(false);
// Step 4.Create a JMS Connection
log.debug("Creating connection...");
connection = cf.createConnection();
// Step 5. Create a JMS Session
log.debug("Creating session...");
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Step 10. Start the Connection
log.debug("Starting connection...");
connection.start();
if (processingMessages) {
systemQueueReceiver.stop();
}
systemQueueReceiver.setUp("systemQueue", session);
log.debug("Executor: taskExecutor.execute(systemQueueReceiver)...");
taskExecutor.execute(systemQueueReceiver);
log.debug("Initialization done.");
processingMessages = true;
} catch (JMSException e) {
// If unable to connect to the server...
log.error("Connection failed. \nThis is weird...are you sure that the Perun-Dispatcher is running on host[" + dispatcherPropertiesBean.getProperty("dispatcher.ip.address") + "] on port[" + dispatcherPropertiesBean.getProperty("dispatcher.port") + "] ? \nSee: perun-dispatcher.properties. We gonna wait 5 sec and try again...", e);
throw new RuntimeException(e);
} catch (Exception e) {
log.error(e.toString(), e);
}
}
use of org.hornetq.api.core.TransportConfiguration in project perun by CESNET.
the class JMSQueueManager method initiateConnection.
public void initiateConnection() {
while (needToConnect) {
try {
// Step 2. Instantiate the TransportConfiguration object which
// contains the knowledge of what transport to use,
// The server port etc.
Map<String, Object> connectionParams = new HashMap<String, Object>();
if (log.isDebugEnabled()) {
log.debug("Gonna connect to the host[" + propertiesBean.getProperty("dispatcher.ip.address") + "] on port[" + propertiesBean.getProperty("dispatcher.port") + "]...");
}
connectionParams.put(TransportConstants.PORT_PROP_NAME, Integer.parseInt(propertiesBean.getProperty("dispatcher.port")));
connectionParams.put(TransportConstants.HOST_PROP_NAME, propertiesBean.getProperty("dispatcher.ip.address"));
TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams);
// Step 3 Directly instantiate the JMS ConnectionFactory object
// using that TransportConfiguration
ConnectionFactory cf = (ConnectionFactory) HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration);
// Step 4.Create a JMS Connection
connection = cf.createConnection();
// Step 5. Create a JMS Session
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Step 10. Start the Connection
connection.start();
systemInitiated = true;
needToConnect = false;
waitTime = 0;
} catch (JMSException e) {
// If unable to connect to the server...
needToConnect = true;
waitTime = waitTime + 10000;
log.error("Connection failed. We gonna wait " + (waitTime / 1000) + " s and try again...", e);
try {
Thread.sleep(waitTime);
} catch (InterruptedException e1) {
log.error(e1.toString(), e1);
}
}
}
}
use of org.hornetq.api.core.TransportConfiguration in project wildfly by wildfly.
the class LegacyConnectionFactoryService method start.
@Override
public void start(StartContext context) throws StartException {
ActiveMQServer activeMQServer = injectedActiveMQServer.getValue();
DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
if (discoveryGroupName != null) {
if (activeMQServer.getConfiguration().getDiscoveryGroupConfigurations().keySet().contains(discoveryGroupName)) {
discoveryGroupConfiguration = translateDiscoveryGroupConfiguration(activeMQServer.getConfiguration().getDiscoveryGroupConfigurations().get(discoveryGroupName));
} else {
throw MessagingLogger.ROOT_LOGGER.discoveryGroupIsNotDefined(discoveryGroupName);
}
}
TransportConfiguration[] transportConfigurations = translateTransportGroupConfigurations(activeMQServer.getConfiguration().getConnectorConfigurations(), connectors);
JMSFactoryType factoryType = JMSFactoryType.valueOf(uncompletedConnectionFactory.getFactoryType());
if (uncompletedConnectionFactory.isHA()) {
if (discoveryGroupConfiguration != null) {
connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(discoveryGroupConfiguration, factoryType);
} else {
connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(factoryType, transportConfigurations);
}
} else {
if (discoveryGroupConfiguration != null) {
connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(discoveryGroupConfiguration, factoryType);
} else {
connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(factoryType, transportConfigurations);
}
}
connectionFactory.setAutoGroup(uncompletedConnectionFactory.isAutoGroup());
connectionFactory.setBlockOnAcknowledge(uncompletedConnectionFactory.isBlockOnAcknowledge());
connectionFactory.setBlockOnDurableSend(uncompletedConnectionFactory.isBlockOnDurableSend());
connectionFactory.setBlockOnNonDurableSend(uncompletedConnectionFactory.isBlockOnNonDurableSend());
connectionFactory.setCacheLargeMessagesClient(uncompletedConnectionFactory.isCacheLargeMessagesClient());
connectionFactory.setCallFailoverTimeout(uncompletedConnectionFactory.getCallFailoverTimeout());
connectionFactory.setCallTimeout(uncompletedConnectionFactory.getCallTimeout());
connectionFactory.setClientFailureCheckPeriod(uncompletedConnectionFactory.getClientFailureCheckPeriod());
connectionFactory.setClientID(uncompletedConnectionFactory.getClientID());
connectionFactory.setCompressLargeMessage(uncompletedConnectionFactory.isCompressLargeMessage());
connectionFactory.setConfirmationWindowSize(uncompletedConnectionFactory.getConfirmationWindowSize());
connectionFactory.setConnectionLoadBalancingPolicyClassName(uncompletedConnectionFactory.getConnectionLoadBalancingPolicyClassName());
connectionFactory.setConnectionTTL(uncompletedConnectionFactory.getConnectionTTL());
connectionFactory.setConsumerMaxRate(uncompletedConnectionFactory.getConsumerMaxRate());
connectionFactory.setConsumerWindowSize(uncompletedConnectionFactory.getConsumerWindowSize());
connectionFactory.setConfirmationWindowSize(uncompletedConnectionFactory.getConfirmationWindowSize());
connectionFactory.setDupsOKBatchSize(uncompletedConnectionFactory.getDupsOKBatchSize());
connectionFactory.setFailoverOnInitialConnection(uncompletedConnectionFactory.isFailoverOnInitialConnection());
connectionFactory.setGroupID(uncompletedConnectionFactory.getGroupID());
connectionFactory.setInitialConnectAttempts(uncompletedConnectionFactory.getInitialConnectAttempts());
connectionFactory.setInitialMessagePacketSize(uncompletedConnectionFactory.getInitialMessagePacketSize());
connectionFactory.setMaxRetryInterval(uncompletedConnectionFactory.getMaxRetryInterval());
connectionFactory.setMinLargeMessageSize(uncompletedConnectionFactory.getMinLargeMessageSize());
connectionFactory.setPreAcknowledge(uncompletedConnectionFactory.isPreAcknowledge());
connectionFactory.setProducerMaxRate(uncompletedConnectionFactory.getProducerMaxRate());
connectionFactory.setProducerWindowSize(uncompletedConnectionFactory.getProducerWindowSize());
connectionFactory.setReconnectAttempts(uncompletedConnectionFactory.getReconnectAttempts());
connectionFactory.setRetryInterval(uncompletedConnectionFactory.getRetryInterval());
connectionFactory.setRetryIntervalMultiplier(uncompletedConnectionFactory.getRetryIntervalMultiplier());
connectionFactory.setScheduledThreadPoolMaxSize(uncompletedConnectionFactory.getScheduledThreadPoolMaxSize());
connectionFactory.setThreadPoolMaxSize(uncompletedConnectionFactory.getThreadPoolMaxSize());
connectionFactory.setTransactionBatchSize(uncompletedConnectionFactory.getTransactionBatchSize());
connectionFactory.setUseGlobalPools(uncompletedConnectionFactory.isUseGlobalPools());
}
use of org.hornetq.api.core.TransportConfiguration in project wildfly by wildfly.
the class LegacyConnectionFactoryService method translateTransportGroupConfigurations.
private TransportConfiguration[] translateTransportGroupConfigurations(Map<String, org.apache.activemq.artemis.api.core.TransportConfiguration> connectorConfigurations, List<String> connectors) throws StartException {
List<org.hornetq.api.core.TransportConfiguration> legacyConnectorConfigurations = new ArrayList<>();
for (String connectorName : connectors) {
org.apache.activemq.artemis.api.core.TransportConfiguration newTransportConfiguration = connectorConfigurations.get(connectorName);
String legacyFactoryClassName = translateFactoryClassName(newTransportConfiguration.getFactoryClassName());
Map legacyParams = translateParams(newTransportConfiguration.getParams());
org.hornetq.api.core.TransportConfiguration legacyTransportConfiguration = new org.hornetq.api.core.TransportConfiguration(legacyFactoryClassName, legacyParams, newTransportConfiguration.getName());
legacyConnectorConfigurations.add(legacyTransportConfiguration);
}
return legacyConnectorConfigurations.toArray(new org.hornetq.api.core.TransportConfiguration[legacyConnectorConfigurations.size()]);
}
Aggregations