ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexIBM MQ API Supportmq series client interface

Post new topicReply to topic
mq series client interface View previous topic :: View next topic
Author Message
jahjouh
PostPosted: Sun Jun 11, 2017 7:00 am Post subject: mq series client interface Reply with quote

Newbie

Joined: 28 Mar 2017
Posts: 4

Hello everyone,
I developed a C ++ application using the MQ API to interface with an MqSeries client. I followed the examples provided by IBM as "imqdput.cpp". I am able to start my application, but to connect, I do not know how to fill in the mq manager, the channel, and the tail. Knowing I was provided with:
the :
Host: hostname
IpAdress: xx.xx.xx.xxx
Qmanager: SERV_TEST
Listener port: XYXY
Channel application: TEST_APP
User: mqm (without password)
My question how in my program I inform the name of mq manager with the supplied elements, the channel. For the tails, I was provided and aliases is what is the same thing?
Thank you for your help.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Sun Jun 11, 2017 11:13 am Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 7844
Location: US: west coast, almost. Otherwise, enroute.

What were the results when you tried your app? Please be precise. "It didn't work." is not precise.

Did you use IBM's sample source c++ code? Did it work? https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q030200_.htm

imqwrld.cpp seems a bit simpler.
_________________
I didn't know that Schrdinger had a cat.
Back to top
View user's profile Send private message
jahjouh
PostPosted: Sun Jun 11, 2017 11:51 am Post subject: Reply with quote

Newbie

Joined: 28 Mar 2017
Posts: 4

My main problem is that I do not know the exact syntax to be able to connect to the MQ client from my application. In the documentation: the only settings are: MQSERVER or use a channel with chanelName / protocol / ip (port). But I do not know at what level the application should enter the username and password in the setting with the client.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jun 12, 2017 4:43 am Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 24614
Location: Ohio, USA

What version are you using? User id and password was introduced in MQ v8.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Mon Jun 12, 2017 5:19 am Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 7844
Location: US: west coast, almost. Otherwise, enroute.

jahjouh wrote:
In the documentation...

What documentation? Please be specific.
_________________
I didn't know that Schrdinger had a cat.
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Mon Jun 12, 2017 3:03 pm Post subject: Re: mq series client interface Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3020
Location: London, ON Canada

jahjouh wrote:
User: mqm (without password)

Do NOT, absolutely NOT have an MQ application use 'mqm' UserId. This UserId should ONLY be used by the queue manager (and possibly MQ monitoring tools).

Yes, IBM likes to make it difficult for MQ programmers to do simply things like pass a UserId and Password on the MQCONN/MQCONNX API call.

Here's a simple C++ program that sets a UserId and Password.

Code:
/*
 * Program Name
 *  MQTest31.cpp
 *
 * Description
 * Test program to connect to a queue manager using MQCONNX and MQCSP
 * and then put a message from a queue.
 *
 * Sample Command Line Parameters
 *   QMgrName ChlName hostname(port) QName
 *
 * Where
 *    QMgrName is the queue manager name
 *    ChlName is the name of the channel to be used
 *    hostname(port) is the hostname and port number
 *    QName is the queue name
 * i.e.
 *    MQTest31.exe MQWT1 MY.TEST.EXIT 127.0.0.1(1415) TEST.Q1
 *
 * @author Roger Lacroix, Capitalware Inc.
 * @version 1.00
 * @license Apache 2 License
 */
#include <iostream.h>
#include <stdio.h>
#include <string.h>

#include <imqi.hpp>    /* MQI */

/*
 * mainline
 */
int main ( int argc, char * * argv )
{
   /* --------------------------------------------
    * Variable declarations.
    * --------------------------------------------
    */
   ImqQueueManager  mgr;
   ImqChannel      *pchannel = 0 ;
   ImqQueue         queue;
   ImqMessage       msg;
   /* */
   char     buffer[10240];
   char     myUserId[33]   = "tester";
   char     myPassword[33] = "mypwd";
   char     testMsg[] = "This is a simple test message.";

   /* --------------------------------------------
    * Code section
    * --------------------------------------------
    */
   if (argc != 5)
   {
     cout << "Usage: MQTest31 QMgrName ChlName hostname(port) QName" <<endl;
     return( 1 );
   }

   cout << "MQTest31 Starting." <<endl;

   // Create object descriptor for subject queue
   mgr.setName( argv[ 1 ] );

   pchannel = new ImqChannel ;
   pchannel -> setHeartBeatInterval( 1 );
   pchannel -> setTransportType( MQXPT_TCP );
   pchannel -> setChannelName( argv[ 2 ] );
   pchannel -> setConnectionName( argv[ 3 ] );

   mgr.setChannelReference( pchannel );

   queue.setName( argv[ 4 ] );

   /*
    * Specify UserId and Password via MQCSP
    */
   mgr.setAuthenticationType(MQCSP_AUTH_USER_ID_AND_PWD);
   mgr.setUserId( myUserId );
   mgr.setPassword( myPassword );

   /*
    * Connect to queue manager
    */
   if ( ! mgr.connect( ) )
   {
     cout << "MQTest31: connect CC=" << mgr.completionCode()<< " : RC=" << mgr.reasonCode() <<endl;
     return( 1 );
   }

   /* setup queue info */
   queue.setConnectionReference( mgr );
   queue.setOpenOptions(MQOO_OUTPUT + MQOO_FAIL_IF_QUIESCING);
   queue.open( );
   cout << "MQTest31: open CC=" << queue.completionCode()<< " : RC=" << queue.reasonCode() <<endl;

   if ( queue.completionCode( ) == MQCC_OK )
   {
      msg.useEmptyBuffer( buffer, sizeof( buffer ) );
      msg.setMessageId( );
      msg.setCorrelationId( );
      msg.setMessageLength( (int)strlen( buffer ) );
      msg.setFormat( MQFMT_STRING );      /* character string format    */
      strcpy(buffer,  testMsg);
      msg.setMessageLength( (int)strlen( testMsg ) );

      queue.put(msg);
      cout << "MQTest31: put CC=" << queue.completionCode()<< " : RC=" << queue.reasonCode() <<endl;
   }

   /* Close the queue */
   queue.close( );
   cout << "MQTest31: close CC=" << queue.completionCode()<< " : RC=" << queue.reasonCode() <<endl;

   /* Disconnect from the queue manager */
   mgr.disconnect( );
   cout << "MQTest31: disconnect CC=" << mgr.completionCode()<< " : RC=" << mgr.reasonCode() <<endl;

   /* clean up */
   if ( pchannel )
   {
      mgr.setChannelReference( );
      delete pchannel ;
   }

   cout << "MQTest31 Ending." <<endl;
   return( 0 );
}


I believe you can remove the 'ImqChannel' class and then use either a CCDT (Client Channel Definition Table) file or the MQSERVER environment variable. Note: You will need to test it.

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexIBM MQ API Supportmq series client interface
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.