@Before public void setUp() { when(lockFactory.createLock(anyString())).thenReturn(mockLock); when(objectStoreManager.getOrCreateObjectStore(anyString(), any())) .thenReturn(objectStore); cacheManager.start(); }
@Override public void onStart(SourceCallback<T, A> sourceCallback) throws MuleException { delegate.onStart(sourceCallback); flowName = componentLocation.getRootContainerName(); keyPrefix = "_pollingSource_" + flowName + "/"; inflightIdsObjectStore = objectStoreManager.getOrCreateObjectStore(formatKey("inflight-ids"), ObjectStoreSettings.builder() .persistent(false) .maxEntries(1000) .entryTtl(60000L) .expirationInterval(20000L) .build()); recentlyProcessedIds = objectStoreManager.getOrCreateObjectStore(formatKey("recently-processed-ids"), unmanagedPersistent()); idsOnUpdatedWatermark = objectStoreManager.getOrCreateObjectStore(formatKey("ids-on-updated-watermark"), unmanagedPersistent()); watermarkObjectStore = objectStoreManager.getOrCreateObjectStore(formatKey("watermark"), unmanagedPersistent()); executor = schedulerService.customScheduler(SchedulerConfig.config() .withMaxConcurrentTasks(1) .withWaitAllowed(true) .withName(formatKey("executor"))); stopRequested.set(false); scheduler.schedule(executor, () -> poll(sourceCallback)); }
@Override public CoreEvent process(CoreEvent event) throws MuleException { ObjectStore<String> myPartition = objectStoreManager.getOrCreateObjectStore("myPartition", ObjectStoreSettings.builder().persistent(true).build()); String key = "value"; if (myPartition.contains(key)) { myPartition.remove(key); } myPartition.store(key, key); return event; } }
@Override public void onStart(SourceCallback<T, A> sourceCallback) throws MuleException { delegate.onStart(sourceCallback); flowName = componentLocation.getRootContainerName(); keyPrefix = "_pollingSource_" + flowName + "/"; inflightIdsObjectStore = objectStoreManager.getOrCreateObjectStore(formatKey("inflight-ids"), ObjectStoreSettings.builder() .persistent(false) .maxEntries(1000) .entryTtl(60000L) .expirationInterval(20000L) .build()); recentlyProcessedIds = objectStoreManager.getOrCreateObjectStore(formatKey("recently-processed-ids"), ObjectStoreSettings.builder() .persistent(true) .maxEntries(1000) .entryTtl(60000L) .expirationInterval(20000L) .build()); watermarkObjectStore = objectStoreManager.getOrCreateObjectStore(formatKey("watermark"), unmanagedPersistent()); executor = schedulerService.customScheduler(SchedulerConfig.config() .withMaxConcurrentTasks(1) .withWaitAllowed(true) .withName(formatKey("executor"))); stopRequested.set(false); scheduler.schedule(executor, () -> poll(sourceCallback)); }