Created attachment 881389 [details] batch mode example Description of problem: When running eap cli batch scripts, it is expected that conditional statements would work as they work in cli mode, but I get an error saying it doesn't support if statements. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. ./JBOSS_HOME/bin/standalone.sh -c standalone.xml 2. ./JBOSS_HOME/jboss-cli.sh --connect controller=$HOSTNAME:9999 --file=/DIR-TO-BATCH/if-else-test Actual results: if is not allowed while in batch mode. Expected results: #1 /subsystem=web/connector=ajp:add(protocol=AJP/1.3,scheme=http,socket-binding=ajp) 11:25:32,752 INFO [org.apache.coyote.ajp] (MSC service thread 1-3) JBWEB003046: Starting Coyote AJP/1.3 on ajp-/127.0.0.1:8009 The batch executed successfully Additional info: If the resource exists I expect the if statement to gracefully handle the successful exit of batch mode.
Unless someone has some great ideas around this, I recommend that this be converted into a docs / help issue to document the supported behavior of a batch (which does not include client-side conditional logic.) Supporting client-side conditional logic would require client-side control of transaction boundaries, which should be a WildFly RFE.
This restriction was intentional. The problem is the batch is translated into a single composite operation request which has no notion of conditional flow of control. So, the CLI resolves these conditions when it creates the composite request before sending it to the controller. The problem is that the CLI cannot take into account the effects of the commands and operations on the domain model preceding the if-else statements that may affect the how these if-else statements are resolved. For this reason, the CLI (as it is implemented now) can't take the responsibility for the accuracy of resolving if-else conditions in the batch mode during the batch execution. This may lead to unexpected results for the users. So, at this point, either we allow if-else in batches at user's own risk or we keep this restriction and document it.
According to previous comments closing this as notabug. Created BZ1120184 for documentation.