use of org.hornetq.jms.client.HornetQConnectionFactory 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.jms.client.HornetQConnectionFactory in project wildfly by wildfly.
the class LegacyConnectionFactoryAdd method createLegacyConnectionFactory.
private HornetQConnectionFactory createLegacyConnectionFactory(OperationContext context, ModelNode model) throws OperationFailedException {
boolean ha = LegacyConnectionFactoryDefinition.HA.resolveModelAttribute(context, model).asBoolean();
String factoryTypeStr = LegacyConnectionFactoryDefinition.FACTORY_TYPE.resolveModelAttribute(context, model).asString();
JMSFactoryType factoryType = LegacyConnectionFactoryDefinition.HornetQConnectionFactoryType.valueOf(factoryTypeStr).getType();
final HornetQConnectionFactory incompleteCF;
if (ha) {
incompleteCF = HornetQJMSClient.createConnectionFactoryWithHA(factoryType);
} else {
incompleteCF = HornetQJMSClient.createConnectionFactoryWithoutHA(factoryType);
}
incompleteCF.setAutoGroup(AUTO_GROUP.resolveModelAttribute(context, model).asBoolean());
incompleteCF.setBlockOnAcknowledge(BLOCK_ON_ACKNOWLEDGE.resolveModelAttribute(context, model).asBoolean());
incompleteCF.setBlockOnDurableSend(BLOCK_ON_DURABLE_SEND.resolveModelAttribute(context, model).asBoolean());
incompleteCF.setBlockOnNonDurableSend(BLOCK_ON_NON_DURABLE_SEND.resolveModelAttribute(context, model).asBoolean());
incompleteCF.setCacheLargeMessagesClient(CACHE_LARGE_MESSAGE_CLIENT.resolveModelAttribute(context, model).asBoolean());
incompleteCF.setCallFailoverTimeout(CALL_FAILOVER_TIMEOUT.resolveModelAttribute(context, model).asLong());
incompleteCF.setCallTimeout(CALL_TIMEOUT.resolveModelAttribute(context, model).asLong());
incompleteCF.setClientFailureCheckPeriod(CLIENT_FAILURE_CHECK_PERIOD.resolveModelAttribute(context, model).asLong());
final ModelNode clientID = CLIENT_ID.resolveModelAttribute(context, model);
if (clientID.isDefined()) {
incompleteCF.setClientID(clientID.asString());
}
incompleteCF.setCompressLargeMessage(COMPRESS_LARGE_MESSAGES.resolveModelAttribute(context, model).asBoolean());
incompleteCF.setConfirmationWindowSize(CONFIRMATION_WINDOW_SIZE.resolveModelAttribute(context, model).asInt());
final ModelNode connectionLoadBalancingClassName = CONNECTION_LOAD_BALANCING_CLASS_NAME.resolveModelAttribute(context, model);
if (connectionLoadBalancingClassName.isDefined()) {
incompleteCF.setConnectionLoadBalancingPolicyClassName(connectionLoadBalancingClassName.asString());
}
incompleteCF.setConnectionTTL(CONNECTION_TTL.resolveModelAttribute(context, model).asLong());
incompleteCF.setConsumerMaxRate(CONSUMER_MAX_RATE.resolveModelAttribute(context, model).asInt());
incompleteCF.setConsumerWindowSize(CONSUMER_WINDOW_SIZE.resolveModelAttribute(context, model).asInt());
incompleteCF.setConfirmationWindowSize(CONFIRMATION_WINDOW_SIZE.resolveModelAttribute(context, model).asInt());
incompleteCF.setDupsOKBatchSize(DUPS_OK_BATCH_SIZE.resolveModelAttribute(context, model).asInt());
incompleteCF.setFailoverOnInitialConnection(FAILOVER_ON_INITIAL_CONNECTION.resolveModelAttribute(context, model).asBoolean());
final ModelNode groupID = GROUP_ID.resolveModelAttribute(context, model);
if (groupID.isDefined()) {
incompleteCF.setGroupID(groupID.asString());
}
incompleteCF.setInitialConnectAttempts(INITIAL_CONNECT_ATTEMPTS.resolveModelAttribute(context, model).asInt());
incompleteCF.setInitialMessagePacketSize(INITIAL_MESSAGE_PACKET_SIZE.resolveModelAttribute(context, model).asInt());
incompleteCF.setMaxRetryInterval(MAX_RETRY_INTERVAL.resolveModelAttribute(context, model).asLong());
incompleteCF.setMinLargeMessageSize(MIN_LARGE_MESSAGE_SIZE.resolveModelAttribute(context, model).asInt());
incompleteCF.setPreAcknowledge(PRE_ACKNOWLEDGE.resolveModelAttribute(context, model).asBoolean());
incompleteCF.setProducerMaxRate(PRODUCER_MAX_RATE.resolveModelAttribute(context, model).asInt());
incompleteCF.setProducerWindowSize(PRODUCER_WINDOW_SIZE.resolveModelAttribute(context, model).asInt());
incompleteCF.setReconnectAttempts(RECONNECT_ATTEMPTS.resolveModelAttribute(context, model).asInt());
incompleteCF.setRetryInterval(RETRY_INTERVAL.resolveModelAttribute(context, model).asLong());
incompleteCF.setRetryIntervalMultiplier(RETRY_INTERVAL_MULTIPLIER.resolveModelAttribute(context, model).asDouble());
incompleteCF.setScheduledThreadPoolMaxSize(SCHEDULED_THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, model).asInt());
incompleteCF.setThreadPoolMaxSize(THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, model).asInt());
incompleteCF.setTransactionBatchSize(TRANSACTION_BATCH_SIZE.resolveModelAttribute(context, model).asInt());
incompleteCF.setUseGlobalPools(USE_GLOBAL_POOLS.resolveModelAttribute(context, model).asBoolean());
return incompleteCF;
}
use of org.hornetq.jms.client.HornetQConnectionFactory in project wildfly by wildfly.
the class LegacyConnectionFactoryAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
String name = context.getCurrentAddressValue();
final ServiceName activeMQServerServiceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
HornetQConnectionFactory incompleteCF = createLegacyConnectionFactory(context, model);
ModelNode discoveryGroup = DISCOVERY_GROUP.resolveModelAttribute(context, model);
String discoveryGroupName = discoveryGroup.isDefined() ? discoveryGroup.asString() : null;
LegacyConnectionFactoryService service = LegacyConnectionFactoryService.installService(name, activeMQServerServiceName, context.getServiceTarget(), incompleteCF, discoveryGroupName, CONNECTORS.unwrap(context, model));
for (String legacyEntry : LegacyConnectionFactoryDefinition.ENTRIES.unwrap(context, model)) {
BinderServiceUtil.installBinderService(context.getServiceTarget(), legacyEntry, service, new ServiceName[0]);
}
}
Aggregations