setGlobals(inputMessage, operation, session);
if (ExchangePattern.IN_ONLY.equals(exchangePattern)) {
List<Object> facts = getInputList(inputMessage, operation, session);
session.getStateless().execute(facts);
} else if (ExchangePattern.IN_OUT.equals(exchangePattern)) {
KieCommands cmds = KieServices.Factory.get().getCommands();
List<Command<?>> batch = new ArrayList<Command<?>>();
Map<String, Object> inouts = getInputOutputMap(inputMessage, operation, session);
for (Entry<String, Object> inout : inouts.entrySet()) {
batch.add(cmds.newInsert(inout.getValue(), inout.getKey()));
}
List<Object> facts = getInputOnlyList(inputMessage, operation, session);
batch.add(cmds.newInsertElements(facts));
batch.add(cmds.newFireAllRules());
BatchExecutionCommand exec = cmds.newBatchExecution(batch, KnowledgeConstants.RESULT);
ExecutionResults results = session.getStateless().execute(exec);
for (String id : inouts.keySet()) {
expressionVariables.put(id, results.getValue(id));
}
expressionVariables.putAll(getGlobalVariables(session));