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 Index » IBM MQ Java / JMS » JAVA API code in "usning java" is dated ? API is

Post new topic  Reply to topic Goto page Previous  1, 2, 3  Next
 JAVA API code in "usning java" is dated ? API is « View previous topic :: View next topic » 
Author Message
mqjeff
PostPosted: Wed Jun 22, 2011 9:23 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=/com.ibm.mq.amqzao.doc/fm12610_.htm
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jun 22, 2011 9:23 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

anotherID wrote:
Code:
MQJE001: Completion Code '2', Reason '2058'


Congratulations.

And when you looked up that code what did you attempt to fix it? Given that it's a fairly obvious error with a limited number of possible causes?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
anotherID
PostPosted: Wed Jun 22, 2011 9:30 am    Post subject: Reply with quote

Novice

Joined: 21 Jun 2011
Posts: 19

I am glad now I am actually working on MQ errors now its

2035, which is not enough rights.

Thanks for every ones halp.

If I get stuck again. I will post.
Back to top
View user's profile Send private message
anotherID
PostPosted: Wed Jun 22, 2011 10:38 am    Post subject: Reply with quote

Novice

Joined: 21 Jun 2011
Posts: 19

Code:
1 import com.ibm.mq.*;
  2 import com.ibm.mq.constants.CMQC;
  3
  4 public class MQSample
  5 {
  6    private String qManager = "TST";
  7    private String hostname = "mq-host";
  8    private String channel  = "TST.TO.DEV";
  9    private String port     = "1622";
 10    private MQQueueManager qMgr;
 11
 12   public static void main(String args[]) {
 13      new MQSample();
 14   }
 15
 16   public MQSample() {
 17    try {
 18
 19
 20       qMgr = new MQQueueManager(qManager);
 21
 22
 23
 24       int openOptions =  CMQC.MQOO_BROWSE | CMQC.MQOO_INPUT_AS_Q_DEF | CMQC.MQOO_OUTPUT ;
 25
 26
 27       MQQueue system_default_local_queue =
 28               qMgr.accessQueue("SENDQ0",
 29                                openOptions);
 30
 31
 32
 33       MQMessage hello_world = new MQMessage();
 34       hello_world.writeUTF("Hello World!");
 35
 36
 37
 38       MQPutMessageOptions pmo = new MQPutMessageOptions();
 39
 40
 41
 42       system_default_local_queue.put(hello_world,pmo);
 43
 44
 45 //      MQMessage retrievedMessage = new MQMessage();
 46  //     retrievedMessage.messageId = hello_world.messageId;
 47
 48
 49
 50   //    MQGetMessageOptions gmo = new MQGetMessageOptions();
 51
 52     //  system_default_local_queue.get(retrievedMessage, gmo);
 53
 54
 55
 56      // String msgText =
57     //  System.out.println("The message is: " + msgText);
 58
 59       system_default_local_queue.close();
 60
 61
 62       qMgr.disconnect();
 63     }
 64
 65     catch (MQException ex)
 66     {
 67       System.out.println("A WebSphere MQ error occurred : Completion code " +
 68                          ex.completionCode + " Reason code " + ex.reasonCode);
 69     }
 70
 71     catch (java.io.IOException ex)
 72     {
 73       System.out.println("An error occurred whilst writing to the message buffer: " + ex);
 74     }
 75   }
 76 }


Is this right way to create a q-manger object?
I think not, because when I ececute it, it tries too look at q-manager on local machine rather then "mq-host".

I do have TST qmanager on local system to and code worked with that fine, wrote message and read them as well.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jun 22, 2011 10:42 am    Post subject: Reply with quote

Grand High Poobah

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

To talk to a remote qmgr you need to initialize the MQEnvironment class, and look at the alternative class instantiation methods.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
anotherID
PostPosted: Wed Jun 22, 2011 12:43 pm    Post subject: Reply with quote

Novice

Joined: 21 Jun 2011
Posts: 19

Code:
  1 import com.ibm.mq.*;
  2 import com.ibm.mq.MQEnvironment;
  3 import com.ibm.mq.jmqi.JmqiObject;
  4 import com.ibm.mq.MQQueueManager;
  5 import com.ibm.mq.constants.CMQC;
  6
  7
  8 public class MQSample
  9 {
 10 public static void main(String[] args)
 11 {
 12
 13 MQEnvironment.hostname = "mq-host";
 14 MQEnvironment.channel = "TST.TO.DEV";
 15 MQEnvironment.port = 1622;
 16 MQEnvironment.userID = "mqusr"; // equivalent to env var MQ_USER_ID
 17 MQEnvironment.password = "XXXX";
 18
 19 MQQueueManager queueManager = new MQQueueManager("TST");
 20
 21 //queueManager.disconnect();
 22
 23
 24 }
 25 }



Code:
$ javac   MQSample.java
MQSample.java:19: unreported exception com.ibm.mq.MQException; must be caught or declared to be thrown
MQQueueManager queueManager = new MQQueueManager("TST");
                              ^
1 error




What now?
Back to top
View user's profile Send private message
mvic
PostPosted: Wed Jun 22, 2011 12:50 pm    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

I'm not much of a Java programmer, but it looks like you need a try/catch block around the statement listed.

There are quite a few other samples with MQ v7. Have you checked through them to see if there is anything close to what you need? If not then it could still be worthwhile to help you know what else is available.
Back to top
View user's profile Send private message
anotherID
PostPosted: Wed Jun 22, 2011 12:55 pm    Post subject: Reply with quote

Novice

Joined: 21 Jun 2011
Posts: 19

mvic wrote:
I'm not much of a Java programmer, but it looks like you need a try/catch block around the statement listed.

There are quite a few other samples with MQ v7. Have you checked through them to see if there is anything close to what you need? If not then it could still be worthwhile to help you know what else is available.


You have no idea.

If I try to get help from different document I get into a different realm of imports, calls etc etc.... I miss C language

Now I am following on doc by IBM and things still wont work.

I miss how in C you can pick a structure assigns values and use it.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jun 22, 2011 12:57 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

anotherID wrote:
You have no idea.


Nor, it seems, do you.

anotherID wrote:
If I try to get help from different document I get into a different realm of imports, calls etc etc.... I miss C language


Then write in C.

anotherID wrote:
I miss how in C you can pick a structure assigns values and use it.


I know what you mean. It's like Java's a different language.....
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 22, 2011 1:00 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
It's like Java's a different language.....

At least you can trust it to know what chips are.
Back to top
View user's profile Send private message
anotherID
PostPosted: Wed Jun 22, 2011 1:01 pm    Post subject: Reply with quote

Novice

Joined: 21 Jun 2011
Posts: 19

Vitor wrote:
anotherID wrote:
You have no idea.


Nor, it seems, do you.

anotherID wrote:
If I try to get help from different document I get into a different realm of imports, calls etc etc.... I miss C language


Then write in C.

anotherID wrote:
I miss how in C you can pick a structure assigns values and use it.


I know what you mean. It's like Java's a different language.....


1-Truth be told, in C you can do stuff even if you are not 24/7 programmer.
2-I looked at the C api, it did not have remote q manager thing.

3-Are you going to say any thing useful ? ever ?
Back to top
View user's profile Send private message
mvic
PostPosted: Wed Jun 22, 2011 1:02 pm    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

anotherID wrote:
You have no idea.

I have some ideas. What happens if you re-instate the try/catch block that was present in the working sample?
Back to top
View user's profile Send private message
anotherID
PostPosted: Wed Jun 22, 2011 1:07 pm    Post subject: Reply with quote

Novice

Joined: 21 Jun 2011
Posts: 19

mvic wrote:
anotherID wrote:
You have no idea.

I have some ideas. What happens if you re-instate the try/catch block that was present in the working sample?


Just to keep up with ""famous"" "using java" I installed older version of MQ, like 6.0.1-3 or some thing, it still gave me error of "depreciated calls/libraries "
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 22, 2011 1:11 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The userid and password fields are entirely meaningless. Don't set them.
Back to top
View user's profile Send private message
anotherID
PostPosted: Wed Jun 22, 2011 1:13 pm    Post subject: Reply with quote

Novice

Joined: 21 Jun 2011
Posts: 19

mqjeff wrote:
The userid and password fields are entirely meaningless. Don't set them.


still same.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2, 3  Next Page 2 of 3

MQSeries.net Forum Index » IBM MQ Java / JMS » JAVA API code in "usning java" is dated ? API is
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.