JBoss Community

CLI Batch Mode

created by Alexey Loubyansky in JBoss AS7 Development - View the full document

Prototype of the batch mode

 

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.

 

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.

 

The batch mode is entered by executing command batch.

 

http://community.jboss.org/docs/DOC-16728/quote

http://community.jboss.org/docs/DOC-16728/localhost:9999 / batch

localhost:9999 / #

/quote

 

 

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.

 

http://community.jboss.org/docs/DOC-16728/quote

localhost:9999 / # deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar

localhost:9999 / # create-jms-topic name=mytop

localhost:9999 / # :add-system-property(name=myprop,value=myval)

localhost:9999 / #

/quote

 

 

But commands that don't translate into operation requests will be executed immediately. E.g.

 

http://community.jboss.org/docs/DOC-16728/quote

localhost:9999 / # ls

extension               path                    subsystem               deployment              management-interfaces

interface               socket-binding-group

localhost:9999 / # cd subsystem=web

localhost:9999 web #

/quote

 

 

To see the list of the commands and operations in the current batch execute list-batch

 

http://community.jboss.org/docs/DOC-16728/quote

localhost:9999 / # list-batch

#1 deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar

#2 create-jms-topic name=mytop

#3 /:add-system-property(name=myprop,value=myval)

/quote

 

 

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

 

http://community.jboss.org/docs/DOC-16728/quote

localhost:9999 / # edit-batch-line 2 create-jms-topic name=mytopic

localhost:9999 / # list-batch

#1 deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar

#2 create-jms-topic name=mytopic

#3 /:add-system-property(name=myprop,value=myval)

/quote

 

 

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

 

http://community.jboss.org/docs/DOC-16728/quote

localhost:9999 / # move-batch-line 3 1

localhost:9999 / # list-batch

#1 /:add-system-property(name=myprop,value=myval)

#2 deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar

#3 create-jms-topic name=mytopic

/quote

 

 

You can remove a line using remove-batch-line and specifying the line number of the command in the batch

 

http://community.jboss.org/docs/DOC-16728/quote

localhost:9999 / # remove-batch-line 2

localhost:9999 / # list-batch

#1 /:add-system-property(name=myprop,value=myval)

#2 create-jms-topic name=mytopic

/quote

 

 

You can postpone batch editing if suddenly you want to perform some other tasks by executing holdback-batch

 

http://community.jboss.org/docs/DOC-16728/quote

localhost:9999 / # holdback-batch

http://community.jboss.org/docs/DOC-16728/localhost:9999 /

/quote

 

 

To return to the held back batch, just execute batch command

 

http://community.jboss.org/docs/DOC-16728/quote

http://community.jboss.org/docs/DOC-16728/localhost:9999 / batch

Re-activated batch

#1 /:add-system-property(name=myprop,value=myval)

#2 create-jms-topic name=mytopic

/quote

 

 

Actually, it's possible to hold back more than one batch by adding an argument to holdback-batch

 

http://community.jboss.org/docs/DOC-16728/quote

localhost:9999 / # holdback-batch mybatch

http://community.jboss.org/docs/DOC-16728/localhost:9999 /

/quote

 

 

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.

 

http://community.jboss.org/docs/DOC-16728/quote

http://community.jboss.org/docs/DOC-16728/localhost:9999 / batch

localhost:9999 / # deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar

localhost:9999 / # holdback-batch

/quote

 

 

Now there are two batches held back. Too see the list of all the held back batches, execute batch with '-l' switch

 

http://community.jboss.org/docs/DOC-16728/quote

http://community.jboss.org/docs/DOC-16728/localhost:9999 / batch -l

 

mybatch

/quote

 

 

The unnamed batch (there can be only one unnamed batch) is activated by just executing batch command

 

http://community.jboss.org/docs/DOC-16728/quote

http://community.jboss.org/docs/DOC-16728/localhost:9999 / batch

Re-activated batch

#1 deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar

localhost:9999 / #

/quote

 

 

You can discard the currently active batch by executing discard-batch

 

http://community.jboss.org/docs/DOC-16728/quote

localhost:9999 / # discard-batch

http://community.jboss.org/docs/DOC-16728/localhost:9999 / batch -l

mybatch

/quote

 

 

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.

 

Finally, run-batch executes the currently active batch after which the batch is automatically discarded.

 

http://community.jboss.org/docs/DOC-16728/quote

http://community.jboss.org/docs/DOC-16728/localhost:9999 / batch mybatch

Re-activated batch 'mybatch'

#1 /:add-system-property(name=myprop,value=myval)

#2 create-jms-topic name=mytopic

localhost:9999 / # run-batch

The batch executed successfully.

http://community.jboss.org/docs/DOC-16728/localhost:9999 /

/quote

Comment by going to Community

Create a new document in JBoss AS7 Development at Community