use of org.apache.plc4x.java.spi.transaction.RequestTransactionManager in project plc4x by apache.
the class EipProtocolLogic method setConfiguration.
@Override
public void setConfiguration(EIPConfiguration 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 KnxNetIpProtocolLogic method setDriverContext.
@Override
public void setDriverContext(DriverContext driverContext) {
super.setDriverContext(driverContext);
this.knxNetIpDriverContext = (KnxNetIpDriverContext) 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 S7ProtocolLogic method setDriverContext.
@Override
public void setDriverContext(DriverContext driverContext) {
super.setDriverContext(driverContext);
this.s7DriverContext = (S7DriverContext) 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);
EventLogic.start();
}
use of org.apache.plc4x.java.spi.transaction.RequestTransactionManager in project plc4x by apache.
the class CBusProtocolLogic method setDriverContext.
@Override
public void setDriverContext(DriverContext driverContext) {
super.setDriverContext(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 RequestTransactionManagerTest method abortTransactionFromExternally.
@Test
@Disabled("This test is randomly failing on Jenkins")
public void abortTransactionFromExternally() throws ExecutionException, InterruptedException {
CompletableFuture<Void> sendRequest = new CompletableFuture<>();
CompletableFuture<Void> receiveResponse = new CompletableFuture<>();
CompletableFuture<Void> transactionIsFinished = new CompletableFuture<>();
RequestTransactionManager tm = new RequestTransactionManager();
RequestTransactionManager.RequestTransaction handle = tm.startRequest();
handle.submit(() -> {
// ...
sendRequest.complete(null);
// Receive
receiveResponse.thenAccept((n) -> {
handle.endRequest();
transactionIsFinished.complete(null);
});
});
// Assert that there is a request going on
sendRequest.get();
// Exception case
handle.failRequest(new RuntimeException());
// Wait that the fail is handled internally surely
Thread.sleep(100);
// Assert that no requests are active
assertEquals(0, tm.getNumberOfActiveRequests());
// Assert that its cancelled
assertTrue(handle.getCompletionFuture().isCancelled());
}
Aggregations