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 Java / JMSCCDT in JAVA

Post new topicReply to topic Goto page Previous  1, 2
CCDT in JAVA View previous topic :: View next topic
Author Message
kalam475
PostPosted: Sat Nov 12, 2016 10:16 pm Post subject: Reply with quote

Acolyte

Joined: 16 Jan 2015
Posts: 56

Hi fjb_saper,

It was a typo.

Here are the things i have done in order.

1. Create a queue manager
2. Create a server- connection channel
3. Create a Client connection channel with the same name as the server connection channel
4.copy the AMQCLCHL.TAB (/var/mqm/qmgrs/<queue manager name>/@ipcc) from my linux machine to Window machine (client)
5.set the environment variables in Client machine as
MQCHLLIB=D:\ccdt
MQCHLTAB=AMQCLCHL.TAB
6. Simple java code to create a connection
Code:

public class MQTest {
public static void main(String[] args) {

   
    try {
     String qMgrName ="QM3";
     String QUEUE1 ="TARGET";
       
java.net.URL chanTab1 = new URL("file:///D:\\ccdt\\AMQCLCHL.TAB");
        System.out.println("test");
       
     MQQueueManager qMgr = new MQQueueManager(qMgrName, chanTab1);
System.out.println("test");


     System.out.println("Connected to QMGR ");
     int openOptions = MQC.MQOO_OUTPUT;
     MQQueue InQueue = qMgr.accessQueue(QUEUE1,openOptions,null,null,null);
     MQMessage inMessage = new MQMessage();
     inMessage.writeString("###Testing####");
     InQueue.put(inMessage);
     System.out.println("Message Id is :" + Arrays.toString(inMessage.messageId));
     System.out.println(inMessage.toString());
     InQueue.close();
     qMgr.disconnect() ;
 }
 catch(MQException ex){
     System.out.println("MQ Error - Reason code :" + ex.reasonCode);
 }
 catch (IOException e){
     System.out.println("Error : " + e);
 }
}
}


Now i am getting the error

MQJE001: Completion Code 2, Reason 2278

My program is not able to create a connection to queue manager in the first place. that is the problem.


Thanks for your patience and please help me on this .
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Sun Nov 13, 2016 11:08 am Post subject: Reply with quote

Jedi Knight

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

kalam475 wrote:
I am using MQ 9.0

Is that on Linux or Windows? What version of MQ was used to create the CCDT file? What version of the MQ/Java JAR files are you using?

kalam475 wrote:
4.copy the AMQCLCHL.TAB (/var/mqm/qmgrs/<queue manager name>/@ipcc) from my linux machine to Window machine (client)

How did you copy/ftp the file to the Windows machine? Did you make sure to copy it as 'binary'? Because if you copied as 'ASCII' then that is your issue.

kalam475 wrote:
5.set the environment variables in Client machine as
MQCHLLIB=D:\ccdt
MQCHLTAB=AMQCLCHL.TAB

These environment variables are not used by MQ/Java library.

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
hughson
PostPosted: Sun Nov 13, 2016 4:05 pm Post subject: Reply with quote

Yatiri

Joined: 09 May 2013
Posts: 642
Location: Bay of Plenty, New Zealand

kalam475 wrote:
Now i am getting the error

MQJE001: Completion Code 2, Reason 2278


This is a different error code, so you must have done something different this time to the last time.

2278 is MQRC_CLIENT_CONN_ERROR.

Did you remember when defining the CLNTCONN, to put the queue manager name in the QMNAME field this time? You don't show your definitions this time, so unsure if they are exactly the same as you have previously posted.

Cheers
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
kalam475
PostPosted: Mon Nov 14, 2016 4:08 am Post subject: Reply with quote

Acolyte

Joined: 16 Jan 2015
Posts: 56

Hey issue is resolved. Thanks for your help!!

What I did was recreate the AMQCLCHL.TAB and put only one queue manager name in the Client connection channel and mention the queue manager name in the client connection channel. It worked fine.

I think recreating the file did the trick.

Any how when i am switching my active queue manager to passive queue manger my application is not able to connect to now active queue manager.

I did mention my two queue manager names in client connection channel as

mq1.tec.com(1416),mq2.tec.com(1416)


I am getting the error 2059 i.e queue manager is not available. is that means it is still searching on mq1.tec.com which is my previous active queue manager.


When my active instance is mq1.tec.com i am able to put the message but when i switch to mq2.tec.com as active i am getting 2059.


Do i have to make any changes to my code for this to work. Thanks
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Nov 14, 2016 4:35 am Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6061
Location: Somewhere over the Rainbow this side of Never-never land.

When you get a 'disconnect' error do you close everything including the QMGR connection and reconnect?
From memory, it is the underlying MQCONN/MQCONNX that decides if the first QMGR is available and if not, tries the second one.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
kalam475
PostPosted: Mon Nov 14, 2016 6:46 am Post subject: Reply with quote

Acolyte

Joined: 16 Jan 2015
Posts: 56

Hi

The very idea of using multi-instance queue manger along with CCDT in my java code is that i don't have to manually connect to second queue manager (Passive queue manager which become active queue manager).

Am I thinking wrong do i have to manually create a connection with all the details of passive queue manager (now active) in my reconnection.


I have tested using the sample amqsphac to switch it is working fine. I have written JMS code and used connection namelist property it is successfully switching between Active and passive.

Only in Java using CCDT i am facing difficulties.


I am fairley new to this help me out here
Back to top
View user's profile Send private message
kalam475
PostPosted: Mon Nov 14, 2016 6:50 am Post subject: Reply with quote

Acolyte

Joined: 16 Jan 2015
Posts: 56

Here is my code

Code:

package com.ca.mq;

import com.ibm.mq.MQC;
import com.ibm.mq.MQEnvironment;
import com.ibm.mq.MQException;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
import com.ibm.mq.jmqi.MQCNO;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Map;

/**
 *
 * @author kalam
 */

public class MQTest {
public static void main(String[] args) {

   
    try {
     String qMgrName ="QM1";
     String QUEUE1 ="TARGET";
       

URL("file:///D:\\ccdt\\AMQCLCHL.TAB") ;
MQEnvironment.userID="mqadmin";
MQEnvironment.password="Password1";
java.net.URL chanTab1 = new URL("file:///D:\\ccdt\\AMQCLCHL.TAB");
        System.out.println("test");
        MQQueueManager qMgr = new MQQueueManager(qMgrName, chanTab1);
System.out.println("test");


     System.out.println("Connected to QMGR ");
     int openOptions = MQC.MQOO_OUTPUT;
     MQQueue InQueue = qMgr.accessQueue(QUEUE1,openOptions,null,null,null);
     MQMessage inMessage = new MQMessage();
     inMessage.writeString("###Testing####");
     InQueue.put(inMessage);
     System.out.println("Message Id is :" + Arrays.toString(inMessage.messageId));
     System.out.println(inMessage.toString());
     InQueue.close();
     qMgr.disconnect() ;
 }
 catch(MQException ex){
     System.out.println("MQ Error - Reason code :" + ex.reasonCode);
 }
 catch (IOException e){
     System.out.println("Error : " + e);
 }
}
}



and my client connection channel details

Display channel(channel1)
2 : Display channel(channel1)
AMQ8414: Display Channel details.
CHANNEL(CHANNEL1) CHLTYPE(CLNTCONN)
AFFINITY(PREFERRED) ALTDATE(2016-10-31)
ALTTIME(22.57.26) CERTLABL( )
CLNTWGHT(0) COMPHDR(NONE)
COMPMSG(NONE)
CONNAME(mq1.tec.com (1416),mq2.tec.com (1416))
DEFRECON(NO) DESCR( )
HBINT(300) KAINT(AUTO)
LOCLADDR( ) MAXMSGL(4194304)
MODENAME( ) PASSWORD( )
QMNAME(QM1) RCVDATA( )
RCVEXIT( ) SCYDATA( )
SCYEXIT( ) SENDDATA( )
SENDEXIT( ) SHARECNV(10)
SSLCIPH( ) SSLPEER( )
TPNAME( ) TRPTYPE(TCP)
USERID( )
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Mon Nov 14, 2016 4:57 pm Post subject: Reply with quote

Jedi Knight

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

kalam475 wrote:
Am I thinking wrong do i have to manually create a connection with all the details of passive queue manager (now active) in my reconnection.

There is no magic wand in MQ library.

kalam475 wrote:
CONNAME(mq1.tec.com (1416),mq2.tec.com (1416))

MQQueueManager qMgr = new MQQueueManager(qMgrName, chanTab1);

Explanation: When the JVM instantiates the MQQueueManager class, the MQ library will attempt to make a connection to 'mq1.tec.com (1416)'.
- if it succeeds then the MQ library is done
- if it fails then the MQ library will try to make a connection to 'mq2.tec.com (1416)'
- - if it succeeds then the MQ library is done
- - if it fails then the MQ library throws an MQException of RC 2059 or 2538 (depends on the version of MQ).

Now to the fly in your soup. There is no magic wand in MQ. If the queue manager is stopped/crashed/network issues then the MQ library will throw an MQException of RC whatever (depends on the issue) and the MQ library is done/over (there is no recovery or re-connection).

You will need to write your own re-connection logic. For a good example, go look at my open source project called UFM. Find the class called MQGetMsg or MQStatusUpdate, they each have a method called 'reconnect'.

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
kalam475
PostPosted: Mon Nov 14, 2016 9:40 pm Post subject: Reply with quote

Acolyte

Joined: 16 Jan 2015
Posts: 56

Hi RogerLacroix thanks for your reply


Quote:
*if it fails then the MQ library throws an MQException of RC 2059 or 2538 (depends on the version of MQ).*


As suggested by you my mq program will first connect to mq1.tec.com if it is not available it will try to connect to mq2.tec.com and if that is also not available it will thow 2059.

But here my mq2.tec.com is available and i am able to ping the server and telnet the port 1416 when active is switched to mq2.tec.com still i am getting 2059.

Thanks for your link of UFM I think the reconnection logic is to make my program wait for certain amount of time but i am running my program once it is switched completly to mq2.tec.com

Am i missing something here!
Back to top
View user's profile Send private message
hughson
PostPosted: Tue Nov 15, 2016 12:55 am Post subject: Reply with quote

Yatiri

Joined: 09 May 2013
Posts: 642
Location: Bay of Plenty, New Zealand

Simplify the problem to help you debug it.

Run the queue manager on mq2.tec.com and only have that address used by the client application. Can you connect with that setup. If not, debug that, is the listener running etc etc.

If you can connect in that way then look to the stop and start scenario. Just stop and restart the queue manager on the same machine. Can the client still connect? Is there something that isn't restarted after the queue manager comes up again, e.g. the listener?

If you can connect in that way then look to the failover scenario. What is different in that case from the above cases that mean your client can't connect.

Remember that it may be easier to try with a sample like amqsputc which will write more information in the client side ANQERR01.LOG because it is a 'C' client. It can u the same CCDT as you have created for your Java program so it is also a good way to test that the CCDT is OK.

Cheers
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Tue Nov 15, 2016 5:47 am Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 18994
Location: LI,NY

Last but not least, remember that you need to create the CCDT to the lowest level used.
You cannot use a CCDT created for MQ V9 with a client at MQ V7.5....
Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:
Post new topicReply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum IndexIBM MQ Java / JMSCCDT in JAVA
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.