本文整理汇总了Java中org.apache.activemq.broker.BrokerPlugin类的典型用法代码示例。如果您正苦于以下问题:Java BrokerPlugin类的具体用法?Java BrokerPlugin怎么用?Java BrokerPlugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BrokerPlugin类属于org.apache.activemq.broker包,在下文中一共展示了BrokerPlugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startBroker
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
@Before
public void startBroker() throws Exception {
broker = new BrokerService();
broker.setUseJmx(false);
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.addConnector(BROKER_URL);
broker.setBrokerName("localhost");
broker.setPopulateJMSXUserID(true);
broker.setUseAuthenticatedPrincipalForJMSXUserID(true);
// enable authentication
List<AuthenticationUser> users = new ArrayList<>();
// username and password to use to connect to the broker.
// This user has users privilege (able to browse, consume, produce, list destinations)
users.add(new AuthenticationUser(USERNAME, PASSWORD, "users"));
SimpleAuthenticationPlugin plugin = new SimpleAuthenticationPlugin(users);
BrokerPlugin[] plugins = new BrokerPlugin[]{ plugin };
broker.setPlugins(plugins);
broker.start();
// create JMS connection factory
connectionFactory = new ActiveMQConnectionFactory(BROKER_URL);
connectionFactoryWithoutPrefetch =
new ActiveMQConnectionFactory(BROKER_URL + "?jms.prefetchPolicy.all=0");
}
示例2: setUp
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
this.plugin = new KalinkaClusterPlugin(this.connectionStore, this.clientIdResolver);
this.customizedBroker = new EmbeddedActiveMQBroker() {
@Override
protected void configure() {
try {
final TransportConnector connector = new TransportConnector();
connector.setUri(new URI("mqtt://localhost:1883"));
connector.setName("mqtt");
this.getBrokerService().addConnector(connector);
this.getBrokerService().setPlugins(new BrokerPlugin[] { plugin });
} catch (final Exception e) {
e.printStackTrace();
}
}
};
this.customizedBroker.start();
}
示例3: createBroker
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
protected BrokerService createBroker(String name, boolean deleteMessagesOnStartup,
Map<String, Integer> portMap) throws Exception {
BrokerService brokerService = new BrokerService();
brokerService.setBrokerName(name);
brokerService.setDeleteAllMessagesOnStartup(deleteMessagesOnStartup);
brokerService.setUseJmx(true);
brokerService.getManagementContext().setCreateConnector(false);
brokerService.setDataDirectory(DATA_PARENT_DIR + File.separator + "data" + File.separator + name);
brokerService.setPersistent(false);
brokerService.setSchedulerSupport(false);
brokerService.setAdvisorySupport(false);
ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>();
BrokerPlugin authenticationPlugin = configureAuthentication();
if (authenticationPlugin != null) {
plugins.add(authenticationPlugin);
}
if (!plugins.isEmpty()) {
brokerService.setPlugins(plugins.toArray(new BrokerPlugin[0]));
}
addAdditionalConnectors(brokerService, portMap);
return brokerService;
}
示例4: createBroker
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
protected BrokerService createBroker() throws Exception {
brokerService = new BrokerService();
brokerService.setPersistent(false);
ArrayList<BrokerPlugin> plugins = new ArrayList<>();
BrokerPlugin authenticationPlugin = configureAuthentication();
plugins.add(authenticationPlugin);
BrokerPlugin[] array = new BrokerPlugin[plugins.size()];
brokerService.setPlugins(plugins.toArray(array));
transportConnector = brokerService.addConnector(LOCAL_URI);
proxyConnector = new ProxyConnector();
proxyConnector.setName("proxy");
proxyConnector.setBind(new URI(PROXY_URI));
proxyConnector.setRemote(new URI(LOCAL_URI));
brokerService.addProxyConnector(proxyConnector);
brokerService.start();
brokerService.waitUntilStarted();
return brokerService;
}
示例5: startBroker
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
public void startBroker() throws Exception {
brokerService = new BrokerService();
brokerService.setPersistent(false);
brokerService.setDeleteAllMessagesOnStartup(true);
brokerService.setAdvisorySupport(false);
brokerService.getManagementContext().setCreateConnector(false);
brokerService.getManagementContext().setCreateMBeanServer(false);
brokerService.addConnector("tcp://0.0.0.0:0");
ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>();
BrokerPlugin authenticationPlugin = configureAuthentication();
if (authenticationPlugin != null) {
plugins.add(configureAuthorization());
}
BrokerPlugin authorizationPlugin = configureAuthorization();
if (authorizationPlugin != null) {
plugins.add(configureAuthentication());
}
if (!plugins.isEmpty()) {
BrokerPlugin[] array = new BrokerPlugin[plugins.size()];
brokerService.setPlugins(plugins.toArray(array));
}
brokerService.start();
brokerService.waitUntilStarted();
connectionURI = brokerService.getTransportConnectors().get(0).getPublishableConnectString();
}
示例6: configureAuthentication
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
protected BrokerPlugin configureAuthentication() throws Exception {
List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
users.add(new AuthenticationUser("system", "manager", "users,admins"));
users.add(new AuthenticationUser("user", "password", "users"));
users.add(new AuthenticationUser("guest", "password", "guests"));
SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
return authenticationPlugin;
}
示例7: startWithPlugins
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
/**
* Starting ActiveMQ embedded broker after specifying plugins.
*
* @param brokerPlugins the array of BrokerPlugins to be set
* @return whether or not the broker was stated successfully
*/
public boolean startWithPlugins(BrokerPlugin[] brokerPlugins) {
try {
setInitialConfigurations();
broker.setPlugins(brokerPlugins);
startBroker();
return true;
} catch (Exception e) {
log.error("JMSServerController: There was an error starting JMS broker: " + serverName, e);
return false;
}
}
示例8: startBroker
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
public void startBroker() throws Exception {
String brokerName = "test-broker-" + System.currentTimeMillis();
String brokerUri = "vm://" + brokerName;
broker = new BrokerService();
broker.setBrokerName(brokerName);
broker.setBrokerId(brokerName);
broker.addConnector(brokerUri);
broker.setPersistent(false);
// This Broker Plugin simulates Producer Flow Control by delaying the broker's ACK by 2 seconds
broker.setPlugins(new BrokerPlugin[] {new DelayerBrokerPlugin()});
broker.start();
}
示例9: configureAuthentication
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
protected BrokerPlugin configureAuthentication() throws Exception {
List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
users.add(new AuthenticationUser(USERNAME_ADMIN, PASSWORD_ADMIN, "users,admins"));
users.add(new AuthenticationUser(USERNAME_USER, PASSWORD_USER, "users"));
users.add(new AuthenticationUser(USERNAME_GUEST, PASSWORD_GUEST, "guests"));
SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
authenticationPlugin.setAnonymousAccessAllowed(isAnonymousAccessAllowed());
return authenticationPlugin;
}
示例10: JMSBrokerService
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
public JMSBrokerService(String url) throws Exception {
System.setProperty(JMSTestConstants.ACTIVEMQ_LOGIN_CONFIG,
getClass().getClassLoader().getResource(JMSTestConstants.ACTIVEMQ_LOGIN_CONFIG_DIR).getPath());
broker = new BrokerService();
broker.setDataDirectory(JMSTestConstants.TEST_LOG_DIR);
broker.setBrokerName(BROKER_NAME);
broker.addConnector(url);
broker.setPlugins(new BrokerPlugin[] { new JaasAuthenticationPlugin() });
}
示例11: setUp
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
baseDir = Files.createTempDir();
tmpDir = new File(baseDir, "tmp");
dataDir = new File(baseDir, "data");
Assert.assertTrue(tmpDir.mkdir());
passwordFile = new File(baseDir, "password");
Files.write(PASSWORD.getBytes(StandardCharsets.UTF_8), passwordFile);
broker = new BrokerService();
broker.addConnector(BROKER_BIND_URL);
broker.setTmpDataDirectory(tmpDir);
broker.setDataDirectoryFile(dataDir);
List<AuthenticationUser> users = Lists.newArrayList();
users.add(new AuthenticationUser(USERNAME, PASSWORD, ""));
SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin(users);
broker.setPlugins(new BrokerPlugin[]{authentication});
broker.start();
basicConfig = new BasicConfig();
credentialsConfig = new CredentialsConfig();
dataFormatConfig = new DataParserFormatConfig();
messageConfig = new MessageConfig();
jmsSourceConfig = new JmsSourceConfig();
credentialsConfig.useCredentials = true;
credentialsConfig.username = () -> USERNAME;
credentialsConfig.password = () -> PASSWORD;
dataFormat = DataFormat.JSON;
dataFormatConfig.removeCtrlChars = true;
jmsSourceConfig.initialContextFactory = INITIAL_CONTEXT_FACTORY;
jmsSourceConfig.connectionFactory = CONNECTION_FACTORY;
jmsSourceConfig.destinationName = JNDI_PREFIX + DESTINATION_NAME;
jmsSourceConfig.providerURL = BROKER_BIND_URL;
// Create a connection and start
ConnectionFactory factory = new ActiveMQConnectionFactory(USERNAME,
PASSWORD, BROKER_BIND_URL);
connection = factory.createConnection();
connection.start();
}
示例12: setUp
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
baseDir = Files.createTempDir();
tmpDir = new File(baseDir, "tmp");
dataDir = new File(baseDir, "data");
Assert.assertTrue(tmpDir.mkdir());
passwordFile = new File(baseDir, "password");
Files.write(PASSWORD.getBytes(StandardCharsets.UTF_8), passwordFile);
broker = new BrokerService();
broker.addConnector(BROKER_BIND_URL);
broker.setTmpDataDirectory(tmpDir);
broker.setDataDirectoryFile(dataDir);
List<AuthenticationUser> users = Lists.newArrayList();
users.add(new AuthenticationUser(USERNAME, PASSWORD, ""));
SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin(users);
broker.setPlugins(new BrokerPlugin[]{authentication});
broker.start();
credentialsConfig = new CredentialsConfig();
dataFormatConfig = new DataGeneratorFormatConfig();
jmsTargetConfig = new JmsTargetConfig();
credentialsConfig.useCredentials = true;
credentialsConfig.username = () -> USERNAME;
credentialsConfig.password = () -> PASSWORD;
jmsTargetConfig.destinationName = JNDI_PREFIX + DESTINATION_NAME;
jmsTargetConfig.initialContextFactory = INITIAL_CONTEXT_FACTORY;
jmsTargetConfig.connectionFactory = CONNECTION_FACTORY;
jmsTargetConfig.providerURL = BROKER_BIND_URL;
// Create a connection and start
ConnectionFactory factory = new ActiveMQConnectionFactory(USERNAME,
PASSWORD, BROKER_BIND_URL);
connection = factory.createConnection();
connection.start();
}
示例13: createBroker
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
@Override
protected BrokerService createBroker() throws Exception {
BrokerService broker = super.createBroker();
broker.setPopulateJMSXUserID(true);
broker.setUseAuthenticatedPrincipalForJMSXUserID(true);
broker.setPlugins(new BrokerPlugin[]{authorizationPlugin, authenticationPlugin});
broker.setPersistent(false);
return broker;
}
示例14: createBroker
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
protected BrokerService createBroker() throws Exception {
BrokerService answer = new BrokerService();
BrokerPlugin[] plugins = new BrokerPlugin[1];
plugins[0] = new StatisticsBrokerPlugin();
answer.setPlugins(plugins);
answer.setDeleteAllMessagesOnStartup(true);
answer.addConnector("tcp://localhost:0");
answer.start();
return answer;
}
示例15: configureAuthentication
import org.apache.activemq.broker.BrokerPlugin; //导入依赖的package包/类
protected BrokerPlugin configureAuthentication() throws Exception {
List<AuthenticationUser> users = new ArrayList<>();
users.add(new AuthenticationUser(USER, GOOD_USER_PASSWORD, "users"));
SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
return authenticationPlugin;
}