本文整理汇总了Java中org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory类的典型用法代码示例。如果您正苦于以下问题:Java NettyConnectorFactory类的具体用法?Java NettyConnectorFactory怎么用?Java NettyConnectorFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NettyConnectorFactory类属于org.apache.activemq.artemis.core.remoting.impl.netty包,在下文中一共展示了NettyConnectorFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildArtemisBroker
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
public ActiveMQServer buildArtemisBroker() throws IOException {
Configuration configuration = new ConfigurationImpl();
configuration.setPersistenceEnabled(true);
configuration.setSecurityEnabled(false);
Map<String, Object> connectionParams = new HashMap<String, Object>();
connectionParams.put(
org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, 61400);
configuration.setBindingsDirectory(storeFolder.newFolder().getAbsolutePath());
configuration.setJournalDirectory(storeFolder.newFolder().getAbsolutePath());
configuration.setLargeMessagesDirectory(storeFolder.newFolder().getAbsolutePath());
configuration.setPagingDirectory(storeFolder.newFolder().getAbsolutePath());
configuration.addAcceptorConfiguration(
new TransportConfiguration(NettyAcceptorFactory.class.getName(), connectionParams));
configuration.addConnectorConfiguration("connector",
new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams));
return new ActiveMQServerImpl(configuration);
}
示例2: createNativeConnectionFactory
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
private <T extends ActiveMQConnectionFactory> T createNativeConnectionFactory(
Class<T> factoryClass) throws Exception {
Map<String, Object> params = new HashMap<String, Object>();
params.put(TransportConstants.HOST_PROP_NAME, this.properties.getHost());
params.put(TransportConstants.PORT_PROP_NAME, this.properties.getPort());
TransportConfiguration transportConfiguration = new TransportConfiguration(
NettyConnectorFactory.class.getName(), params);
Constructor<T> constructor = factoryClass.getConstructor(boolean.class,
TransportConfiguration[].class);
T connectionFactory = constructor.newInstance(false,
new TransportConfiguration[] { transportConfiguration });
String user = this.properties.getUser();
if (StringUtils.hasText(user)) {
connectionFactory.setUser(user);
connectionFactory.setPassword(this.properties.getPassword());
}
return connectionFactory;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:ArtemisConnectionFactoryFactory.java
示例3: process
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
public void process(InputStream inputStream, String host, int port, boolean transactional) throws Exception {
HashMap<String, Object> connectionParams = new HashMap<>();
connectionParams.put(TransportConstants.HOST_PROP_NAME, host);
connectionParams.put(TransportConstants.PORT_PROP_NAME, Integer.toString(port));
ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams));
ClientSessionFactory sf = serverLocator.createSessionFactory();
ClientSession session;
ClientSession managementSession;
if (user != null || password != null) {
session = sf.createSession(user, password, false, !transactional, true, false, 0);
managementSession = sf.createSession(user, password, false, true, true, false, 0);
} else {
session = sf.createSession(false, !transactional, true);
managementSession = sf.createSession(false, true, true);
}
localSession = true;
process(inputStream, session, managementSession);
}
示例4: testTransportConfiguration
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
@Test
public void testTransportConfiguration() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put(TransportConstants.PORT_PROP_NAME, 5665);
params.put(TransportConstants.HOST_PROP_NAME, RandomUtil.randomString());
TransportConfiguration config = new TransportConfiguration(NettyConnectorFactory.class.getName(), params);
ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(TransportConfigurationEncodingSupport.getEncodeSize(config));
TransportConfigurationEncodingSupport.encode(buffer, config);
assertEquals(buffer.capacity(), buffer.writerIndex());
buffer.readerIndex(0);
TransportConfiguration decoded = TransportConfigurationEncodingSupport.decode(buffer);
assertNotNull(decoded);
assertEquals(config.getName(), decoded.getName());
assertEquals(config.getFactoryClassName(), decoded.getFactoryClassName());
assertEquals(config.getParams().size(), decoded.getParams().size());
for (String key : config.getParams().keySet()) {
assertEquals(config.getParams().get(key).toString(), decoded.getParams().get(key).toString());
}
}
示例5: main
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
try {
CrashClient.log.debug("args = " + Arrays.asList(args));
ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName()));
locator.setClientFailureCheckPeriod(ClientCrashTest.PING_PERIOD);
locator.setConnectionTTL(ClientCrashTest.CONNECTION_TTL);
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession(false, true, true);
ClientProducer producer = session.createProducer(ClientCrashTest.QUEUE);
// it has to be durable otherwise it may race dying before the client is killed
ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 1);
message.getBodyBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT);
producer.send(message);
// exit without closing the session properly
System.exit(9);
} catch (Throwable t) {
CrashClient.log.error(t.getMessage(), t);
System.exit(1);
}
}
示例6: setUp
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
super.setUp();
DiscoveryGroupConfiguration dcg = new DiscoveryGroupConfiguration().setName("mygroup").setRefreshTimeout(5432).setDiscoveryInitialWaitTimeout(5432).setBroadcastEndpointFactory(new UDPBroadcastEndpointFactory().setGroupAddress(getUDPDiscoveryAddress()).setGroupPort(getUDPDiscoveryPort()).setLocalBindAddress("172.16.8.10"));
config = createBasicConfig().addConnectorConfiguration("netty", new TransportConfiguration(NettyConnectorFactory.class.getName())).addDiscoveryGroupConfiguration("mygroup", dcg);
ActiveMQServer server = createServer(false, config);
jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
}
示例7: deployConnectionFactory
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
@Override
public void deployConnectionFactory(final String clientId,
final JMSFactoryType type,
final String objectName,
final int prefetchSize,
final int defaultTempQueueFullSize,
final int defaultTempQueuePageSize,
final int defaultTempQueueDownCacheSize,
final boolean supportsFailover,
final boolean supportsLoadBalancing,
final int dupsOkBatchSize,
final boolean blockOnAcknowledge,
final String... jndiBindings) throws Exception {
List<TransportConfiguration> connectorConfigs = new ArrayList<>();
connectorConfigs.add(new TransportConfiguration(NettyConnectorFactory.class.getName()));
ArrayList<String> connectors = new ArrayList<>();
connectors.add("netty");
getJMSServerManager().createConnectionFactory(objectName, false, type, connectors, clientId, 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, prefetchSize, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, blockOnAcknowledge, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, dupsOkBatchSize, 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, jndiBindings);
}
示例8: adaptTransportConfiguration
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
/**
* Adapt the transport configuration by replacing the factoryClassName corresponding to an HornetQ's NettyConnectorFactory
* by the Artemis-based implementation.
*/
@Override
public TransportConfiguration adaptTransportConfiguration(TransportConfiguration tc) {
if (tc == null) {
return null;
}
String factoryClassName = tc.getFactoryClassName();
if (factoryClassName.equals("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory")) {
factoryClassName = NettyConnectorFactory.class.getName();
}
TransportConfiguration newConfig = new TransportConfiguration(factoryClassName,
tc.getParams(),
tc.getName(),
tc.getExtraParams());
return newConfig;
}
示例9: internalNewObject
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
@Override
protected ActiveMQConnectionFactory internalNewObject(URI uri,
Map<String, String> query,
String name) throws Exception {
JMSConnectionOptions options = newConectionOptions(uri, query);
List<TransportConfiguration> configurations = TCPTransportConfigurationSchema.getTransportConfigurations(uri, query, TransportConstants.ALLOWABLE_CONNECTOR_KEYS, name, NettyConnectorFactory.class.getName());
TransportConfiguration[] tcs = new TransportConfiguration[configurations.size()];
configurations.toArray(tcs);
ActiveMQConnectionFactory factory;
if (options.isHa()) {
factory = ActiveMQJMSClient.createConnectionFactoryWithHA(options.getFactoryTypeEnum(), tcs);
} else {
factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), tcs);
}
return BeanSupport.setData(uri, factory, query);
}
示例10: testTCPURI
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
@Test
public void testTCPURI() throws Exception {
TransportConfiguration tc = new TransportConfiguration(NettyConnectorFactory.class.getName());
HashMap<String, Object> params = new HashMap<>();
params.put("host", "localhost1");
params.put("port", 61617);
TransportConfiguration tc2 = new TransportConfiguration(NettyConnectorFactory.class.getName(), params);
HashMap<String, Object> params2 = new HashMap<>();
params2.put("host", "localhost2");
params2.put("port", 61618);
TransportConfiguration tc3 = new TransportConfiguration(NettyConnectorFactory.class.getName(), params2);
ActiveMQConnectionFactory connectionFactoryWithHA = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, tc, tc2, tc3);
URI tcp = parser.createSchema("tcp", connectionFactoryWithHA);
ActiveMQConnectionFactory factory = parser.newObject(tcp, null);
BeanUtilsBean bean = new BeanUtilsBean();
checkEquals(bean, connectionFactoryWithHA, factory);
}
示例11: createConnector
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
private TransportConfiguration createConnector(String host, int port) {
Map<String, Object> connectionParams = new HashMap<>();
connectionParams.put(HOST_PROP_NAME, host);
connectionParams.put(NIO_REMOTING_THREADS_PROPNAME, 2);
connectionParams.put(PORT_PROP_NAME, port);
connectionParams.put(TCP_NODELAY_PROPNAME, true);
// tuned for Gigabit switched single datacenter connections
connectionParams.put(TCP_SENDBUFFER_SIZE_PROPNAME, 40000);
connectionParams.put(TCP_RECEIVEBUFFER_SIZE_PROPNAME, 40000);
// don't use NIO on the client
connectionParams.put(USE_NIO_PROP_NAME, false);
return new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams);
}
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:17,代码来源:ActiveMQArtemisMessagingService.java
示例12: assertNettyConnectionFactory
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
private TransportConfiguration assertNettyConnectionFactory(
ActiveMQConnectionFactory connectionFactory, String host, int port) {
TransportConfiguration transportConfig = getSingleTransportConfiguration(
connectionFactory);
assertThat(transportConfig.getFactoryClassName())
.isEqualTo(NettyConnectorFactory.class.getName());
assertThat(transportConfig.getParams().get("host")).isEqualTo(host);
assertThat(transportConfig.getParams().get("port")).isEqualTo(port);
return transportConfig;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:ArtemisAutoConfigurationTests.java
示例13: init
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
@Override
public void init() throws InitException {
try {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("host", getHost());
map.put("port", getPort());
map.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
map.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, "http-acceptor");
TransportConfiguration transportConfiguration = new TransportConfiguration(
NettyConnectorFactory.class.getName(), map);
factory = new org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory(false, transportConfiguration);
connection = factory.createConnection(getUser(), getPassword());
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
dest = (getDestType() == DestType.QUEUE) ? session.createQueue(getDestination()) : session.createTopic(getDestination());
producer = session.createProducer(dest);
connection.start();
} catch (JMSException e) {
throw new InitException(e.fillInStackTrace());
}
}
示例14: createNativeConnectionFactory
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
private <T extends ActiveMQConnectionFactory> T createNativeConnectionFactory(
Class<T> factoryClass) throws Exception {
Map<String, Object> params = new HashMap<String, Object>();
params.put(TransportConstants.HOST_PROP_NAME, this.properties.getHost());
params.put(TransportConstants.PORT_PROP_NAME, this.properties.getPort());
TransportConfiguration transportConfiguration = new TransportConfiguration(
NettyConnectorFactory.class.getName(), params);
Constructor<T> constructor = factoryClass.getConstructor(boolean.class,
TransportConfiguration[].class);
return constructor.newInstance(false,
new TransportConfiguration[] { transportConfiguration });
}
示例15: assertNettyConnectionFactory
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; //导入依赖的package包/类
private TransportConfiguration assertNettyConnectionFactory(
ActiveMQConnectionFactory connectionFactory, String host, int port) {
TransportConfiguration transportConfig = getSingleTransportConfiguration(
connectionFactory);
assertEquals(NettyConnectorFactory.class.getName(),
transportConfig.getFactoryClassName());
assertEquals(host, transportConfig.getParams().get("host"));
assertEquals(port, transportConfig.getParams().get("port"));
return transportConfig;
}