Search This Blog

Showing posts with label MQ. Show all posts
Showing posts with label MQ. Show all posts

Wednesday, March 6, 2013

Usefull MQ command

here are some usefull comand to use when working with MQ
command to display the queuestatus of a queue:
dis qs() type(handle) all 

command to display the queuestatus of a queue (and only display the pid) :
dis qs() type(handle) pid 

command to display the queuestatus of a queue (and display the applicationtag and the pid) :
dis qs() type(handle) appltag pid
display all the queues that contains more then 0 messages: dis ql(*) where (curdepth gt 0) 

start an api trace:
strmqtrc -m [QM]  -t api
(the -t has several options. Logs are written to: /trace)

end a trace:
endmqtrc -m [QM]


on windows you can read the TRC files via text viewer.

Enjoy 
Yaniv Tzanany

Tuesday, May 1, 2012

MQ CCDT files with C++


A client channel definition table (CCDT) file contains the details of all the client-connection channels defined at the WebSphere MQ Server. It is a binary file with the name amqclchl.tab and it is created automatically by the WebSphere MQ system when you create one or more client connection channels. You can find this file on the server at this location:

On Windows
\mqm\qmgrs\\@ipcc

On UNIX systems
/var/mqm/qmgrs//@ipcc

How to work with CCDT file in C++ MQ client ?
the easiest way to test your CCDT file is via the amqsputc program that shipped with MQ installation.
set the next env params ( the mqsslkeyr is for ssl key , i used in this sample , its optional, if no ssl required):
the paths is where to find your AMQCLCHL.TAB  files ...
more about Using WebSphere MQ environment variables

(make sure the MQSERVER env param is not set)


set mqchllib=C:\Program Files\IBM\WebSphere MQ\Qmgrs\MYQM\ssl\MQCLIENT
set mqchltab=AMQCLCHL.TAB
set mqsslkeyr=C:\Program Files\IBM\WebSphere MQ\Qmgrs\ MYQM\ssl\MQCLIENT\key

run the next command
amqsputc   MY.Q


if all configured well you should connect to QM and put messages into yours 


How to use CCDT  with C++  ?
the idea is simple , make sure you set the env param before connecting to the QM.
avoid setting the queue name and the channel name , or any connection details.
only the Queue name is important.

putenv("mqchllib=C:\Program Files\IBM\WebSphere MQ\Qmgrs\ MYQM\ssl\MQCLIENT");
putenv(" mqchltab=AMQCLCHL.TAB");
putenv("mqsslkeyr=C:\Program Files\IBM\WebSphere MQ\Qmgrs\ MYQM\ssl\MQCLIENT\key");

ImqQueueManager mgr;
mgr.connect();

ImqQueue q1;
q1.setName("MY.Q.NAME");

q1.setConnectionReference( m_QMgr );
q1.setOpenOptions(m_lOpenQueueInFlags);
q1.open();


Enjoy
Yaniv Tzanany

Wednesday, April 18, 2012

How To MQ SSL

You Must READ this : WebSphere MQ SSL channels on Windows

MQ SSL

SSL configuration of the Websphere MQ Java/JMS client

How to Set MQ ssl details programmatically (c++)?
My C++ code looks like this ( the MQ header from v7/6 version):

ImqChannel * pchannel = new ImqChannel;
pchannel->setChannelName("SSL_CHANNEL");
pchannel->setTransportType(MQXPT_TCP);
pchannel->setConnectionName ("myhostname(1414)");
pchannel->setSslCipherSpecification("TRIPLE_DES_SHA_US"); // its must be the same as the channel 

ImqQueueManager mgr;
mgr.setName("myQMgr");
mgr.setChannelReference(pchannel);
mgr.setKeyRepository("c:\\keys\\key");

To complete this post , and if you interesting with How to MQ SSL with CCDT files follow this post.

Yaniv Tzanany

Monday, February 6, 2012

Setting the applicationOriginData on MQMessage

the applicationOriginData on MQMessage java class , is a great way to add some app extra info on the message.
"This is information that is defined by the application suite, and can be used to provide additional information about the origin of the message."

In addition to add such data you must open the queue with the next option:
MQC.MQPMO_SET_ALL_CONTEXT


and when put the message add the same option above  on the MQPutMessageOptions.
this is the only way i managed to add such info on the message.


enjoy
Yaniv Tzanany

Sunday, June 5, 2011

WebSphere MQ Queue Load / Unload Utility

here you can find a very good utility from IBM to use with MQ product.
Possible Uses:
• To save the messages that are on a queue, to a file, perhaps for archiving purposes and the possibility of later reload back onto a queue.
• To reload a queue with messages you previously saved to a file.
• To remove messages from a queue which are old.
• To ‘replay’ test messages from a stored location – even maintaining time spacing if required.

IBM MO03: WebSphere MQ Queue Load / Unload Utility -
United States

enjoy
Yaniv Tzanany

Tuesday, January 4, 2011

Working with WebSphere MQ JMS Under WebSphere app server

i struggled allot to make this JMS  sample working .
follow the next instruction to use JMS under web sphere.

1. get into admin console
2. get into JMS->connection factories  -> new
    choose web sphere MQ , click OK .
give it a logic name , and a jndi name such as jms/myMqFactory, and set the correct parameters during the wizard.
click finish and save.

3. goto Resources -> JMS ->queues
4. click new , and choose websphere MQ message provider
set the name and jndi name such as jms/mqRequestQ
and set the queue name
5. click apply and save.

some resources i used :
Developing a JMS client

IBM WebSphere Developer Technical Journal: Building an Enterprise Service Bus with WebSphere Application Server V6 -- Part 3
A java.lang.ClassCastException error occurs during a JNDI lookup of a queue connection factory


How to extract Queue Manager Name from CF / QCF in your J2EE JMS application



here is the code snippets, i used tp send message to mqRequestQ and get result from mqResponseQ , and pick the message with the same msg id:

private void testJMS(String qIn,String qOut )
{

    String  outString                 = "I am a string from JMS";
    String  qcfName                   = "jms/myMqFactory";
    String  qnameIn                   = "jms/mqRequestQ";
    String  qnameOut                  = "jms/mqResponseQ";
    boolean verbose                   = false;

    Session           session    = null;


    Connection        connection = null;
    ConnectionFactory   qcf  = null;

    Queue                  inQueue    = null;
    Queue                  outQueue   = null;
    InitialContext context = null;
    try {
context = new InitialContext();
qcf = (ConnectionFactory)context.lookup( qcfName );
inQueue = (Queue)context.lookup( qnameIn );
outQueue = (Queue)context.lookup( qnameOut );

   if(qcf != null)
   {
connection = qcf.createConnection();  
connection.start();
boolean transacted = false;
session = connection.createSession( transacted,
Session.AUTO_ACKNOWLEDGE);
((MQQueue)inQueue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ); //its 1
MessageProducer  queueSender = session.createProducer(inQueue);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
queueSender.setTimeToLive(60000); // in milli seconds 0 - unlimited
TextMessage outMessage = session.createTextMessage(outString);
outMessage.setJMSCorrelationID("Alis0000");
queueSender.send(outMessage);
queueSender.close();

String msgID  = outMessage.getJMSMessageID();
String selector1 = "JMSMessageID='"+msgID+"'";
MessageConsumer queueReciever =  session.createConsumer(outQueue, selector1);
javax.jms.Message inMessage =  queueReciever.receive(2000);
if ( inMessage instanceof TextMessage )
{
String replyString = ((TextMessage) inMessage).getText();
}
queueReciever.close();

session.close();
session = null;
connection.close();
connection = null;
   }

} catch (NamingException e) {
// there is no such DSN lets report it and will try to work without the DataSource name

} catch (JMSException je) {
      System.out.println("JMS failed with "+je);
      Exception le = je.getLinkedException();
      if (le != null)
      {
  System.out.println("linked exception "+le);
      }
}
}

enjoy
Yaniv Tzanany


Wednesday, December 1, 2010

How to check your MQ client software connectivity to the QM - 2058 ?

Our software linked to  MQ client library , sometimes when the client deploy our software on new machine , or move it to other , he complain about the mq error 2058 , that we return  while trying to connect to the QM.

i am always explained that we have a buggy-less software, and check your environment :) ,

I suggest to run the built-in sample that arrived with the MQ installation.

This will give us a clue , if its installation issue or software .
I am talking about the amqsputc program (the client version one).
Here is how i managed to put messages on Windows QM , from our AIX.

bash-3.00# cd /usr/mqm/samp/bin

bash-3.00# export MQSERVER='SYSTEM.DEF.SVRCONN/TCP/srv1(1414)'
bash-3.00# ./amqsputc YANIVTIN QM1
Sample AMQSPUT0 start
target queue is YANIVTIN
hello world
^C
bash-3.00#

export MQSERVER='SYSTEM.DEF.SVRCONN/TCP/srv1(1414)'

The first part if the name of a 'svrconn' channel, the second is

the protocol used, and the third is the 'connection name'
consisting of either an ip address or hostname or dsn name,
followed by the port number. By default, MQ uses 1414.

btw:
in windows you set the env setting as follow:
SET MQSERVER=SYSTEM.DEF.SVRCONN/TCP/srv1(1414)


i hope its help
enjoy
Yaniv Tzanany



 

 

suggesting to the client

Wednesday, July 14, 2010

MQGET on Cluster Queue manager

you can read about Queue Manager Clusters
"As with distributed queuing, an application uses the MQPUT call to put a message on a cluster queue at any queue manager. An application uses the MQGET call to retrieve messages from a cluster queue on the local queue manager. "

when you are dealing with server binding mode and cluster queue manager you can use MQPUT on any QM in the cluster , when using MQGET  you should use the local QM - otherwise you will get reason code - 2085  while try to access/open it.

i used the next c++ option when i open the queue.

for get: MQOO_INPUT_AS_Q_DEF
For put : MQOO_OUTPUT

Yaniv T

Wednesday, June 16, 2010

C++ MQ application without MQ Client installation

The next stuff tested on mq v5.3.
Sometimes your program run on the same machine where the MQ server is installed , so why to install MQ client on this server , if you have the MQ server there ??
the "Trick" is in your app development , you need to compile and link your application with the correct MQ library , client or server.Usually the server library contains  the s character and the client with the c.
e.g. imq{c|s}23in, imq{c|s}23vn.

when dealing with server binding you need to know the next stuff, the channel name and the server name is ignored, the important parameters is just the queue manager name , and the queues name.
In case you want to connect to the default queue manager name leave the queue manager name empty.

Enjoy
Yaniv T

Sunday, May 30, 2010

Making an existing queue manager the default

on version 5.3
"On Windows systems, use the WebSphere MQ Services snap-in to display the properties of the queue manager, and check the Make queue manager the default box. You need to stop and restart the queue manager for the change to take effect. "
the above instruction  are from Creating a queue manager

on version 6 and 7
On WebSphere® MQ for Windows® and WebSphere MQ for Linux® (x86 platform) systems, you can make an existing queue manager the default queue manager as follows:
1.Open the WebSphere MQ Explorer.
2.Right-click IBM WebSphere MQ, then select Properties.... The Properties for WebSphere MQ panel is displayed.
3.Type the name of the default queue manager into the Default queue manager name field.
4.Click OK.
thats from here http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=/com.ibm.mq.amqzag.doc/fa10880_.htm


Yaniv

Configuring WebSphere MQ with the WebSphere MQ Explorer - Version: 5.3

The next link is a step by step of description + images , how to set queue manager , and local queue, via MQ explorer , i think its version 5.3.
i find it very useful for beginners .
http://support.sas.com/rnd/itech/doc9/dev_guide/messageq/mqexplor.html

enjoy
Yaniv T

Tuesday, May 11, 2010

Queue manager on mainframe / zos.

I have a program that put messages on MQ series its its working like a charm , the other side can pick up the message and everyone are happy, the MQ series installed on windows.
We try to deploy our program on the client environment they only changes was that the MQ series installed on mainframe, we knew that, but MQ is multi-platform OS there was no worries, so we manged to connect to the Queue manager and put a message , the problem was the other side could not pick up the message we sent.
we could not find what can cause it , untill we found this thread strange mq client behaviour whan connecting to mainframe

"Mainframe queue managers use syncpoint by default, other platforms do not. Messages are going onto the mainframe queue (causing the count to increase) but are not eligable to be read back (appearing to be blank) and eventually roll back (causing the count to decrease again). Use an explicit commit (like q.exe does). It won't affect running again non-mainframe queue managers."

so right after the put messages i used
qmgr.commit
and the other side could pick up my message from the mainframe queue - that's worked !!!

enjoy
Yaniv T

Wednesday, January 27, 2010

IBM Cloud solution

Recently i started to "play" with IBM solution for the cloud , you can find it at Development & Test from IBM .

Its still in Beta and open for developers and test, the idea very much looks like Amazon WS , you can create you instance in a minutes and you can choose from several existing instances (Images) , you can even create your own image publish it ( i guess) , also you can have your own storage on the cloud and mount it to any instance you already have.
i suggest first to create your storage and than your instance , because while creating the instance you can mount the storage easily.
i created my SUSE Linux Enterprise v10 SP2 from an exiting image , i manage to connect to it via putty (watch this video for Accessing Instances using SSH Clients ).
in the next steps i will explain how do i install MQSeries 7.0.1 on it .
i upload to my Storage the MQSeries installation file (tar.gz file) via ftp (i used filezilla - use the next link how to use filezilla with the key supplied- Key based authentication ).
i unzip it and open it.
the complete installation step for MQ 32bit -> Installing a WebSphere MQ
i didn't update any kernel parameters.
you have to run the mqlicense.sh under root permission , but we do not have any root password , so the trick is:
use the sudo command on the cloud to run command under root.
so i use -> sudo su - root
and than i run the installation
add idcuser to the mqm group -> useradd -G mqm idcuser
for RedHat version i used -> usermod -G mqm idcuser

IBM cloud solution is still in Beta so their site is quite slow and buggy , but its looking good and do the job at the moment , in 2 minutes i created my Suze server with websphere 7, i want to see you do it by yourself , and its working too !!!

Get started with the IBM Smart Business Development and Test on the IBM Cloud


regards
Yaniv T

Monday, August 31, 2009

MQSeries - enable trace

To Enable WebSphere MQ tracing by executing the following command.
On Windows (Win32) systems: strmqtrc -t api -l 5
On Linux systems: strmqtrc -e -t api -l 5

The strmqtrc tool can be found under the bin directory located under the main MQ
installation directory.

To Stop tracing by executing the command below.
On Windows (Win32) systems: endmqtrc
On Linux systems: endmqtrc -a

The WebSphere MQ trace logs can be found under the (MQ_HOME)\trace directory ,(on AIX its under /var/mqm/trace)
and are all the files that end with extension ".TRC"

i just found a good article how to set trace and decode it
Tracing WebSphere MQ

enjoy
YanivT