本文整理汇总了Java中org.apache.activemq.command.ConnectionInfo.getClientId方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionInfo.getClientId方法的具体用法?Java ConnectionInfo.getClientId怎么用?Java ConnectionInfo.getClientId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.command.ConnectionInfo
的用法示例。
在下文中一共展示了ConnectionInfo.getClientId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeConnection
import org.apache.activemq.command.ConnectionInfo; //导入方法依赖的package包/类
@Override
public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception {
String clientId = info.getClientId();
if (clientId == null) {
throw new InvalidClientIDException("No clientID specified for connection disconnect request");
}
synchronized (clientIdSet) {
ConnectionContext oldValue = clientIdSet.get(clientId);
// we may be removing the duplicate connection, not the first
// connection to be created
// so lets check that their connection IDs are the same
if (oldValue == context) {
if (isEqual(oldValue.getConnectionId(), info.getConnectionId())) {
clientIdSet.remove(clientId);
}
}
}
connections.remove(context.getConnection());
}
示例2: removeConnection
import org.apache.activemq.command.ConnectionInfo; //导入方法依赖的package包/类
public void removeConnection(ConnectionInfo info, Throwable error) throws InvalidClientIDException {
synchronized (clientIdSet) {
String clientId = info.getClientId();
if (clientId != null) {
AMQConnectionContext context = this.clientIdSet.get(clientId);
if (context != null && context.decRefCount() == 0) {
//connection is still there and need to close
context.getConnection().disconnect(error != null);
this.connections.remove(context.getConnection());
this.clientIdSet.remove(clientId);
}
} else {
throw new InvalidClientIDException("No clientID specified for connection disconnect request");
}
}
}
示例3: startBridge
import org.apache.activemq.command.ConnectionInfo; //导入方法依赖的package包/类
/**
* @throws IOException
*/
final void startBridge() throws IOException {
connectionInfo = new ConnectionInfo();
connectionInfo.setConnectionId(new ConnectionId(ID_GENERATOR.generateId()));
connectionInfo.setClientId(clientId);
localBroker.oneway(connectionInfo);
remoteBroker.oneway(connectionInfo);
sessionInfo = new SessionInfo(connectionInfo, 1);
localBroker.oneway(sessionInfo);
remoteBroker.oneway(sessionInfo);
queueConsumerInfo = new ConsumerInfo(sessionInfo, 1);
queueConsumerInfo.setDispatchAsync(dispatchAsync);
queueConsumerInfo.setDestination(new ActiveMQQueue(destinationFilter));
queueConsumerInfo.setPrefetchSize(prefetchSize);
queueConsumerInfo.setPriority(ConsumerInfo.NETWORK_CONSUMER_PRIORITY);
localBroker.oneway(queueConsumerInfo);
producerInfo = new ProducerInfo(sessionInfo, 1);
producerInfo.setResponseRequired(false);
remoteBroker.oneway(producerInfo);
if (connectionInfo.getClientId() != null) {
topicConsumerInfo = new ConsumerInfo(sessionInfo, 2);
topicConsumerInfo.setDispatchAsync(dispatchAsync);
topicConsumerInfo.setSubscriptionName("topic-bridge");
topicConsumerInfo.setRetroactive(true);
topicConsumerInfo.setDestination(new ActiveMQTopic(destinationFilter));
topicConsumerInfo.setPrefetchSize(prefetchSize);
topicConsumerInfo.setPriority(ConsumerInfo.NETWORK_CONSUMER_PRIORITY);
localBroker.oneway(topicConsumerInfo);
}
LOG.info("Network connection between {} and {} has been established.", localBroker, remoteBroker);
}
示例4: processAddConnection
import org.apache.activemq.command.ConnectionInfo; //导入方法依赖的package包/类
@Override
public Response processAddConnection(ConnectionInfo info) throws Exception {
Response answer = super.processAddConnection(info);
String clientId = info.getClientId();
if (populateUserName) {
((ConnectionView) mbean).setUserName(info.getUserName());
}
if (clientId != null) {
if (byClientIdName == null) {
byClientIdName = createObjectName("clientId", clientId);
registerMBean(byClientIdName);
}
}
return answer;
}
示例5: addConnection
import org.apache.activemq.command.ConnectionInfo; //导入方法依赖的package包/类
@Override
public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
String clientId = info.getClientId();
if (clientId == null) {
throw new InvalidClientIDException("No clientID specified for connection request");
}
synchronized (clientIdSet) {
ConnectionContext oldContext = clientIdSet.get(clientId);
if (oldContext != null) {
if (context.isAllowLinkStealing()){
clientIdSet.remove(clientId);
if (oldContext.getConnection() != null) {
LOG.warn("Stealing link for clientId {} From Connection {}", clientId, oldContext.getConnection());
oldContext.getConnection().stop();
}else{
LOG.error("Not Connection for {}", oldContext);
}
}else{
throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected from "
+ oldContext.getConnection().getRemoteAddress());
}
} else {
clientIdSet.put(clientId, context);
}
}
connections.add(context.getConnection());
}
示例6: initContext
import org.apache.activemq.command.ConnectionInfo; //导入方法依赖的package包/类
public AMQConnectionContext initContext(ConnectionInfo info) throws Exception {
WireFormatInfo wireFormatInfo = wireFormat.getPreferedWireFormatInfo();
// Older clients should have been defaulting this field to true.. but
// they were not.
if (wireFormatInfo != null && wireFormatInfo.getVersion() <= 2) {
info.setClientMaster(true);
}
state = new ConnectionState(info);
context = new AMQConnectionContext();
state.reset(info);
// Setup the context.
String clientId = info.getClientId();
context.setBroker(protocolManager);
context.setClientId(clientId);
context.setClientMaster(info.isClientMaster());
context.setConnection(this);
context.setConnectionId(info.getConnectionId());
// for now we pass the manager as the connector and see what happens
// it should be related to activemq's Acceptor
context.setFaultTolerant(info.isFaultTolerant());
context.setUserName(info.getUserName());
context.setWireFormatInfo(wireFormatInfo);
context.setReconnect(info.isFailoverReconnect());
context.setConnectionState(state);
if (info.getClientIp() == null) {
info.setClientIp(getRemoteAddress());
}
createInternalSession(info);
return context;
}
示例7: addConnection
import org.apache.activemq.command.ConnectionInfo; //导入方法依赖的package包/类
/**
* Add new connection.
*
* @param context
* @param info
* @throws Exception
* @see org.apache.activemq.broker.BrokerFilter#addConnection(org.apache.activemq.broker.ConnectionContext, org.apache.activemq.command.ConnectionInfo)
*/
public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
String clientId = info.getClientId();
String usr = info.getUserName();
String pass = info.getPassword();
logger.info("Add new connection { Remote Address: " + context.getConnection().getRemoteAddress()
+ ", User: " + usr + ", ClientID: " + clientId + " } ");
if (usr != null && pass != null) {
if (SYSTEM_USER.equals(usr) || (SUPER_USER.equals(usr) && superpass.equals(pass))) {
userMap.put(clientId, "*");
} else {
String[] parts = usr.split(":");
if (parts.length > 1) {
String ns = parts[0];/*"/public/packer/providers"*/
String cloudName = parts[1]; /*"ec2.us-east-1a"*/
CmsCISimple cloud = cmsClient.getCloudCi(ns, cloudName);
if (cloud != null) {
String authkey = cloud.getCiAttributes().get("auth");
if (authkey.equals(pass)) {
String queueName = (ns.replaceAll("/", ".") + "." + cloudName + QUEUE_SUFFIX).substring(1);
userMap.put(clientId, queueName);
} else {
logger.error("Got bad password for cloud " + cloudName + ", NsPath: " + ns);
throw new CmsAuthException("Bad password for user: " + usr);
}
} else {
logger.error("Got null cloud object for user: " + usr);
throw new CmsAuthException("Bad user/pass combination");
}
} else {
throw new CmsAuthException("Bad user/pass combination");
}
}
} else {
logger.error("Got null user/pass");
throw new CmsAuthException("Got null user/pass");
}
super.addConnection(context, info);
}
示例8: addConnection
import org.apache.activemq.command.ConnectionInfo; //导入方法依赖的package包/类
public void addConnection(OpenWireConnection connection, ConnectionInfo info) throws Exception {
String username = info.getUserName();
String password = info.getPassword();
try {
validateUser(username, password, connection);
} catch (ActiveMQSecurityException e) {
// We need to send an exception used by the openwire
SecurityException ex = new SecurityException("User name [" + username + "] or password is invalid.");
ex.initCause(e);
throw ex;
}
String clientId = info.getClientId();
if (clientId == null) {
throw new InvalidClientIDException("No clientID specified for connection request");
}
synchronized (clientIdSet) {
AMQConnectionContext context;
context = clientIdSet.get(clientId);
if (context != null) {
if (info.isFailoverReconnect()) {
OpenWireConnection oldConnection = context.getConnection();
oldConnection.disconnect(true);
connections.remove(oldConnection);
connection.reconnect(context, info);
} else {
throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected from " + context.getConnection().getRemoteAddress());
}
} else {
//new connection
context = connection.initContext(info);
clientIdSet.put(clientId, context);
}
connections.add(connection);
ActiveMQTopic topic = AdvisorySupport.getConnectionAdvisoryTopic();
// do not distribute passwords in advisory messages. usernames okay
ConnectionInfo copy = info.copy();
copy.setPassword("");
fireAdvisory(context, topic, copy);
// init the conn
context.getConnection().addSessions(context.getConnectionState().getSessionIds());
}
}