/** * Create an async-event-queue with the given name. * For a partitioned region a parallel queue is created. * Otherwise a serial queue is created. */ private void createAsyncEventQueue(Cache cache, String queueName, boolean isPartitioned) { AsyncEventQueueFactory asyncEventQueueFactory = cache.createAsyncEventQueueFactory(); asyncEventQueueFactory.setParallel(isPartitioned); asyncEventQueueFactory.create(queueName, new JdbcAsyncWriter()); }
private static AsyncEventQueueFactory getInitialAsyncEventQueueFactory(boolean isParallel, Integer maxMemory, Integer batchSize, boolean isPersistent, String diskStoreName) { AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory(); factory.setBatchSize(batchSize); factory.setPersistent(isPersistent); factory.setDiskStoreName(diskStoreName); factory.setMaximumQueueMemory(maxMemory); factory.setParallel(isParallel); return factory; }
public static String createAsyncEventQueueWithDiskStore(String asyncChannelId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isPersistent, String diskStoreName) { AsyncEventListener asyncEventListener = new MyAsyncEventListener(); File persistentDirectory = null; if (diskStoreName == null) { persistentDirectory = new File( asyncChannelId + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum()); } else { persistentDirectory = new File(diskStoreName); } LogWriterUtils.getLogWriter().info("The ds is : " + persistentDirectory.getName()); persistentDirectory.mkdir(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File[] dirs1 = new File[] {persistentDirectory}; AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory(); factory.setBatchSize(batchSize); factory.setParallel(isParallel); if (isPersistent) { factory.setPersistent(isPersistent); factory.setDiskStoreName(dsf.setDiskDirs(dirs1).create(asyncChannelId).getName()); } factory.setMaximumQueueMemory(maxMemory); // set dispatcher threads factory.setDispatcherThreads(numDispatcherThreadsForTheRun); AsyncEventQueue asyncChannel = factory.create(asyncChannelId, asyncEventListener); return persistentDirectory.getName(); }
public static Cache mockAsyncEventQueueFactory(Cache mockCache) { when(mockCache.createAsyncEventQueueFactory()).thenAnswer(invocation -> mockAsyncEventQueueFactory()); return mockCache; }
@Override protected void doInit() { Assert.state(this.asyncEventListener != null, "AsyncEventListener must not be null"); AsyncEventQueueFactory asyncEventQueueFactory = this.factory != null ? (AsyncEventQueueFactory) this.factory : this.cache.createAsyncEventQueueFactory(); Optional.ofNullable(this.batchConflationEnabled).ifPresent(asyncEventQueueFactory::setBatchConflationEnabled); Optional.ofNullable(this.batchSize).ifPresent(asyncEventQueueFactory::setBatchSize); Optional.ofNullable(this.batchTimeInterval).ifPresent(asyncEventQueueFactory::setBatchTimeInterval); Optional.ofNullable(this.diskStoreReference).ifPresent(asyncEventQueueFactory::setDiskStoreName); Optional.ofNullable(this.diskSynchronous).ifPresent(asyncEventQueueFactory::setDiskSynchronous); Optional.ofNullable(this.dispatcherThreads).ifPresent(asyncEventQueueFactory::setDispatcherThreads); Optional.ofNullable(this.forwardExpirationDestroy).ifPresent(asyncEventQueueFactory::setForwardExpirationDestroy); Optional.ofNullable(this.gatewayEventSubstitutionFilter).ifPresent(asyncEventQueueFactory::setGatewayEventSubstitutionListener); Optional.ofNullable(this.maximumQueueMemory).ifPresent(asyncEventQueueFactory::setMaximumQueueMemory); Optional.ofNullable(this.persistent).ifPresent(asyncEventQueueFactory::setPersistent); asyncEventQueueFactory.setParallel(isParallelEventQueue()); nullSafeList(this.gatewayEventFilters).forEach(asyncEventQueueFactory::addGatewayEventFilter); if (this.orderPolicy != null) { Assert.state(isSerialEventQueue(), "OrderPolicy cannot be used with a Parallel AsyncEventQueue"); asyncEventQueueFactory.setOrderPolicy(this.orderPolicy); } setAsyncEventQueue(asyncEventQueueFactory.create(getName(), this.asyncEventListener)); }
@Override protected void doInit() { Assert.state(this.asyncEventListener != null, "AsyncEventListener must not be null"); AsyncEventQueueFactory asyncEventQueueFactory = this.factory != null ? (AsyncEventQueueFactory) this.factory : this.cache.createAsyncEventQueueFactory(); Optional.ofNullable(this.batchConflationEnabled).ifPresent(asyncEventQueueFactory::setBatchConflationEnabled); Optional.ofNullable(this.batchSize).ifPresent(asyncEventQueueFactory::setBatchSize); Optional.ofNullable(this.batchTimeInterval).ifPresent(asyncEventQueueFactory::setBatchTimeInterval); Optional.ofNullable(this.diskStoreReference).ifPresent(asyncEventQueueFactory::setDiskStoreName); Optional.ofNullable(this.diskSynchronous).ifPresent(asyncEventQueueFactory::setDiskSynchronous); Optional.ofNullable(this.dispatcherThreads).ifPresent(asyncEventQueueFactory::setDispatcherThreads); Optional.ofNullable(this.forwardExpirationDestroy).ifPresent(asyncEventQueueFactory::setForwardExpirationDestroy); Optional.ofNullable(this.gatewayEventSubstitutionFilter).ifPresent(asyncEventQueueFactory::setGatewayEventSubstitutionListener); Optional.ofNullable(this.maximumQueueMemory).ifPresent(asyncEventQueueFactory::setMaximumQueueMemory); Optional.ofNullable(this.persistent).ifPresent(asyncEventQueueFactory::setPersistent); asyncEventQueueFactory.setParallel(isParallelEventQueue()); nullSafeList(this.gatewayEventFilters).forEach(asyncEventQueueFactory::addGatewayEventFilter); if (this.orderPolicy != null) { Assert.state(isSerialEventQueue(), "OrderPolicy cannot be used with a Parallel AsyncEventQueue"); asyncEventQueueFactory.setOrderPolicy(this.orderPolicy); } setAsyncEventQueue(asyncEventQueueFactory.create(getName(), this.asyncEventListener)); }