torek, 09. oktober 2012

OpenMQ: Create queues from Java program

When you execute imqcmd command from OpenMQ you have to provide username and password, which is a bit of a PITA if you are calling the imqcmd from Java programs.
This is the recipe you can use to get around this problem:

  1. Create a file calles imqCmd.password with following content:
    imq.imqcmd.password=ADMIN_OPENMQ_PASSWORD
  2. If you are on Linux it is a good idea to make the file readable only to your user:
    chmod 600 imqCmd.password
  3. Run the commands for queue creation:
    $com.sun.aas.imqBin/imqcmd create dst -n MyQueue -t q -o "maxNumMsgs=1000" -o "limitBehavior=FLOW_CONTROL" -o "maxNumMsgs=-1" -o "localDeliveryPreferred=false" -o "useDMQ=true" -o "validateXMLSchemaEnabled=false" -u admin -passfile PATH_TO_PASSWORD_FILE
  4. You can also delete the queue:
    $com.sun.aas.imqBin/imqcmd destroy dst -n MyQueue -t q -f -u admin -passfile PATH_TO_PASSWORD_FILE
com.sun.aas.imqBin is a System property that tells you where you can find imqcmd and other OpenMQ executables. It is only set on a Glassfish process.
Objavite komentar