@Override public TransportConfiguration getConnectorConfig() { if (configuration != null) { return new TransportConfiguration(NettyConnectorFactory.class.getName(), this.configuration); } else { return null; } }
/** * Generates a {@link TransportConfiguration} to be use to connect to the * same target this is connect to * @return */ public TransportConfiguration getConnectorConfig() { if (configuration != null) { return new TransportConfiguration(NettyConnectorFactory.class.getName(), this.configuration); } else { return null; } }
/** * Generates a {@link TransportConfiguration} to be use to connect to the * same target this is connect to * @return */ public TransportConfiguration getConnectorConfig() { Map<String, Object> params = new HashMap<String, Object>(); params.put(org.hornetq.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, serverID); return new TransportConfiguration(InVMConnectorFactory.class.getName(), params); }
@Override public TransportConfiguration getConnectorConfig() { Map<String, Object> params = new HashMap<String, Object>(); params.put(org.hornetq.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, serverID); return new TransportConfiguration(InVMConnectorFactory.class.getName(), params); }
static ClientSessionFactory createClientSessionFactory(String host, int port) throws Exception { final Map<String, Object> properties = new HashMap<String, Object>(); properties.put("host", host); properties.put("port", port); final TransportConfiguration configuration = new TransportConfiguration(NettyConnectorFactory.class.getName(), properties); return HornetQClient.createServerLocatorWithoutHA(configuration).createSessionFactory(); }
@Override public ConnectionFactory createConnectionFactory(URI serverUri) { HashMap<String, Object> props = new HashMap<>(); props.put("host", UriUtils.extractHostFromUri(serverUri)); Integer port = UriUtils.extractPortFromUri(serverUri); if (port != null) { props.put("port", port); } TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), props); return HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration); }
@Override public ConnectionFactory createConnectionFactory(URI serverUri) { HashMap<String, Object> props = new HashMap<>(); props.put("host", UriUtils.extractHostFromUri(serverUri)); Integer port = UriUtils.extractPortFromUri(serverUri); if (port != null) { props.put("port", port); } TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), props); return HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration); }
protected void initDefaults() { if (locator == null) { locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName())); } if (sessionFactory == null) { try { sessionFactory = locator.createSessionFactory(); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } if (consumerSessionFactory == null) consumerSessionFactory = sessionFactory; if (timeoutTask == null) throw new RuntimeException("TimeoutTask is not set"); }
public XmlDataImporter(InputStream inputStream, String host, String port, boolean transactional) { try { reader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream); HashMap<String, Object> connectionParams = new HashMap<String, Object>(); connectionParams.put(TransportConstants.HOST_PROP_NAME, host); connectionParams.put(TransportConstants.PORT_PROP_NAME, port); ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams)); ClientSessionFactory sf = serverLocator.createSessionFactory(); session = sf.createSession(false, !transactional, true); managementSession = sf.createSession(false, true, true); localSession = true; } catch (Exception e) { e.printStackTrace(); } }
private TransportConfiguration parseTransportConfiguration(final Element e, final Configuration mainConfig) { Node nameNode = e.getAttributes().getNamedItem("name"); String name = nameNode != null ? nameNode.getNodeValue() : null; String clazz = XMLConfigurationUtil.getString(e, "factory-class", null, Validators.NOT_NULL_OR_EMPTY); Map<String, Object> params = new HashMap<String, Object>(); if (mainConfig.isMaskPassword()) { params.put(Configuration.PROP_MASK_PASSWORD, mainConfig.isMaskPassword()); if (mainConfig.getPasswordCodec() != null) { params.put(Configuration.PROP_PASSWORD_CODEC, mainConfig.getPasswordCodec()); } } NodeList paramsNodes = e.getElementsByTagName("param"); for (int i = 0; i < paramsNodes.getLength(); i++) { Node paramNode = paramsNodes.item(i); NamedNodeMap attributes = paramNode.getAttributes(); Node nkey = attributes.getNamedItem("key"); String key = nkey.getTextContent(); Node nValue = attributes.getNamedItem("value"); params.put(key, nValue.getTextContent()); } return new TransportConfiguration(clazz, params, name); }
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()]); }
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()]); }
/** * Close the existing Session if exists and create new one. * @return Session instance */ public Session createJMSSession() { closeJMSSession(_jmsSession); try { if (_jmsConnectionFactory == null || _jmsConnection == null) { if (_startEmbedded) { _jmsConnectionFactory = new HornetQConnectionFactory(false, getTransports(getConfiguration())); } else { _jmsConnectionFactory = new HornetQConnectionFactory(false, new TransportConfiguration(NettyConnectorFactory.class.getName(), _transportParams)); } _jmsConnection = _jmsConnectionFactory.createConnection(_user, _passwd); _jmsConnection.start(); } _jmsSession = _jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); return _jmsSession; } catch (JMSException e) { throw new RuntimeException(e); } }
/** * Close the existing Session if exists and create new one. * @return Session instance */ public Session createJMSSession() { closeJMSSession(_jmsSession); try { if (_jmsConnectionFactory == null || _jmsConnection == null) { if (_startEmbedded) { _jmsConnectionFactory = new HornetQConnectionFactory(false, getTransports(getConfiguration())); } else { _jmsConnectionFactory = new HornetQConnectionFactory(false, new TransportConfiguration(NettyConnectorFactory.class.getName(), _transportParams)); } _jmsConnection = _jmsConnectionFactory.createConnection(_user, _passwd); _jmsConnection.start(); } _jmsSession = _jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); return _jmsSession; } catch (JMSException e) { throw new RuntimeException(e); } }
@Override public void decodeRest(final HornetQBuffer buffer) { clusterUser = buffer.readString(); clusterPassword = buffer.readString(); backupWantsFailBack = buffer.readBoolean(); connector = new TransportConfiguration(); connector.decode(buffer); }
@Override public void decodeRest(final HornetQBuffer buffer) { this.nodeID = buffer.readString(); this.backup = buffer.readBoolean(); this.currentEventID = buffer.readLong(); if (buffer.readBoolean()) { connector = new TransportConfiguration(); connector.decode(buffer); } if (buffer.readBoolean()) { backupConnector = new TransportConfiguration(); backupConnector.decode(buffer); } }
@Override public void decodeRest(final HornetQBuffer buffer) { this.nodeID = buffer.readString(); this.nodeName = buffer.readNullableString(); this.backup = buffer.readBoolean(); this.currentEventID = buffer.readLong(); if (buffer.readBoolean()) { connector = new TransportConfiguration(); connector.decode(buffer); } if (buffer.readBoolean()) { backupConnector = new TransportConfiguration(); backupConnector.decode(buffer); } }
public static TransportConfiguration decode(HornetQBuffer buffer) { String name = BufferHelper.readNullableSimpleStringAsString(buffer); String factoryClassName = buffer.readSimpleString().toString(); int paramSize = buffer.readInt(); Map<String, Object> params = new HashMap<String, Object>(); for (int i = 0; i < paramSize; i++) { String key = buffer.readSimpleString().toString(); String value = buffer.readSimpleString().toString(); params.put(key, value); } TransportConfiguration config = new TransportConfiguration(factoryClassName, params, name); return config; }
protected ConnectionFactory createRemoteConnectionFactory(final Options<CreateContextOption> options) { //TODO: possibly cache the remote cf's? Map<String, Object> transportOpts = new HashMap<>(); transportOpts.put("host", options.getString(CreateContextOption.HOST)); transportOpts.put("port", options.getInt(CreateContextOption.PORT)); if (REMOTE_TYPE_WILDFLY.equals(options.getString(CreateContextOption.REMOTE_TYPE))) { transportOpts.put("http-upgrade-enabled", true); } TransportConfiguration config = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory", transportOpts); HornetQConnectionFactory hornetQcf = HornetQJMSClient .createConnectionFactoryWithoutHA(options.has(CreateContextOption.XA) ? JMSFactoryType.XA_CF : JMSFactoryType.CF, config); hornetQcf.setReconnectAttempts(options.getInt(CreateContextOption.RECONNECT_ATTEMPTS)); hornetQcf.setRetryInterval(options.getLong(CreateContextOption.RECONNECT_RETRY_INTERVAL)); hornetQcf.setRetryIntervalMultiplier(options.getDouble(CreateContextOption.RECONNECT_RETRY_INTERVAL_MULTIPLIER)); hornetQcf.setMaxRetryInterval(options.getLong(CreateContextOption.RECONNECT_MAX_RETRY_INTERVAL)); // We have to cast for HornetQ 2.3 - the factory object that is returned is both a HornetQConnectionFactory // and a javax.jms.ConnectionFactory, but HornetQConnectionFactory doesn't implement j.j.ConnectionFactory. // With HornetQ 2.4, this cast is redundant. return (ConnectionFactory)hornetQcf; }
public boolean initialise(final String config) { if (HornetQXAResourceRecovery.log.isTraceEnabled()) { HornetQXAResourceRecovery.log.trace(this + " intialise: " + config); } String[] configs = config.split(";"); XARecoveryConfig[] xaRecoveryConfigs = new XARecoveryConfig[configs.length]; for (int i = 0, configsLength = configs.length; i < configsLength; i++) { String s = configs[i]; ConfigParser parser = new ConfigParser(s); String connectorFactoryClassName = parser.getConnectorFactoryClassName(); Map<String, Object> connectorParams = parser.getConnectorParameters(); String username = parser.getUsername(); String password = parser.getPassword(); TransportConfiguration transportConfiguration = new TransportConfiguration(connectorFactoryClassName, connectorParams); xaRecoveryConfigs[i] = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfiguration}, username, password); } res = new HornetQXAResourceWrapper(xaRecoveryConfigs); if (HornetQXAResourceRecovery.log.isTraceEnabled()) { HornetQXAResourceRecovery.log.trace(this + " initialised"); } return true; }