本文整理汇总了Java中org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory类的典型用法代码示例。如果您正苦于以下问题:Java InVMConnectorFactory类的具体用法?Java InVMConnectorFactory怎么用?Java InVMConnectorFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InVMConnectorFactory类属于org.apache.activemq.artemis.core.remoting.impl.invm包,在下文中一共展示了InVMConnectorFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEmbeddedConnectionFactory
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
private <T extends ActiveMQConnectionFactory> T createEmbeddedConnectionFactory(
Class<T> factoryClass) throws Exception {
try {
TransportConfiguration transportConfiguration = new TransportConfiguration(
InVMConnectorFactory.class.getName(),
this.properties.getEmbedded().generateTransportParameters());
ServerLocator serviceLocator = ActiveMQClient
.createServerLocatorWithoutHA(transportConfiguration);
return factoryClass.getConstructor(ServerLocator.class)
.newInstance(serviceLocator);
}
catch (NoClassDefFoundError ex) {
throw new IllegalStateException("Unable to create InVM "
+ "Artemis connection, ensure that artemis-jms-server.jar "
+ "is in the classpath", ex);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:ArtemisConnectionFactoryFactory.java
示例2: createQueue
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
private void createQueue(final String queueAddress, final String queueName, SubscriptionDurability durability) throws ActiveMQException, Exception {
final TransportConfiguration inVMTransportConfig = new TransportConfiguration(InVMConnectorFactory.class.getName());
try (ServerLocator loc = ActiveMQClient.createServerLocatorWithoutHA(inVMTransportConfig)) {
try (ClientSessionFactory sf = loc.createSessionFactory()) {
try (ClientSession session = sf.createSession()) {
final QueueQuery queryResults = session.queueQuery(new SimpleString(queueName));
if (!queryResults.isExists()) {
switch (durability) {
case TEMPORARY:
// If we created a temporary queue here, it'd be removed right after closing the ClientSession:
// there's no point. Only clients may create temporary queues (e.g. through their Consumer).
LOGGER.warn("Only a client may create a temporary queue: ignoring request");
break;
case DURABLE:
case DEFAULT:
session.createQueue(queueAddress, queueName, durability == SubscriptionDurability.DURABLE);
break;
default:
throw new IllegalArgumentException("Unknown subscription durability " + durability);
}
session.commit();
}
}
}
}
}
示例3: initDefaults
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
protected void initDefaults() {
if (locator == null) {
locator = ActiveMQClient.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");
}
示例4: setup
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
activeMQServer = ActiveMQServers.newActiveMQServer(configuration);
activeMQServer.start();
HashMap<String, Object> transportConfig = new HashMap<>();
serverLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig));
sessionFactory = serverLocator.createSessionFactory();
consumerSessionFactory = serverLocator.createSessionFactory();
SimpleString addr = SimpleString.toSimpleString("testQueue");
activeMQServer.addAddressInfo(new AddressInfo(addr, RoutingType.MULTICAST));
activeMQServer.createQueue(addr, RoutingType.MULTICAST, addr, null, false, false);
session = sessionFactory.createSession(true, true);
producer = session.createProducer(addr);
session.start();
}
示例5: setUp
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
super.setUp();
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addUser("testuser", "testpassword");
securityManager.getConfiguration().addUser("guest", "guest");
securityManager.getConfiguration().setDefaultUser("guest");
securityManager.getConfiguration().addRole("testuser", "arole");
securityManager.getConfiguration().addRole("guest", "arole");
Role role = new Role("arole", true, true, true, true, true, true, true, true, true, true);
Set<Role> roles = new HashSet<>();
roles.add(role);
server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
resourceAdapter = new ActiveMQResourceAdapter();
resourceAdapter.setEntries("[\"java://jmsXA\"]");
resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
}
示例6: setUp
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
useDummyTransactionManager();
super.setUp();
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addUser("testuser", "testpassword");
securityManager.getConfiguration().addUser("guest", "guest");
securityManager.getConfiguration().setDefaultUser("guest");
securityManager.getConfiguration().addRole("testuser", "arole");
securityManager.getConfiguration().addRole("guest", "arole");
Role role = new Role("arole", true, true, true, true, true, true, true, true, true, true);
Set<Role> roles = new HashSet<>();
roles.add(role);
server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
resourceAdapter = new ActiveMQResourceAdapter();
resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
}
示例7: setUp
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
useDummyTransactionManager();
super.setUp();
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("testuser", "testpassword");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("guest", "guest");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().setDefaultUser("guest");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("testuser", "arole");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("guest", "arole");
Role role = new Role("arole", true, true, true, true, true, true, true, true, true, true);
Set<Role> roles = new HashSet<>();
roles.add(role);
server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
resourceAdapter = new ActiveMQResourceAdapter();
resourceAdapter.setEntries("[\"java://jmsXA\"]");
resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
}
示例8: setUp
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
useDummyTransactionManager();
super.setUp();
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("testuser", "testpassword");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("guest", "guest");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().setDefaultUser("guest");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("testuser", "arole");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("guest", "arole");
Role role = new Role("arole", true, true, true, true, true, true, true, true);
Set<Role> roles = new HashSet<>();
roles.add(role);
server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
resourceAdapter = new ActiveMQResourceAdapter();
resourceAdapter.setEntries("[\"java://jmsXA\"]");
resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setAllowLocalTransactions(true);
mcf.setResourceAdapter(resourceAdapter);
qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
}
示例9: setUp
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getCanonicalName()));
testDir = temporaryFolder.getRoot().getAbsolutePath();
LegacyLDAPSecuritySettingPlugin legacyLDAPSecuritySettingPlugin = new LegacyLDAPSecuritySettingPlugin();
Map<String, String> map = new HashMap<>();
map.put(LegacyLDAPSecuritySettingPlugin.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
map.put(LegacyLDAPSecuritySettingPlugin.CONNECTION_URL, "ldap://localhost:1024");
map.put(LegacyLDAPSecuritySettingPlugin.CONNECTION_USERNAME, "uid=admin,ou=system");
map.put(LegacyLDAPSecuritySettingPlugin.CONNECTION_PASSWORD, "secret");
map.put(LegacyLDAPSecuritySettingPlugin.CONNECTION_PROTOCOL, "s");
map.put(LegacyLDAPSecuritySettingPlugin.AUTHENTICATION, "simple");
map.put(LegacyLDAPSecuritySettingPlugin.ENABLE_LISTENER, "true");
legacyLDAPSecuritySettingPlugin.init(map);
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager("LDAPLogin");
Configuration configuration = new ConfigurationImpl().setSecurityEnabled(true).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())).setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)).setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)).setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)).setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)).setPersistenceEnabled(false).addSecuritySettingPlugin(legacyLDAPSecuritySettingPlugin);
server = ActiveMQServers.newActiveMQServer(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager, false);
}
示例10: consumeMessages
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
public static void consumeMessages(final int expected, final Destination dest) throws JMSException {
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
try {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(dest);
connection.start();
Message m = null;
for (int i = 0; i < expected; i++) {
m = consumer.receive(500);
Assert.assertNotNull("expected to received " + expected + " messages, got only " + (i + 1), m);
}
m = consumer.receiveNoWait();
Assert.assertNull("received one more message than expected (" + expected + ")", m);
} finally {
if (connection != null) {
connection.close();
}
}
}
示例11: setUp
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
super.setUp();
setupServer2();
setupServer1();
jmsServer1.start();
jmsServer1.activated();
waitForServerToStart(jmsServer1.getActiveMQServer());
jmsServer2.start();
jmsServer2.activated();
waitForServerToStart(jmsServer2.getActiveMQServer());
waitForTopology(jmsServer1.getActiveMQServer(), 2);
waitForTopology(jmsServer2.getActiveMQServer(), 2);
cf1 = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(InVMConnectorFactory.class.getName(), generateInVMParams(1)));
cf2 = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(InVMConnectorFactory.class.getName(), generateInVMParams(2)));
}
示例12: createConfigServer
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
/**
* @return
*/
protected Configuration createConfigServer(final int source, final int destination) throws Exception {
final String destinationLabel = "toServer" + destination;
final String sourceLabel = "server" + source;
Configuration configuration = createDefaultInVMConfig(source).setSecurityEnabled(false)
.setJMXManagementEnabled(true)
.setPersistenceEnabled(false)
.addConnectorConfiguration(destinationLabel, new TransportConfiguration(InVMConnectorFactory.class.getName(), generateInVMParams(destination)))
.addConnectorConfiguration(sourceLabel, new TransportConfiguration(InVMConnectorFactory.class.getName(), generateInVMParams(source)))
.addClusterConfiguration(new ClusterConnectionConfiguration().setName(destinationLabel)
.setConnectorName(sourceLabel)
.setRetryInterval(250)
.setMaxHops(MAX_HOPS)
.setConfirmationWindowSize(1024)
.setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND)
.setStaticConnectors(new ArrayList<String>() {
{
add(destinationLabel);
}
}));
configuration.getAddressesSettings().put("#", new AddressSettings().setRedistributionDelay(0));
return configuration;
}
示例13: testCreateConnectionFactoryOverrideDiscovery
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
@Test
public void testCreateConnectionFactoryOverrideDiscovery() throws Exception {
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
ra.setConnectorClassName(InVMConnectorFactory.class.getName());
ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
connectionFactoryProperties.setDiscoveryAddress("myhost");
connectionFactoryProperties.setDiscoveryPort(5678);
connectionFactoryProperties.setDiscoveryLocalBindAddress("newAddress");
ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
ActiveMQConnectionFactory defaultFactory = ra.getDefaultActiveMQConnectionFactory();
Assert.assertNotSame(factory, defaultFactory);
DiscoveryGroupConfiguration dc = factory.getServerLocator().getDiscoveryGroupConfiguration();
UDPBroadcastEndpointFactory udpDg = (UDPBroadcastEndpointFactory) dc.getBroadcastEndpointFactory();
Assert.assertEquals(udpDg.getLocalBindAddress(), "newAddress");
Assert.assertEquals(udpDg.getGroupAddress(), "myhost");
Assert.assertEquals(udpDg.getGroupPort(), 5678);
}
示例14: getScaleDownConnector
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
public static ServerLocatorInternal getScaleDownConnector(ScaleDownPolicy scaleDownPolicy,
ActiveMQServer activeMQServer) throws ActiveMQException {
if (!scaleDownPolicy.getConnectors().isEmpty()) {
return (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(connectorNameListToArray(scaleDownPolicy.getConnectors(), activeMQServer));
} else if (scaleDownPolicy.getDiscoveryGroup() != null) {
DiscoveryGroupConfiguration dg = activeMQServer.getConfiguration().getDiscoveryGroupConfigurations().get(scaleDownPolicy.getDiscoveryGroup());
if (dg == null) {
throw ActiveMQMessageBundle.BUNDLE.noDiscoveryGroupFound(dg);
}
return (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(dg);
} else {
Map<String, TransportConfiguration> connectorConfigurations = activeMQServer.getConfiguration().getConnectorConfigurations();
for (TransportConfiguration transportConfiguration : connectorConfigurations.values()) {
if (transportConfiguration.getFactoryClassName().equals(InVMConnectorFactory.class.getName())) {
return (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(transportConfiguration);
}
}
}
throw ActiveMQMessageBundle.BUNDLE.noConfigurationFoundForScaleDown();
}
示例15: assertInVmConnectionFactory
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; //导入依赖的package包/类
private TransportConfiguration assertInVmConnectionFactory(
ActiveMQConnectionFactory connectionFactory) {
TransportConfiguration transportConfig = getSingleTransportConfiguration(
connectionFactory);
assertThat(transportConfig.getFactoryClassName())
.isEqualTo(InVMConnectorFactory.class.getName());
return transportConfig;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:ArtemisAutoConfigurationTests.java