private ClientSession createSessionInternal(final String username, final String password, final boolean xa, final boolean autoCommitSends, final boolean autoCommitAcks, final boolean preAcknowledge, final int ackBatchSize) throws ActiveMQException { String name = UUIDGenerator.getInstance().generateStringUUID(); SessionContext context = createSessionChannel(name, username, password, xa, autoCommitSends, autoCommitAcks, preAcknowledge); ClientSessionInternal session = new ClientSessionImpl(this, name, username, password, xa, autoCommitSends, autoCommitAcks, preAcknowledge, serverLocator.isBlockOnAcknowledge(), serverLocator.isAutoGroup(), ackBatchSize, serverLocator.getConsumerWindowSize(), serverLocator.getConsumerMaxRate(), serverLocator.getConfirmationWindowSize(), serverLocator.getProducerWindowSize(), serverLocator.getProducerMaxRate(), serverLocator.isBlockOnNonDurableSend(), serverLocator.isBlockOnDurableSend(), serverLocator.isCacheLargeMessagesClient(), serverLocator.getMinLargeMessageSize(), serverLocator.isCompressLargeMessage(), serverLocator.getInitialMessagePacketSize(), serverLocator.getGroupID(), context, orderedExecutorFactory.getExecutor(), orderedExecutorFactory.getExecutor(), orderedExecutorFactory.getExecutor()); synchronized (sessions) { if (closed || !clientProtocolManager.isAlive()) { session.close(); return null; } sessions.add(session); } return session; }
closeExecutor = orderedExecutorFactory.getExecutor();
public RemoteGroupingHandler(final ExecutorFactory executorFactory, final ManagementService managementService, final SimpleString name, final SimpleString address, final long timeout, final long groupTimeout) { super(executorFactory != null ? executorFactory.getExecutor() : null, managementService, address); this.name = name; this.timeout = timeout; this.groupTimeout = groupTimeout; }
public BackupManager(ActiveMQServer server, ExecutorFactory executorFactory, ScheduledExecutorService scheduledExecutor, NodeManager nodeManager, Configuration configuration, ClusterManager clusterManager) { this.server = server; this.executor = executorFactory.getExecutor(); this.scheduledExecutor = scheduledExecutor; this.nodeManager = nodeManager; this.configuration = configuration; this.clusterManager = clusterManager; }
@Override public synchronized PagingStore newStore(final SimpleString address, final AddressSettings settings) { return new PagingStoreImpl(address, scheduledExecutor, syncTimeout, pagingManager, storageManager, null, this, address, settings, executorFactory.getExecutor(), executorFactory.getExecutor(), syncNonTransactional); }
StompProtocolManager(final StompProtocolManagerFactory factory, final ActiveMQServer server, final List<StompFrameInterceptor> incomingInterceptors, final List<StompFrameInterceptor> outgoingInterceptors) { this.factory = factory; this.server = server; this.executor = server.getExecutorFactory().getExecutor(); this.incomingInterceptors = incomingInterceptors; this.outgoingInterceptors = outgoingInterceptors; }
StompProtocolManager(final StompProtocolManagerFactory factory, final ActiveMQServer server, final List<StompFrameInterceptor> incomingInterceptors, final List<StompFrameInterceptor> outgoingInterceptors) { this.factory = factory; this.server = server; this.executor = server.getExecutorFactory().getExecutor(); this.incomingInterceptors = incomingInterceptors; this.outgoingInterceptors = outgoingInterceptors; }
public static OperationContext getContext(final ExecutorFactory executorFactory) { OperationContext token = OperationContextImpl.threadLocalContext.get(); if (token == null) { if (executorFactory == null) { return null; } else { token = new OperationContextImpl(executorFactory.getExecutor()); OperationContextImpl.threadLocalContext.set(token); } } return token; }
private void handleHeartBeat(String heartBeatHeader) throws ActiveMQStompException { String[] params = heartBeatHeader.split(","); if (params.length != 2) { throw new ActiveMQStompException(connection, "Incorrect heartbeat header " + heartBeatHeader); } //client ping long minPingInterval = Long.valueOf(params[0]); //client receive ping long minAcceptInterval = Long.valueOf(params[1]); if (heartBeater == null) { heartBeater = new HeartBeater(scheduledExecutorService, executorFactory.getExecutor(), minPingInterval, minAcceptInterval); } }
public ClusterController(ActiveMQServer server, ScheduledExecutorService scheduledExecutor) { this.server = server; executor = server.getExecutorFactory().getExecutor(); quorumManager = new QuorumManager(scheduledExecutor, this); }
@Override public synchronized void start() throws Exception { if (started) { return; } beforeStart(); singleThreadExecutor = ioExecutorFactory.getExecutor(); bindingsJournal.start(); messageJournal.start(); started = true; }
public ActiveMQProtonRemotingConnection createConnection(ProtonProtocolManager protocolManager, Connection connection, Optional<EventHandler> eventHandler, ClientSASLFactory clientSASLFactory) { AMQPConnectionCallback connectionCallback = new AMQPConnectionCallback(protocolManager, connection, server.getExecutorFactory().getExecutor(), server); Executor executor = server.getExecutorFactory().getExecutor(); AMQPConnectionContext amqpConnection = new AMQPConnectionContext(protocolManager, connectionCallback, containerId, ttl, protocolManager.getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, useCoreSubscriptionNaming, server.getScheduledPool(), false, clientSASLFactory, connectionProperties); eventHandler.ifPresent(amqpConnection::addEventHandler); ActiveMQProtonRemotingConnection delegate = new ActiveMQProtonRemotingConnection(protocolManager, amqpConnection, connection, executor); delegate.addFailureListener(connectionCallback); delegate.addCloseListener(connectionCallback); connectionCallback.setProtonConnectionDelegate(delegate); return delegate; } }
public ActiveMQProtonRemotingConnection createConnection(ProtonProtocolManager protocolManager, Connection connection, Optional<EventHandler> eventHandler, ClientSASLFactory clientSASLFactory) { AMQPConnectionCallback connectionCallback = new AMQPConnectionCallback(protocolManager, connection, server.getExecutorFactory().getExecutor(), server); Executor executor = server.getExecutorFactory().getExecutor(); AMQPConnectionContext amqpConnection = new AMQPConnectionContext(protocolManager, connectionCallback, containerId, ttl, protocolManager.getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, useCoreSubscriptionNaming, server.getScheduledPool(), false, clientSASLFactory, connectionProperties); eventHandler.ifPresent(amqpConnection::addEventHandler); ActiveMQProtonRemotingConnection delegate = new ActiveMQProtonRemotingConnection(protocolManager, amqpConnection, connection, executor); delegate.addFailureListener(connectionCallback); delegate.addCloseListener(connectionCallback); connectionCallback.setProtonConnectionDelegate(delegate); return delegate; } }
@Override public ConnectionEntry createConnectionEntry(Acceptor acceptorUsed, Connection connection) { OpenWireFormat wf = (OpenWireFormat) wireFactory.createWireFormat(); OpenWireConnection owConn = new OpenWireConnection(connection, server, server.getExecutorFactory().getExecutor(), this, wf); owConn.sendHandshake(); //first we setup ttl to -1 //then when negotiation, we handle real ttl and delay ConnectionEntry entry = new ConnectionEntry(owConn, null, System.currentTimeMillis(), -1); owConn.setConnectionEntry(entry); return entry; }
@Override public synchronized void startAddressQueueScanner() { if (addressQueueReaperPeriod > 0) { if (addressQueueReaperRunnable != null) addressQueueReaperRunnable.stop(); addressQueueReaperRunnable = new AddressQueueReaper(server.getScheduledPool(), server.getExecutorFactory().getExecutor(), addressQueueReaperPeriod, TimeUnit.MILLISECONDS, false); addressQueueReaperRunnable.start(); } }
/** * The expiry scanner can't be started until the whole server has been started other wise you may get races */ @Override public synchronized void startExpiryScanner() { if (expiryReaperPeriod > 0) { if (expiryReaperRunnable != null) expiryReaperRunnable.stop(); expiryReaperRunnable = new ExpiryReaper(server.getScheduledPool(), server.getExecutorFactory().getExecutor(), expiryReaperPeriod, TimeUnit.MILLISECONDS, false); expiryReaperRunnable.start(); } }
private StompSession internalGetSession(StompConnection connection, Map<Object, StompSession> sessions, Object id, boolean transacted) throws Exception { StompSession stompSession = sessions.get(id); if (stompSession == null) { stompSession = new StompSession(connection, this, server.getStorageManager().newContext(server.getExecutorFactory().getExecutor())); String name = UUIDGenerator.getInstance().generateStringUUID(); ServerSession session = server.createSession(name, connection.getLogin(), connection.getPasscode(), ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, connection, !transacted, false, false, false, null, stompSession, true, server.newOperationContext(), getPrefixes()); stompSession.setServerSession(session); sessions.put(id, stompSession); } server.getStorageManager().setContext(stompSession.getContext()); return stompSession; }
public StompSession getSession(StompConnection connection) throws Exception { StompSession stompSession = sessions.get(connection.getID()); if (stompSession == null) { stompSession = new StompSession(connection, this, server.getStorageManager().newContext(server.getExecutorFactory().getExecutor())); String name = UUIDGenerator.getInstance().generateStringUUID(); ServerSession session = server.createSession(name, connection.getLogin(), connection.getPasscode(), ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, connection, true, false, false, false, null, stompSession, true, server.newOperationContext(), getPrefixes()); stompSession.setServerSession(session); sessions.put(connection.getID(), stompSession); } server.getStorageManager().setContext(stompSession.getContext()); return stompSession; }
@Override public Queue createQueueWith(final QueueConfig config) { final Queue queue; if (lastValueKey(config) != null) { queue = new LastValueQueue(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), config.deliveryMode(), config.maxConsumers(), config.isExclusive(), config.consumersBeforeDispatch(), config.delayBeforeDispatch(), config.isPurgeOnNoConsumers(), lastValueKey(config), config.isNonDestructive(), config.isConfigurationManaged(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor(), server, this); } else { queue = new QueueImpl(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), config.deliveryMode(), config.maxConsumers(), config.isExclusive(), config.isNonDestructive(), config.consumersBeforeDispatch(), config.delayBeforeDispatch(), config.isPurgeOnNoConsumers(), config.isConfigurationManaged(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor(), server, this); } server.getCriticalAnalyzer().add(queue); return queue; }
@Test public void testDoubleStart() throws Exception { SequentialFileFactory factory = new FakeSequentialFileFactory(); PagingStore storeImpl = new PagingStoreImpl(PagingStoreImplTest.destinationTestName, null, 100, createMockManager(), createStorageManagerMock(), factory, new FakeStoreFactory(factory), PagingStoreImplTest.destinationTestName, new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE), getExecutorFactory().getExecutor(), true); storeImpl.start(); // this is not supposed to throw an exception. // As you could have start being called twice as Stores are dynamically // created, on a multi-thread environment storeImpl.start(); storeImpl.stop(); }