use of org.apache.plc4x.java.spi.transaction.RequestTransactionManager in project plc4x by apache.
the class ModbusRtuProtocolLogic method setConfiguration.
@Override
public void setConfiguration(ModbusRtuConfiguration configuration) {
this.requestTimeout = Duration.ofMillis(configuration.getRequestTimeout());
this.unitIdentifier = (short) configuration.getUnitIdentifier();
this.tm = new RequestTransactionManager(1);
}
use of org.apache.plc4x.java.spi.transaction.RequestTransactionManager in project plc4x by apache.
the class AbEthProtocolLogic method setConfiguration.
@Override
public void setConfiguration(AbEthConfiguration configuration) {
this.configuration = configuration;
// Set the transaction manager to allow only one message at a time.
this.tm = new RequestTransactionManager(1);
}
use of org.apache.plc4x.java.spi.transaction.RequestTransactionManager in project plc4x by apache.
the class CANOpenProtocolLogic method setDriverContext.
@Override
public void setDriverContext(DriverContext driverContext) {
super.setDriverContext(driverContext);
this.canContext = (CANOpenDriverContext) driverContext;
// Initialize Transaction Manager.
// Until the number of concurrent requests is successfully negotiated we set it to a
// maximum of only one request being able to be sent at a time. During the login process
// No concurrent requests can be sent anyway. It will be updated when receiving the
// S7ParameterSetupCommunication response.
this.tm = new RequestTransactionManager(1);
}
use of org.apache.plc4x.java.spi.transaction.RequestTransactionManager in project plc4x by apache.
the class GenericCANProtocolLogic method setDriverContext.
@Override
public void setDriverContext(DriverContext driverContext) {
super.setDriverContext(driverContext);
this.tm = new RequestTransactionManager(1);
}
use of org.apache.plc4x.java.spi.transaction.RequestTransactionManager in project plc4x by apache.
the class RequestTransactionManagerTest method exampleWithMultipleRequests.
@Test
public void exampleWithMultipleRequests() throws ExecutionException, InterruptedException {
CompletableFuture<Void> sendRequest1 = new CompletableFuture<>();
CompletableFuture<Void> endRequest1 = new CompletableFuture<>();
CompletableFuture<Void> requestIsEnded1 = new CompletableFuture<>();
CompletableFuture<Void> sendRequest2 = new CompletableFuture<>();
CompletableFuture<Void> endRequest2 = new CompletableFuture<>();
CompletableFuture<Void> requestIsEnded2 = new CompletableFuture<>();
RequestTransactionManager tm = new RequestTransactionManager();
// Assert there is no request going on
assertEquals(0, tm.getNumberOfActiveRequests());
// Send Request 1
sendRequest(tm, sendRequest1, endRequest1, requestIsEnded1);
// Send Request 2
sendRequest(tm, sendRequest2, endRequest2, requestIsEnded2);
// Assert that there is a request going on
sendRequest1.get();
assertEquals(1, tm.getNumberOfActiveRequests());
// Finish the Request with a response
endRequest1.complete(null);
// Wait till async operation (and transaction end) completed
requestIsEnded1.get();
// Request 2 should now be processed and finish
sendRequest2.get();
endRequest2.complete(null);
requestIsEnded2.get();
assertEquals(0, tm.getNumberOfActiveRequests());
}
Aggregations