use of org.kie.server.client.jms.FireAndForgetResponseHandler in project droolsjbpm-integration by kiegroup.
the class DroolsJmsResponseHandlerIntegrationTest method testExecuteSimpleRuleFlowProcessWithFireAndForgetResponseHandler.
@Test
public void testExecuteSimpleRuleFlowProcessWithFireAndForgetResponseHandler() throws Exception {
// First command in this test needs to be executed with RequestReplyResponseHandler.
// If there would be used FireAndForgetResponseHandler then following request could reach Kie server in same time
// causing stateful kie session for this container to be created concurrently.
// Concurrent creation of same stateful kie session leads to overriding one kie session with another,
// causing inconsistency and data loss.
Command<?> initializeList = commandsFactory.newSetGlobal(LIST_NAME, new ArrayList<String>(), LIST_OUTPUT_NAME);
ServiceResponse<ExecutionResults> response = ruleClient.executeCommandsWithResults(CONTAINER_ID, initializeList);
KieServerAssert.assertSuccess(response);
try {
ruleClient.setResponseHandler(new FireAndForgetResponseHandler());
Command<?> startProcess = commandsFactory.newStartProcess(PROCESS_ID);
response = ruleClient.executeCommandsWithResults(CONTAINER_ID, startProcess);
assertThat(response).isNull();
} finally {
ruleClient.setResponseHandler(new RequestReplyResponseHandler());
}
Command<?> getGlobalCommand = commandsFactory.newGetGlobal(LIST_NAME, LIST_OUTPUT_NAME);
List<String> value = new ArrayList<String>();
value.add("Rule from first ruleflow group executed");
value.add("Rule from second ruleflow group executed");
KieServerSynchronization.waitForCommandResult(ruleClient, CONTAINER_ID, getGlobalCommand, LIST_OUTPUT_NAME, value);
}
use of org.kie.server.client.jms.FireAndForgetResponseHandler in project droolsjbpm-integration by kiegroup.
the class OptaPlannerJmsResponseHandlerIntegrationTest method testSolverWithFireAndForgetResponseHandler.
@Test
public void testSolverWithFireAndForgetResponseHandler() throws Exception {
solverClient.setResponseHandler(new FireAndForgetResponseHandler());
SolverInstance solverInstance = solverClient.createSolver(CONTAINER_1_ID, SOLVER_1_ID, SOLVER_1_CONFIG);
assertThat(solverInstance).isNull();
solverClient.setResponseHandler(new RequestReplyResponseHandler());
KieServerSynchronization.waitForSolver(solverClient, CONTAINER_1_ID, SOLVER_1_ID);
solverClient.setResponseHandler(new FireAndForgetResponseHandler());
solverClient.solvePlanningProblem(CONTAINER_1_ID, SOLVER_1_ID, loadPlanningProblem(5, 15));
solverClient.setResponseHandler(new RequestReplyResponseHandler());
KieServerSynchronization.waitForSolverStatus(solverClient, CONTAINER_1_ID, SOLVER_1_ID, SolverInstance.SolverStatus.SOLVING);
solverClient.setResponseHandler(new FireAndForgetResponseHandler());
solverClient.terminateSolverEarly(CONTAINER_1_ID, SOLVER_1_ID);
solverClient.setResponseHandler(new RequestReplyResponseHandler());
KieServerSynchronization.waitForSolverStatus(solverClient, CONTAINER_1_ID, SOLVER_1_ID, SolverInstance.SolverStatus.NOT_SOLVING);
solverClient.setResponseHandler(new FireAndForgetResponseHandler());
solverClient.disposeSolver(CONTAINER_1_ID, SOLVER_1_ID);
solverClient.setResponseHandler(new RequestReplyResponseHandler());
KieServerSynchronization.waitForSolverDispose(solverClient, CONTAINER_1_ID, SOLVER_1_ID);
List<SolverInstance> solverInstanceList = solverClient.getSolvers(CONTAINER_1_ID);
assertThat(solverInstanceList).isNullOrEmpty();
}
use of org.kie.server.client.jms.FireAndForgetResponseHandler in project droolsjbpm-integration by kiegroup.
the class ContainerJmsResponseHandlerIntegrationTest method setupClients.
@Before
public void setupClients() throws Exception {
asyncClient = createDefaultClient();
Marshaller marshaller = MarshallerFactory.getMarshaller(new HashSet<Class<?>>(extraClasses.values()), configuration.getMarshallingFormat(), asyncClient.getClassLoader());
responseCallback = new BlockingResponseCallback(marshaller);
asyncClient.setResponseHandler(new AsyncResponseHandler(responseCallback));
fireAndForgetClient = createDefaultClient();
fireAndForgetClient.setResponseHandler(new FireAndForgetResponseHandler());
}
Aggregations