Skip to content

Commit ed3abea

Browse files
author
Daniel Rentsch
committed
make number of web-socket-workers / decoders configurable
1 parent 52c9e8a commit ed3abea

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

OCPP-J/src/main/java/eu/chargetime/ocpp/JSONConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class JSONConfiguration {
3737
public static final String USERNAME_PARAMETER = "USERNAME";
3838
public static final String PASSWORD_PARAMETER = "PASSWORD";
3939
public static final String CONNECT_TIMEOUT_IN_MS_PARAMETER = "CONNECT_TIMEOUT_IN_MS";
40+
public static final String WEBSOCKET_WORKER_COUNT = "WEBSOCKET_WORKER_COUNT";
4041

4142
private final HashMap<String, Object> parameters = new HashMap<>();
4243

OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ of this software and associated documentation files (the "Software"), to deal
4848
public class WebSocketListener implements Listener {
4949
private static final Logger logger = LoggerFactory.getLogger(WebSocketListener.class);
5050

51+
private static final int DEFAULT_WEBSOCKET_WORKER_COUNT = 4;
5152
private static final int TIMEOUT_IN_MILLIS = 10000;
5253

5354
private static final int OCPPJ_CP_MIN_PASSWORD_LENGTH = 16;
@@ -78,7 +79,10 @@ public WebSocketListener(ISessionFactory sessionFactory, Draft... drafts) {
7879
@Override
7980
public void open(String hostname, int port, ListenerEvents handler) {
8081
server =
81-
new WebSocketServer(new InetSocketAddress(hostname, port), drafts) {
82+
new WebSocketServer(
83+
new InetSocketAddress(hostname, port),
84+
configuration.getParameter(JSONConfiguration.WEBSOCKET_WORKER_COUNT, DEFAULT_WEBSOCKET_WORKER_COUNT),
85+
drafts) {
8286
@Override
8387
public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) {
8488
logger.debug(

0 commit comments

Comments
 (0)