<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    CLI Batch Mode
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/aloubyansky">Alexey Loubyansky</a> in <i>JBoss AS7 Development</i> - <a href="http://community.jboss.org/docs/DOC-16728">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><h2>Prototype of the batch mode</h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The batch mode allows to group commands and operations and execute them altogether as an atomic unit, i.e. if at least one of the commands or operations failed, all the other successfully executed commands and operations in the batch are rolled back.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Not all of the commands are allowed in the batch. E.g. commands like 'cd', 'ls', 'help', etc are not allowed in the batch since they don't translate into operation requests. Only the commands that translate into operation requests are allowed in the batch. The batch, actually, is executed as 'composite' operation request.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The batch mode is entered by executing command <em>batch</em>.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a> batch</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a></p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The '#' sign in the prompt indicates that the CLI is in the batch mode. Operations and commands like deploy, create-jms-topic, etc won't be executed immediately, instead they will be added to the current batch.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> create-jms-topic name=mytop</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> :add-system-property(name=myprop,value=myval)</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a></p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p> But commands that don't translate into operation requests will be executed immediately. E.g.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> ls</p><p>extension&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; path&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; subsystem&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; deployment&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; management-interfaces</p><p>interface&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; socket-binding-group</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> cd subsystem=web</p><p><a class="jive-link-external-small" href="">localhost:9999 web #</a></p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To see the list of the commands and operations in the current batch execute list-batch</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> list-batch</p><p>#1 deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar</p><p>#2 create-jms-topic name=mytop</p><p>#3 /:add-system-property(name=myprop,value=myval)</p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If you want to edit a line in the batch, use edit-batch-line command by providing the line number as the first argument and the edited command as the second one</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> edit-batch-line 2 create-jms-topic name=mytopic</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> list-batch</p><p>#1 deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar</p><p>#2 create-jms-topic name=mytopic</p><p>#3 /:add-system-property(name=myprop,value=myval)</p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If you want to re-order the lines in the batch you can do this using move-batch-line by specifying the command number you want to move as the first argument and its new position as the second argument</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> move-batch-line 3 1</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> list-batch</p><p>#1 /:add-system-property(name=myprop,value=myval)</p><p>#2 deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar</p><p>#3 create-jms-topic name=mytopic</p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You can remove a line using remove-batch-line and specifying the line number of the command in the batch</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> remove-batch-line 2</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> list-batch</p><p>#1 /:add-system-property(name=myprop,value=myval)</p><p>#2 create-jms-topic name=mytopic</p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You can postpone batch editing if suddenly you want to perform some other tasks by executing holdback-batch</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> holdback-batch</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a></p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To return to the held back batch, just execute batch command</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a> batch</p><p>Re-activated batch</p><p>#1 /:add-system-property(name=myprop,value=myval)</p><p>#2 create-jms-topic name=mytopic</p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Actually, it's possible to hold back more than one batch by adding an argument to holdback-batch</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> holdback-batch mybatch</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a></p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Now, the batch was saved under the name 'mybatch'. To activate it, you now have to execute 'batch mybatch'. Executing just 'batch' will start a new batch.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a> batch</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> holdback-batch</p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Now there are two batches held back. Too see the list of all the held back batches, execute batch with '-l' switch</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a> batch -l</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>mybatch</p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The unnamed batch (there can be only one unnamed batch) is activated by just executing batch command</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a> batch</p><p>Re-activated batch</p><p>#1 deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a></p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You can discard the currently active batch by executing discard-batch</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> discard-batch</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a> batch -l</p><p>mybatch</p><p><a class="jive-link-external-small" href="/quote">/quote</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Note, that after you re-activate your batch it is removed from the held back list and not associated with any name anymore. So, if you want to hold it back again, you will have to give it a new unique name or leave it unnamed.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Finally, run-batch executes the currently active batch after which the batch is automatically discarded.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/quote">http://community.jboss.org/docs/DOC-16728/quote</a></p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a> batch mybatch</p><p>Re-activated batch 'mybatch'</p><p>#1 /:add-system-property(name=myprop,value=myval)</p><p>#2 create-jms-topic name=mytopic</p><p><a class="jive-link-external-small" href="">localhost:9999 / #</a> run-batch</p><p>The batch executed successfully.</p><p><a class="" href="http://community.jboss.org/docs/DOC-16728/localhost:9999 /">http://community.jboss.org/docs/DOC-16728/localhost:9999 /</a> </p><p><a class="jive-link-external-small" href="/quote">/quote</a></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-16728">going to Community</a></p>

        <p style="margin: 0;">Create a new document in JBoss AS7 Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2225">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>