Skip to content

Commit

Permalink
ISOServer/ChannelAdaptor default to Platform Threads.
Browse files Browse the repository at this point in the history
During 'jinstress' test we found that for persistent connections, the
ChannelAdaptor and ISOServer performs better using platform threads.
There are situations, such as a massive number of low-traffic POS
devices that could be better served using VirtualThreads, so there's
still the ability to set 'virtual-threads' to 'true' in the components'
configuration.
  • Loading branch information
ar committed Jan 2, 2025
1 parent 0da87e6 commit 53b10f2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 2 additions & 1 deletion jpos/src/main/java/org/jpos/iso/ISOServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.jpos.jfr.ChannelEvent;
import org.jpos.log.AuditLogEvent;
import org.jpos.log.evt.*;
import org.jpos.q2.QFactory;
import org.jpos.util.*;

/**
Expand Down Expand Up @@ -117,7 +118,6 @@ public ISOServer(int port, ServerChannel clientSide, int maxSessions) {
channels = Collections.synchronizedMap(new HashMap<>());
serverListeners = Collections.synchronizedList(new ArrayList<>());

executor = Executors.newVirtualThreadPerTaskExecutor();
if (maxSessions > 0)
permitsCount = maxSessions;
permits = new Semaphore(permitsCount);
Expand All @@ -143,6 +143,7 @@ public void setConfiguration (Configuration cfg) throws ConfigurationException {
if (socketFactory != this && socketFactory instanceof Configurable) {
((Configurable)socketFactory).setConfiguration (cfg);
}
executor = QFactory.executorService(cfg.getBoolean("virtual-threads", false));
}

// Helper method to setConfiguration. Handles "allow" and "deny" params
Expand Down
2 changes: 1 addition & 1 deletion jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public ChannelAdaptor () {
public void initService() throws ConfigurationException {
initSpaceAndQueues();
NameRegistrar.register (getName(), this);
executor = Executors.newVirtualThreadPerTaskExecutor();
executor = QFactory.executorService(cfg.getBoolean("virtual-threads", false));
}
public void startService () {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ public void initService () throws ConfigurationException {
groups = new HashMap<>();
initParticipants (getPersist());
initStatusListeners (getPersist());
executor = Executors.newThreadPerTaskExecutor(
Thread.ofVirtual()
.inheritInheritableThreadLocals(false)
.name(getName())
.factory());
executor = QFactory.executorService(cfg.getBoolean("virtual-threads", true));

if (!filtersAdded.getAndSet(true)) {
getServer().getMeterRegistry().config().meterFilter(new MeterFilter() {
Expand Down Expand Up @@ -239,8 +235,8 @@ public void run () {
});
}
else {
ISOUtil.sleep(100L);
iisp.push(queue, context); // push it back
ISOUtil.sleep(100L);
}
}
}
Expand Down

0 comments on commit 53b10f2

Please sign in to comment.