private void startLocalBridge() throws Throwable { if (!bridgeFailed.get() && localBridgeStarted.compareAndSet(false, true)) { synchronized (this) { LOG.trace("{} starting local Bridge, localBroker={}", configuration.getBrokerName(), localBroker); if (!disposed.get()) { localConnectionInfo = new ConnectionInfo(); localConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId())); localClientId = configuration.getName() + configuration.getClientIdToken() + remoteBrokerName + configuration.getClientIdToken() + "inbound" + configuration.getClientIdToken() + configuration.getBrokerName(); localConnectionInfo.setClientId(localClientId); localConnectionInfo.setUserName(configuration.getUserName()); localConnectionInfo.setPassword(configuration.getPassword()); X509Certificate[] peerCerts = originalTransport.getPeerCertificates(); localConnectionInfo.setTransportContext(peerCerts); Object resp = localBroker.request(localConnectionInfo); if (resp instanceof ExceptionResponse) { throw ((ExceptionResponse) resp).getException(); localBroker.oneway(localSessionInfo); ConnectionInfo duplexLocalConnectionInfo = new ConnectionInfo(); duplexLocalConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId())); duplexLocalConnectionInfo.setClientId(configuration.getName() + configuration.getClientIdToken() + remoteBrokerName + configuration.getClientIdToken() + "inbound" + configuration.getClientIdToken() + "duplex" + configuration.getClientIdToken() + configuration.getBrokerName());
private void collectBrokerInfos() { int timeout = 30000; TcpTransport tcpTransport = remoteBroker.narrow(TcpTransport.class); if (tcpTransport != null) { timeout = tcpTransport.getConnectionTimeout(); remoteBrokerName = remoteBrokerInfo.getBrokerName(); if (configuration.isUseBrokerNamesAsIdSeed()) { idGenerator = new IdGenerator(brokerService.getBrokerName() + "->" + remoteBrokerName);
broker = ID_GENERATOR.generateSanitizedId();
/** * Does a proper compare on the ids * * @param id1 * @param id2 * @return 0 if equal else a positive if id1 is > id2 ... */ public static int compare(String id1, String id2) { int result = -1; String seed1 = IdGenerator.getSeedFromId(id1); String seed2 = IdGenerator.getSeedFromId(id2); if (seed1 != null && seed2 != null) { result = seed1.compareTo(seed2); if (result == 0) { long count1 = IdGenerator.getSequenceFromId(id1); long count2 = IdGenerator.getSequenceFromId(id2); result = (int)(count1 - count2); } } return result; }
protected void startRemoteBridge() throws Exception { if (!bridgeFailed.get() && remoteBridgeStarted.compareAndSet(false, true)) { LOG.trace("{} starting remote Bridge, remoteBroker={}", configuration.getBrokerName(), remoteBroker); synchronized (this) { brokerInfo.setNetworkProperties(str); brokerInfo.setBrokerId(this.localBrokerId); remoteBroker.oneway(brokerInfo); if (configuration.isSyncDurableSubs() && remoteBroker.getWireFormat().getVersion() >= CommandTypes.PROTOCOL_VERSION_DURABLE_SYNC) { remoteBroker.oneway(NetworkBridgeUtils.getBrokerSubscriptionInfo(brokerService, configuration)); remoteBroker.oneway(remoteConnectionInfo.createRemoveCommand()); remoteConnectionInfo = new ConnectionInfo(); remoteConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId())); remoteConnectionInfo.setClientId(configuration.getName() + configuration.getClientIdToken() + configuration.getBrokerName() + configuration.getClientIdToken() + "outbound"); remoteConnectionInfo.setUserName(configuration.getUserName());
/** * Send the ConnectionInfo to the Broker * * @throws JMSException */ protected void ensureConnectionInfoSent() throws JMSException { synchronized(this.ensureConnectionInfoSentMutex) { // Can we skip sending the ConnectionInfo packet?? if (isConnectionInfoSentToBroker || closed.get()) { return; } //TODO shouldn't this check be on userSpecifiedClientID rather than the value of clientID? if (info.getClientId() == null || info.getClientId().trim().length() == 0) { info.setClientId(clientIdGenerator.generateId()); } syncSendPacket(info.copy(), getConnectResponseTimeout()); this.isConnectionInfoSentToBroker = true; // Add a temp destination advisory consumer so that // We know what the valid temporary destinations are on the // broker without having to do an RPC to the broker. ConsumerId consumerId = new ConsumerId(new SessionId(info.getConnectionId(), -1), consumerIdGenerator.getNextSequenceId()); if (watchTopicAdvisories) { advisoryConsumer = new AdvisoryConsumer(this, consumerId); } } }
protected void mainLoop() { while (this.running.get()) { this.scheduleTime.clearNewJob(); try { for (final JobLocation job : list) { if (!running.get()) { break; String jobId = ID_GENERATOR.generateId(); ByteSequence payload = getPayload(job.getLocation()); schedule(jobId, payload, "", job.getDelay(), job.getPeriod(), job.getRepeat());
connectionInfo = new ConnectionInfo(); connectionInfo.setConnectionId(new ConnectionId(ID_GENERATOR.generateId())); connectionInfo.setClientId(clientId); localBroker.oneway(connectionInfo); remoteBroker.oneway(connectionInfo); localBroker.oneway(sessionInfo); remoteBroker.oneway(sessionInfo);
String uniqueId = connectionIdGenerator.generateId(); this.info = new ConnectionInfo(new ConnectionId(uniqueId)); this.info.setManageable(true); this.info.setFaultTolerant(transport.isFaultTolerant()); this.connectionSessionId = new SessionId(info.getConnectionId(), -1); this.transport.setTransportListener(this); this.connectionAudit.setCheckForDuplicates(transport.isFaultTolerant());
protected void startBridge() throws Exception { connectionInfo = new ConnectionInfo(); connectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId())); connectionInfo.setClientId(idGenerator.generateId()); connectionInfo.setUserName(userName); connectionInfo.setPassword(password); connectionInfo.setBrokerMasterConnector(true); sessionInfo = new SessionInfo(connectionInfo, 1); producerInfo = new ProducerInfo(sessionInfo, 1); producerInfo.setResponseRequired(false); if (connector != null) { brokerInfo = connector.getBrokerInfo(); } else { brokerInfo = new BrokerInfo(); } brokerInfo.setBrokerName(broker.getBrokerName()); brokerInfo.setPeerBrokerInfos(broker.getBroker().getPeerBrokerInfos()); brokerInfo.setSlaveBroker(true); brokerInfo.setPassiveSlave(broker.isPassiveSlave()); restartBridge(); LOG.info("Slave connection between " + localBroker + " and " + remoteBroker + " has been established."); }
/** * * Constructor * * @param next */ public StatisticsBroker(Broker next) { super(next); this.advisoryProducerId.setConnectionId(ID_GENERATOR.generateId()); }
protected ProducerId createProducerId() { String id = idGenerator.generateId(); ConnectionId connectionId = new ConnectionId(id); SessionId sessionId = new SessionId(connectionId, 1); return new ProducerId(sessionId, 1); } }
public Multiplexer(Model model, String name, AsyncExecutors asyncExecutors, MessageDistribution messageDistribution) { this.model = model; this.name = name; this.asyncExecutors = asyncExecutors; this.messageDistribution = messageDistribution; inputs = new ConcurrentHashMap<>(); consumerIdMultiplexerInputMap = new ConcurrentHashMap<>(); outTransports = new ConcurrentHashMap<>(); inputId = new IdGenerator("InTransport"); multiplexerConnectionInfo = new ConnectionInfo(new ConnectionId(inputId.generateSanitizedId())); multiplexerSessionInfo = new SessionInfo(multiplexerConnectionInfo, -1); sessionIdGenerator = new AtomicLong(); producerIdGenerator = new AtomicLong(); consumerIdGenerator = new AtomicLong(); transactionIdGenerator = new AtomicLong(); inputCount = new AtomicLong(); userName = ""; password = ""; }
ConnectionId connectionId = new ConnectionId(connectionIdGenerator.generateId()); SessionId sessionId = new SessionId(connectionId, sessionIdGenerator.getNextSequenceId()); ConsumerId consumerId = new ConsumerId(sessionId, consumerIdGenerator.getNextSequenceId());
/** * Generate a unique ID - that is friendly for a URL or file system * * @return a unique id */ public String generateSanitizedId() { String result = generateId(); result = result.replace(':', '-'); result = result.replace('_', '-'); result = result.replace('.', '-'); return result; }
protected synchronized IdGenerator getClientIdGenerator() { if (clientIdGenerator == null) { if (clientIDPrefix != null) { clientIdGenerator = new IdGenerator(clientIDPrefix); } else { clientIdGenerator = new IdGenerator(); } } return clientIdGenerator; }
protected void startRemoteBridge() throws Exception { if (remoteBridgeStarted.compareAndSet(false, true)) { if (LOG.isTraceEnabled()) { LOG.trace(configuration.getBrokerName() + " starting remote Bridge, localBroker=" + localBroker); brokerInfo.setNetworkProperties(str); brokerInfo.setBrokerId(this.localBrokerId); remoteBroker.oneway(brokerInfo); remoteBroker.oneway(remoteConnectionInfo.createRemoveCommand()); remoteConnectionInfo = new ConnectionInfo(); remoteConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId())); remoteConnectionInfo.setClientId(configuration.getName() + "_" + configuration.getBrokerName() + "_outbound"); remoteConnectionInfo.setUserName(configuration.getUserName()); remoteConnectionInfo.setPassword(configuration.getPassword()); remoteBroker.oneway(remoteConnectionInfo); remoteBroker.oneway(demandConsumerInfo); startedLatch.countDown(); if (!disposed.get()) { triggerLocalStartBridge();
/** * Send the ConnectionInfo to the Broker * * @throws JMSException */ protected void ensureConnectionInfoSent() throws JMSException { synchronized(this.ensureConnectionInfoSentMutex) { // Can we skip sending the ConnectionInfo packet?? if (isConnectionInfoSentToBroker || closed.get()) { return; } //TODO shouldn't this check be on userSpecifiedClientID rather than the value of clientID? if (info.getClientId() == null || info.getClientId().trim().length() == 0) { info.setClientId(clientIdGenerator.generateId()); } syncSendPacket(info.copy()); this.isConnectionInfoSentToBroker = true; // Add a temp destination advisory consumer so that // We know what the valid temporary destinations are on the // broker without having to do an RPC to the broker. ConsumerId consumerId = new ConsumerId(new SessionId(info.getConnectionId(), -1), consumerIdGenerator.getNextSequenceId()); if (watchTopicAdvisories) { advisoryConsumer = new AdvisoryConsumer(this, consumerId); } } }
protected void mainLoop() { while (this.running.get()) { this.scheduleTime.clearNewJob(); try { for (final JobLocation job : list) { if (!running.get()) { break; String jobId = ID_GENERATOR.generateId(); ByteSequence payload = getPayload(job.getLocation()); schedule(jobId, payload, "", job.getDelay(), job.getPeriod(), job.getRepeat());
connectionInfo = new ConnectionInfo(); connectionInfo.setConnectionId(new ConnectionId(ID_GENERATOR.generateId())); connectionInfo.setClientId(clientId); localBroker.oneway(connectionInfo); remoteBroker.oneway(connectionInfo); localBroker.oneway(sessionInfo); remoteBroker.oneway(sessionInfo);