Skip to content

Commit

Permalink
new_init_method
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakarora3 committed Jul 20, 2023
1 parent 9120715 commit 0b9b42a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<groupId>com.americanexpress.unify.flowret</groupId>
<artifactId>unify-flowret</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
<packaging>jar</packaging>

<name>unify-flowret</name>
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Flowret is available as a jar file in Maven central with the following Maven coo
````pom
<groupId>com.americanexpress.unify.flowret</groupId>
<artifactId>unify-flowret</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
````

---
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/com/americanexpress/unify/flowret/Flowret.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import com.americanexpress.unify.flowret.CONSTS_FLOWRET.DAO;
import com.americanexpress.unify.jdocs.JDocument;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;

/*
* @author Deepak Arora
Expand Down Expand Up @@ -86,11 +83,22 @@ public static void init(int maxThreads, int idleTimeout, String typeIdSep) {
}

public static void init(int maxThreads, int idleTimeout, String typeIdSep, String errorWorkbasket) {
init(maxThreads, idleTimeout, typeIdSep, errorWorkbasket, null);
}

public static void init(int maxThreads, int idleTimeout, String typeIdSep, String errorWorkbasket, ThreadFactory threadFactory) {
Flowret am = instance();
am.maxThreads = maxThreads;
am.idleTimeout = idleTimeout;
BlockOnOfferQueue<Runnable> q = new BlockOnOfferQueue(new ArrayBlockingQueue<>(am.maxThreads * 2));
am.es = new ThreadPoolExecutor(am.maxThreads, am.maxThreads, am.idleTimeout, TimeUnit.MILLISECONDS, q, new RejectedItemHandler());

if (threadFactory == null) {
am.es = new ThreadPoolExecutor(am.maxThreads, am.maxThreads, am.idleTimeout, TimeUnit.MILLISECONDS, q, new RejectedItemHandler());
}
else {
am.es = new ThreadPoolExecutor(am.maxThreads, am.maxThreads, am.idleTimeout, TimeUnit.MILLISECONDS, q, threadFactory, new RejectedItemHandler());
}

DAO.SEP = typeIdSep;
am.errorWorkbasket = errorWorkbasket;
ERRORS_FLOWRET.load();
Expand Down

0 comments on commit 0b9b42a

Please sign in to comment.