1

I've been finding ways to load configuration to wildfly in bulk (say I have a json data).

Something that kind of look like this.

./jboss-cli.sh -c subsystem=messagingactivemq/server=default:add(<data.json>)

Where <data.json>

{
    "outcome" => "success",
    "result" => {
        "address-full-policy" => "BLOCK",
        "dead-letter-address" => "jms.queue.DLQ",
        "expiry-address" => "jms.queue.ExpiryQueue",
        "last-value-queue" => false,
        "max-delivery-attempts" => 10,
        "max-size-bytes" => 12333,
        "message-counter-history-day-limit" => 10,
        "page-max-cache-size" => 5,
        "page-size-bytes" => 12333,
        "redelivery-delay" => 0,
        "redistribution-delay" => 222L,
        "send-to-dla-on-no-route" => false
    }
}

I want to load the above json directly to wildlfy via jboss-cli. Is this even possible? i have been looking for references about this for the past weeks. Any inputs are welcome.

EDITED Just to be clear with my goals, I am trying ti migrate manually configured items on jBoss AS7.1 into Wildfly 10.1. Currently migration scripts only supports EAP versions of jBoss. So I have to manually select configurations fron jBoss to be migrated to wildfly. Yes, there are configuration that are deprecated and/or deleted in wildfly, so between jBoss AS7.1 and Wildfly10.1 I have to make some changes to the configuration before I load it to wildfly hence I mentioned the json data.

Since when I try to outputresource in jBoss AS7.1 via jboss-cli.sh using command /subsystem=messaging/hornetq-server=default:read-resource it will output something like

{
    "outcome" => "success",
    "result" => {
        "acceptor" => undefined,
        "allow-failback" => true,
        "async-connection-execution-enabled" => true,
        "backup" => false,
        "bridge" => undefined,
        "broadcast-group" => undefined,
        "cluster-connection" => undefined,
    ... some resource ....

So I will make some modification on the above data (since wildfly uses activemq) and load it to wildfly as activemq. But it just want to use the json data and load it directly to wildfly's jboss-cli.sh. I want to automate this and just execute a script (shell) to do the migration.

Cœur
  • 37,241
  • 25
  • 195
  • 267
lemoncodes
  • 2,371
  • 11
  • 40
  • 66

1 Answers1

1

Not entirely sure, what exactly are you trying to achieve here, but if you want to execute bulk operations from file, you can use jboss-cli.sh --file=commands.cli where commands.cli is a text file containing jboss cli commands.

This way you can perform multiple operations at once, plus you can utilize the batch functionality provided by JBoss CLI to make sure all changes are applied or reverted.

Example file with multiple commands:

#Add xa datasource
xa-data-source add  \
    --name=my.app.ds \
    --jndi-name=java:jboss/datasources/my.app.ds \
    --driver-name=h2 \
    --user-name=username \
    --password=password \
    --use-java-context=true \
    --enabled=true \        
    --xa-datasource-properties={"URL"=>"jdbc:h2:tcp://${env.DB_HOST:localhost}:${env.DB_PORT:1521}/~/my.app.ds;MVCC=TRUE"}

#Add JMS queue
jms-queue add --queue-address=foo.bar.myapp.queue --entries=java:/jms/queue/foo.bar.myapp.queue 

#Add system property
/system-property=ENABLE_MY_COOL_MESSAGING_FEATURE:add(value="true")

If you want to define modules or execute operations based on JSON file or any other format apart from the CLI command format, I am afraid you are out of luck. You can make you own java library that wraps the JBoss CLI to execute it though - as JBoss/Wildfly provides CLI bindings for Java and Python I believe.

yntelectual
  • 3,028
  • 18
  • 24
  • got your point, please read edit post above. i initially did this but its so tedious since the plan is to automate migration. As you've mentioned i will try CLI bindings. thanks – lemoncodes Mar 28 '18 at 02:38
  • if you want migration, you can give the [official migration tool](https://github.com/wildfly/wildfly-server-migration) a try. JBoss AS7 should have compatible configuration with EAP 6.4 and Wildfly 10.1 should be compatible with EAP 7.2(As wildfly is upstream for EAP). So you could use the migration template eap6.4-eap7.2 – yntelectual Mar 28 '18 at 08:58
  • does this nid to have an actual installer/server for EAP 6.4? i assume this needs one. limitation is i don't have any copy of non-community jboss applications – lemoncodes Mar 28 '18 at 10:01
  • yes, but you can easily download EAP distributions - you just need a RedHat developer account(free) – yntelectual Mar 31 '18 at 07:24