Thursday 6 August 2009

How to set arbitrary broker properties when using Glassfish

Several people have read my previous article Consumer flow control and Message-Driven Beans and asked for more information on how to set the various configuration properties mentioned.

There are several types of configuration property used by Open Message Queue:
  • Broker properties

  • Physical destination properties

  • Connection factory properties

  • Resource adapter properties
Let's consider the first of these, broker properties. There's a full list of broker properties in the MQ Administration Guide here. As the name suggests, these are configured on the broker rather than on the client. An example of a broker property is imq.autocreate.queue.consumerFlowLimit. How is this configured?

If you're using Glassfish, and are using Glassfish to manage the lifecycle of your broker (i.e. you're using an EMBEDDED or LOCAL broker), then you can configure arbitrary broker properties using the Glassfish administration console. In the tree-view on the left, navigate to Configuration -> Java Message Service. In the right-hand pane, enter your property in the "Start Arguments" field as if it were a JVM argument. For example, -Dimq.autocreate.queue.consumerFlowLimit=50. You can repeat this whole syntax, separated by a space, to set multiple properties.

Here's an example (click on the image for a larger version):


When you've finished, click "save" and restart your Glassfish server. That's it!

If GUIs aren't your thing and you're a command-line sort of person you can use asadmin instead:

asadmin set --port 4848 server.jms-service.start-args=-Dimq.autocreate.queue.consumerFlowLimit=50

Or you can edit your broker's configuration file. This is documented in the Open Message Queue Administration Guide here.