import com.ibm.mq.MQC; import com.ibm.mq.MQEnvironment; import com.ibm.mq.MQQueue; import com.ibm.mq.MQQueueManager; public class QueueDepthTest extends ServerConfig { /**o * @param args */ public static void main(String[] args) { QueueDepthTest classObj = null; try { classObj = new QueueDepthTest(); final MQRegion env_region = MQRegion.DEV; final String queueName = MQQueueNames.CALC_REQUEST .getName(env_region); classObj.loadConfig(env_region); // Set up MQSeries environment final String mqQMgr = classObj.cf.getQueueManager(); MQEnvironment.hostname = classObj.cf.getHostName(); MQEnvironment.port = classObj.cf.getPort(); MQEnvironment.channel = classObj.cf.getChannel(); MQEnvironment.userID = classObj.cf.getClientID(); System.out.println("******IBM MQ values*****"); System.out.println("QMgr=" + mqQMgr); System.out.println("hostname=" + MQEnvironment.hostname); System.out.println("port=" + MQEnvironment.port); System.out.println("channel=" + MQEnvironment.channel); System.out.println("queue =" + queueName); final MQQueueManager qMgr = new MQQueueManager(mqQMgr); int openOptions = MQC.MQOO_INQUIRE; // int openOptions = CMQC.MQOO_INQUIRE + CMQC.MQOO_FAIL_IF_QUIESCING // + CMQC.MQOO_INPUT_SHARED; MQQueue destQueue = qMgr.accessQueue(queueName, openOptions); final int depth = destQueue.getCurrentDepth(); System.out.println("printing the queue depth =" + queueName + " is=" + depth); destQueue.close(); qMgr.disconnect(); } catch (Exception err) { err.printStackTrace(); } } } public enum MQRegion { DEV ("hostname", port, "channel","QMgr","ClientID"); private String hostName; private long port; private String channel; private String queueManager; private String clientId; MQRegion(String hostName, int port, String channel, String queueManager, String clientId) { this.hostName = hostName ; this.port = port; this.channel =channel; this.queueManager=queueManager; this.clientId = clientId; } public String getHostName() { return hostName; } public String getChannel() { return channel; } public String getQueueManager() { return queueManager; } public String getClientId() { return clientId; } public long getPort() { return port; } } public enum MQQueueNames { QUEUE_NAME("QUEUE_NAME"); MQQueueNames(String name) { this.name = name; } private String name; public String getName(MQRegion region) { switch(region) { case DEV: return name + ".DEV2"; case SIN: return name + ".SIN1"; case UAT: return name + ".UAT3"; } return name; } } import javax.jms.BytesMessage; import javax.jms.ConnectionConsumer; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Queue; import javax.jms.QueueConnection; import javax.jms.QueueReceiver; import javax.jms.QueueSender; import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.TextMessage; import com.bnym.test.common.ConstantsEnum; import com.ibm.jms.JMSMessage; import com.ibm.mq.MQC; import com.ibm.mq.MQEnvironment; import com.ibm.mq.jms.MQQueueConnectionFactory; import com.ibm.mq.jms.MQQueueSender; import com.ibm.mq.jms.MQQueueSession; public class ServerConfig { protected MQQueueConnectionFactory cf = null; protected boolean needConcurrent = false; protected void loadConfig(MQRegion region) throws JMSException { cf = new MQQueueConnectionFactory(); cf.setHostName(region.getHostName()); cf.setPort((int) region.getPort()); cf.setTransportType(1); cf.setQueueManager(region.getQueueManager()); cf.setChannel(region.getChannel()); cf.setClientId(region.getClientId()); } } |
My Quotes
When U were born , you cried and the world rejoiced
Live U'r life in such a way that when you go
THE WORLD SHOULD CRY
Powered by Find-IP.net
Thursday, October 17, 2013
Message Queue Depth
Tuesday, October 8, 2013
Nano seconds in Java
- Get backport-util-concurrent.jar from nexus
<dependency>
<groupid>backport-util-concurrent</groupid>
<artifactid>backport-util-concurrent</artifactid>
<version>3.1</version>
</dependency>
- code snippet
import java.util.concurrent.TimeUnit;
long timeInMillis = System.currentTimeMillis();
- You can use query to get the DB time
select extract(day from(systimestamp - to_timestamp('1970-01-01', 'YYYY-MM-DD'))) * 86400000 + to_number(to_char(sys_extract_utc(systimestamp), 'SSSSSFF3')) current_time_milliseconds
from dual;
- Timestamp dbTimeStamp = result of above quey...
dbTimeStamp.setNanos((int) (nanos % 1000000000));
Oracle equivalent of java currentTimeMillis
Instead of the
queryString = "SELECT systimestamp param FROM DUAL";
use the following
select extract(day from(systimestamp - to_timestamp('1970-01-01', 'YYYY-MM-DD'))) * 86400000 + to_number(to_char(sys_extract_utc(systimestamp), 'SSSSSFF3')) current_time_milliseconds
from dual;
Subscribe to:
Posts
(
Atom
)