本文整理汇总了Java中org.apache.activemq.broker.Broker类的典型用法代码示例。如果您正苦于以下问题:Java Broker类的具体用法?Java Broker怎么用?Java Broker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Broker类属于org.apache.activemq.broker包,在下文中一共展示了Broker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installPlugin
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
@Override
public Broker installPlugin(Broker parent) throws Exception {
logger.info("Initialize JWTAuthenticationPlugin");
Set<Principal> groups = new HashSet();
StringTokenizer iter = new StringTokenizer(this.defaultUserGroups, ",");
while (iter.hasMoreTokens()) {
String name = iter.nextToken().trim();
groups.add(new GroupPrincipal(name));
}
JaasAuthenticationPlugin jaasAuthenticationPlugin = new JaasAuthenticationPlugin();
jaasAuthenticationPlugin.setConfiguration(this.jaasConfiguration);
jaasAuthenticationPlugin.setDiscoverLoginConfig(this.discoverLoginConfig);
Broker jaasAuthenticationFallbackBroker = jaasAuthenticationPlugin.installPlugin(parent);
return new JWTAuthenticationBroker(
parent, jaasAuthenticationFallbackBroker, this.defaultUser,
groups, this.masterSecretKey, this.tokenHeader);
}
开发者ID:hishamaborob,项目名称:ActiveMQ-JWT-Authentication-Plugin,代码行数:20,代码来源:JWTAuthenticationPlugin.java
示例2: addConnectionNullCloudTest
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
@Test(priority=3, expectedExceptions = CmsAuthException.class)
public void addConnectionNullCloudTest() throws Exception{
Broker broker = mock(Broker.class);
CMSClient oddClient = mock(CMSClient.class);
CmsCISimple cmsCISimple = new CmsCISimple();
Map<String, String> ciAttributes = new HashMap<String, String>(1);
ciAttributes.put(AUTH_ATTR_KEY, AUTH_KEY_VALUE);
cmsCISimple.setCiAttributes(ciAttributes);
when(oddClient.getCloudCi(CLOUD_NAME, CLOUD_NAME)).thenReturn(
cmsCISimple);
when(oddClient.getCloudCi(anyString(), anyString())).thenReturn(null); // causes the exception
OneopsAuthBroker oneopsAuthBroker = new OneopsAuthBroker(broker,oddClient);
oneopsAuthBroker.addConnection(connectionContextMock, connectionBadInfo); //bad cloud, is error
}
示例3: installPlugin
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
public Broker installPlugin(Broker broker) throws Exception {
configStore.addVar(PluginVariables.REDIS_HOST, "localhost");
configStore.addVar(PluginVariables.REDIS_PORT, "6379");
configStore.addVar(PluginVariables.REDIS_DB, "0");
configStore.addVar(PluginVariables.REDIS_CONNECTION_STRING, null);
configStore.addVar(PluginVariables.WEBAUTH_SERVER_URL, "https://yourserver/webauth/user");
configStore.addVar(PluginVariables.CA_CERTS_STORE_PATH, null);
System.out.println(PluginVariables.WEBAUTH_SERVER_URL + ": " + configStore.getVar(PluginVariables.WEBAUTH_SERVER_URL));
System.out.println(PluginVariables.CA_CERTS_STORE_PATH + ": " + configStore.getVar(PluginVariables.CA_CERTS_STORE_PATH));
if (null != configStore.getVar(PluginVariables.CA_CERTS_STORE_PATH)) {
System.setProperty("javax.net.ssl.trustStore", configStore.getVar(PluginVariables.CA_CERTS_STORE_PATH));
System.setProperty("javax.net.ssl.trustAnchors", configStore.getVar(PluginVariables.CA_CERTS_STORE_PATH));
}
webAuthClient = new WebAuthClient(configStore.getVar(PluginVariables.WEBAUTH_SERVER_URL), logger);
return new WebAuthBroker(broker, configStore, webAuthClient, logger);
}
示例4: configure
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
public void configure(Broker broker,Queue queue) {
baseConfiguration(broker,queue);
if (dispatchPolicy != null) {
queue.setDispatchPolicy(dispatchPolicy);
}
queue.setDeadLetterStrategy(getDeadLetterStrategy());
queue.setMessageGroupMapFactory(getMessageGroupMapFactory());
if (memoryLimit > 0) {
queue.getMemoryUsage().setLimit(memoryLimit);
}
if (pendingQueuePolicy != null) {
PendingMessageCursor messages = pendingQueuePolicy.getQueuePendingMessageCursor(broker,queue);
queue.setMessages(messages);
}
queue.setUseConsumerPriority(isUseConsumerPriority());
queue.setStrictOrderDispatch(isStrictOrderDispatch());
queue.setOptimizedDispatch(isOptimizedDispatch());
queue.setLazyDispatch(isLazyDispatch());
queue.setTimeBeforeDispatchStarts(getTimeBeforeDispatchStarts());
queue.setConsumersBeforeDispatchStarts(getConsumersBeforeDispatchStarts());
queue.setAllConsumersExclusiveByDefault(isAllConsumersExclusiveByDefault());
}
示例5: StoreDurableSubscriberCursor
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
/**
* @param broker Broker for this cursor
* @param clientId clientId for this cursor
* @param subscriberName subscriber name for this cursor
* @param maxBatchSize currently ignored
* @param subscription subscription for this cursor
*/
public StoreDurableSubscriberCursor(Broker broker,String clientId, String subscriberName,int maxBatchSize, DurableTopicSubscription subscription) {
super(AbstractPendingMessageCursor.isPrioritizedMessageSubscriber(broker,subscription));
this.subscription=subscription;
this.clientId = clientId;
this.subscriberName = subscriberName;
if (broker.getBrokerService().isPersistent()) {
this.nonPersistent = new FilePendingMessageCursor(broker,clientId + subscriberName,this.prioritizedMessages);
} else {
this.nonPersistent = new VMPendingMessageCursor(this.prioritizedMessages);
}
this.nonPersistent.setMaxBatchSize(maxBatchSize);
this.nonPersistent.setSystemUsage(systemUsage);
this.storePrefetches.add(this.nonPersistent);
if (prioritizedMessages) {
setMaxAuditDepth(10*getMaxAuditDepth());
}
}
示例6: matchesSomeConsumer
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
private boolean matchesSomeConsumer(final Broker broker, Message message, Destination dest) throws IOException {
boolean matches = false;
MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext();
msgContext.setDestination(dest.getActiveMQDestination());
msgContext.setMessageReference(message);
List<Subscription> subs = dest.getConsumers();
for (Subscription sub : subs) {
if (sub.matches(message, msgContext)) {
matches = true;
break;
}
}
if (matches == false && subs.size() == 0) {
matches = tryMatchingCachedSubs(broker, dest, msgContext);
}
return matches;
}
示例7: tryMatchingCachedSubs
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
private boolean tryMatchingCachedSubs(final Broker broker, Destination dest, MessageEvaluationContext msgContext) {
boolean matches = false;
LOG.debug("No active consumer match found. Will try cache if configured...");
//retrieve the specific plugin class and lookup the selector for the destination.
final SubQueueSelectorCacheBroker cache = getSubQueueSelectorCacheBrokerPlugin(broker);
if (cache != null) {
final String selector = cache.getSelector(dest.getActiveMQDestination().getQualifiedName());
if (selector != null) {
try {
final BooleanExpression expression = getExpression(selector);
matches = expression.matches(msgContext);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}
return matches;
}
示例8: JWTAuthenticationBroker
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
public JWTAuthenticationBroker(
Broker next, Broker jaasAuthenticationFallbackBroker, String defaultUser,
Set<Principal> defaultUserGroups, String masterSecretKey, String tokenHeader) {
super(next);
this.jaasAuthenticationFallbackBroker = jaasAuthenticationFallbackBroker;
this.defaultUser = defaultUser;
this.defaultUserGroups = defaultUserGroups;
this.masterSecretKey = masterSecretKey;
this.tokenHeader = tokenHeader;
logger.info("Initialize JWTAuthenticationBroker");
}
开发者ID:hishamaborob,项目名称:ActiveMQ-JWT-Authentication-Plugin,代码行数:13,代码来源:JWTAuthenticationBroker.java
示例9: OneopsAuthBroker
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
/**
* Instantiates a new auth broker filter.
*
* @param next the next
* @param cms the cms
*/
public OneopsAuthBroker(Broker next, CMSClient cms) {
super(next);
this.superpass = System.getenv("KLOOPZ_AMQ_PASS");
if (this.superpass == null) {
logger.error("The env var KLOOPZ_AMQ_PASS is not set");
throw new CmsAuthException("The env var KLOOPZ_AMQ_PASS is not set");
}
this.cmsClient = cms;
userMap.put("system", "*");
}
示例10: constructorTest
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
@Test(priority=2)
/**
* construct object ok. Note - it becomes the instance variable used from now on
* succeeds because of the Env setup that's done off the bat
*/
public void constructorTest(){
setEnvironmentVariable();
Broker broker = mock(Broker.class);
this.oneopsAuthBroker = new OneopsAuthBroker(broker, cmsClient);
}
示例11: WebAuthBroker
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
public WebAuthBroker(Broker next, ConfigStore configStore, WebAuthClient webAuthClient, Logger logger) {
super(next);
this.configStore = configStore;
this.webAuthClient = webAuthClient;
this.logger = logger;
prepareRedisConnectionString();
}
示例12: installPlugin
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
@Override
public Broker installPlugin(final Broker next) throws Exception {
LOG.info("Installing plugin...");
return new BrokerFilter(next) {
@Override
public void send(final ProducerBrokerExchange producerExchange, final Message messageSend) throws Exception {
try {
final String destination = messageSend.getDestination().getPhysicalName();
final IMessagePublisher<Message, K, V> publisher = messagePublisherProvider.getPublisher(destination);
if (publisher == null) {
LOG.debug("No kakfa-publisher found for destination={}. Will forward message.", destination);
super.send(producerExchange, messageSend);
} else {
publisher.publish(messageSend, kafkaTemplate);
}
} catch (final Throwable t) {
LOG.error("Exception occured", t);
throw t;
}
}
};
}
示例13: installPlugin
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Broker installPlugin(Broker broker) {
initialiseJaas();
return new CommunoteJaasAuthenticationBroker(settingsDao, embeddedConfiguration, broker,
getConfiguration(),
getSslConfiguration());
}
示例14: installPlugin
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
@Override
public Broker installPlugin(Broker broker) {
HashMap<String, String> u = new HashMap<>();
u.put("system", "manager");
u.put("user", "password");
u.put("guest", "password");
Map<String, Set<Principal>> groups = new HashMap<>();
groups.put("system", new HashSet<>(Arrays.asList(new Principal[]{ADMINS, USERS})));
groups.put("user", new HashSet<>(Arrays.asList(new Principal[]{USERS})));
groups.put("guest", new HashSet<>(Arrays.asList(new Principal[]{GUESTS})));
return new SimpleAuthenticationBroker(broker, u, groups);
}
示例15: sendToDestination
import org.apache.activemq.broker.Broker; //导入依赖的package包/类
private void sendToDestination(Broker broker, ProducerBrokerExchange context, Message message, ActiveMQDestination destination) throws Exception {
if (broker.getDestinations(destination).isEmpty()) {
broker.getBrokerService().getRegionBroker().addDestination(broker.getAdminConnectionContext(), destination,true);
}
for (Destination dest : broker.getDestinations(destination)) {
logger.debug("Following search sending request to Destination " + dest.getName());
dest.send(context, message.copy());
}
}