With the 7.0.1 release of AS7 comes a new release of the JBoss AS7 Maven Plugin. In addition to allowing you to deploy your apps to AS7, the plugin now has the ability to automatically add datasources to a running AS7 instance.

Deploying a datasource is a two stage process, first we have to deploy the driver, then we setup a datasource through the AS7 management api. The example below walks you through the process of deploying a postgresql datasource, but for the impatient among you a complete example can be found here.

You may have noticed about that the name of the maven goal is add-resource, rather than add-datasource. This is because the plugin is not limited to just adding datasources, but can also be used to add other resources to AS7. Internally the plugin uses the AS7 management API, and the <address> and <properties> elements correspond exactly to the management API / command line equivalents. This means that we can add other resources as well, e.g. JMS Queues.

The first thing we need to do is figure out the syntax we need to use to add a JMS Queue. To do this we are going to use the command line client. Fire up an instance of AS7, and then in another terminal window run jboss-admin.sh in the bin directory. You should see the following:

You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /]

Type connect and you should connect to the running AS7 instance. Now we need to figure out the syntax to add a JMS Queue. To do this we run the following command:

This output means that the operation has three parameters, entries, selector and durable, Of type List, String, and Boolean respectively. Using this information we can add queue on the command line as follows:

The most interesting part of the above configuration is the <entries> element. Because the parameter is of a non-primitive type (in this case LIST), it must be specified as a DMR String. The !! escape as the start of the test tells the plugin to interpret it as such.