June 2008
Monthly Archive
Monthly Archive
The JMS spec does not provide a way to easily obtain the number of messages on a certain queue. You could create a browser and browse through the entire queue and keep count, but this is very slow.
The java client for MQSeries (or WebsphereMQ as it is called nowadays) does provide this functionality, so if you don’t mind using IBM specific classes, you could do it like this:
public int getDepth(String queueName) throws MQException { // Build quemanager (this should be done in another method) // and not every time in a real life application MQEnvironment.channel = "CHANNELNAME"; MQEnvironment.port = 1414; MQEnvironment.hostname = "qmgrhost.yourdomain.com"; MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES); MQQueueManager qmgr = new MQQueueManager("YourQueueManagerName"); // access the queue to query its depth com.ibm.mq.MQQueue queue = qmgr.accessQueue(queueName, MQC.MQOO_INQUIRE | MQC.MQOO_INPUT_AS_Q_DEF, null, null, null); return queue.getCurrentDepth(); }
The com.ibm.mq.MQQueue class exposes some other interesting methods to get more information about a queue, like the maximum depth and the maximum message length.
0 comments Wednesday 11 Jun 2008 | Guy Mahieu | java(t) , mqseries(t) , tips&tricks(t)
The svn command has an info parameter with which you can obtain some info about the current directory, like this:
C:\Projects\myproject\branches\DEV_V0001.00>svn info --revision HEAD Path: DEV_V0001.00 URL: http://svn.mycompany:10080/svn/myproject/branches/DEV_V0001.00 Repository Root: http://svn.mycompany:10080/svn/myproject Repository UUID: 495b61df-840d-0410-9b36-f3cf8ec0f97e Revision: 8251 Node Kind: directory Last Changed Author: mahieuguy Last Changed Rev: 8211 Last Changed Date: 2008-06-05 13:05:22 +0200 (do, 05 jun 2008)
I could not find a command that would just return the revision number, which we needed in our build script. On linux systems it would be trivial to extract just the rev number from the output of the ‘info’ command, so I hoped it would also be possible in dos/windows without installing extra tools. It turned out to be possible, but much less elegant than I suspected:
@echo off
FOR /F "tokens=2 skip=4" %%G IN ('svn info --revision HEAD') DO ^
IF NOT DEFINED REVISION SET REVISION=%%G
echo %REVISION%
Note that the ^ character is just there to split the command into two lines, this works for XP batch scripts, but I’m not sure about other versions of cmd.exe
The HEAD revision number is put in the %REVISION% parameter. Make sure you don’t already have a REVISION parameter defined before executing the command in the batch file though, because it will only be set if it is not already defined. This was needed to be able to get the FOR command to ignore all lines after the ‘Revision: 8251′ line from the ’svn info’ result.
2 comments Monday 09 Jun 2008 | Guy Mahieu | batch(t) , svn(t) , windows(t)