Solved

MessageQueue Series connection

Posted on 2001-06-18
21
268 Views
Last Modified: 2012-05-04
hi Experts,

1] I'm researching on how to do connection and disconnection using IBM MQseries functions from its library "import com.ibm.mq.*;".

2] I would like to know the details of these functions too. Do you know where can I find them?

Thanks ..
0
Comment
Question by:Dawn_rico
  • 14
  • 7
21 Comments
 

Author Comment

by:Dawn_rico
ID: 6201638
hi,

You may have found some useful contents to setup the connection using MQseries. Pls kindly do tell me too, thanks...
0
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6202120
Hi
its simple

String factory = "com.ibm.ejs.ns.jndi.CNInitialContextFactory";
String URL = "iiop://host/";
java.util.Hashtable environment = new java.util.Hashtable();
environment.put(InitialContext.PROVIDER_URL, URL);
environment.put(InitialContext.INITIAL_CONTEXT_FACTORY, factory);
Context context = new javax.naming.InitialContext(environment);

String factoryName = "main"; // MQSeries connection factory name
QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.get().lookup(factoryName);

QueueConnection connection = connectionFactory.createQueueConnection();
connection.start();


...

connection.close();

Best regards
Andrey
0
 

Author Comment

by:Dawn_rico
ID: 6202588
hi Andrey,

Thanks for ur immediate reply. May I know where do you find these useful references?

Do you make use of import com.ibm.mq.*;?
Do you make use of IBM MQseries software?

Have you ever come across the explaination of the functions from the library "import com.ibm.mq.*;".

Sorry .. I ask to trouble you with so many questions... I want to advance express my thanks if you'll willing to share with me. Thank you.

Dawn_rico
0
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6202658
this time i use IBM MQSeries...
but in our project we are using standart JMS api...

Example from IBM

import com.ibm.mq.*;//Include the MQSeries classes for Java package
public class MQSample extends java.applet.Applet
{

private String hostname ="your_hostname";//define the name of your
//host to connect to private String channel ="server_channel";/
//for client to use
//Note.assumes MQSeries Server
//is listening on the default
//TCP/IP port of 1414
private String qManager ="your_Q_manager";//define name of queue

//manager object to
//connect to.
private MQQueueManager qMgr;//define a queue manager object

//When the class is called,this initialization is done first.

public void init()
{
//Set up MQSeries environment
MQEnvironment.hostname =hostname;//Could have put the
//hostname &channel
MQEnvironment.channel =channel;//string directly here!
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,//Set TCP/IP or server
MQC.TRANSPORT_MQSERIES);//Connection
}//end of init

public void start()
{
try {
//Create a connection to the queue manager
qMgr =new MQQueueManager(qManager);
//Set up the options on the queue we wish to open...
//Note.All MQSeries Options are prefixed with MQC in Java.
int openOptions =MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT ;
//Now specify the queue that we wish to open,and the open options...
MQQueue system_default_local_queue =
qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",
openOptions,
null,//default q manager
null,//no dynamic q name
null);//no alternate user id
//Define a simple MQSeries message,and write some text in UTF format..
MQMessage hello_world =new MQMessage();
hello_world.writeUTF("Hello World!");
//specify the message options...
MQPutMessageOptions pmo =new MQPutMessageOptions();//accept the defaults,
//same as
//MQPMO_DEFAULT
//constant
//put the message on the queue
system_default_local_queue.put(hello_world,pmo);
//get the message back again...
//First define a MQSeries message buffer to receive the message into..
MQMessage retrievedMessage =new MQMessage();
retrievedMessage.messageId =hello_world.messageId;
//Set the get message options..
MQGetMessageOptions gmo =new MQGetMessageOptions();//accept the defaults
//same as
//MQGMO_DEFAULT
//get the message off the queue..
system_default_local_queue.get(retrievedMessage,gmo);
//And prove we have the message by displaying the UTF message text
String msgText =retrievedMessage.readUTF();
System.out.println("The message is:"+msgText);
//Close the queue
system_default_local_queue.close();
//Disconnect from the queue manager
qMgr.disconnect();
}
//If an error has occurred in the above,try to identify what went wrong.
//Was it an MQSeries error?
catch (MQException ex)
{
System.out.println("An MQSeries error occurred :Completion code "+
ex.completionCode +
"Reason code "+ex.reasonCode);
}
//Was it a Java buffer space error?
catch (java.io.IOException ex)
{
System.out.println("An error occurred whilst writing to the
message buffer:"+ex);
}
}//end of start
}//end of sample
0
 

Author Comment

by:Dawn_rico
ID: 6205145
hi Andrey,

Thanks for your example ... this is something that I've been searching for at their site ...pls give me read on and try out..

Dawn_rico.
0
 

Author Comment

by:Dawn_rico
ID: 6205324
hi Andrey,

Thanks for your example ... this is something that I've been searching for at their site ...pls give me read on and try out..

Dawn_rico.
0
 

Author Comment

by:Dawn_rico
ID: 6205328
I'm now exploring on the creation of the client and server environment.
0
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6205411
OK :)
 u r welcome

Andrey
0
 

Author Comment

by:Dawn_rico
ID: 6205825
I'm now exploring on the creation of the client and server environment.
0
 

Author Comment

by:Dawn_rico
ID: 6223694
Andrey ,

I've downloaded the beta program and let the system create default mqm properties for me. Now, I'm unable to access some places like the MQSeries Explorer cos' I'm unauthorised. How should I amend?

Thanks.

Dawn.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Dawn_rico
ID: 6223739
may I know where should I go to configure?
0
 

Author Comment

by:Dawn_rico
ID: 6230505
I've solved this by using another login with administrator rights, that auto give me rights to access the Explorer too.
0
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6231780
I havenot this problem... I know that your Windows should has preinstall MCI for management facilities. And that's all

Andrey
0
 

Author Comment

by:Dawn_rico
ID: 6233605
May I know what's MCI? This will be my last question.

0
 

Author Comment

by:Dawn_rico
ID: 6233844
I've used the search feature to find MCI files. They're many of them. Does this means that I have the neccessary MCI for management facilities already?
0
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6234072
imho MCI -- default standart feature in Win2000 and WinMe...
If you find some MCI files on your computer -- MCI installed
sorry but I cannot tell about MCI using my low english knowledge :)

Andrey
0
 

Author Comment

by:Dawn_rico
ID: 6234193
Andrey ,

I'm sure your language is good, else we won't be able to intereact so well... ;) Since my server resides on win2000 platform, I'll take it and hope hard that MCI already exists... but do I need this on my client?

thanks ...  
0
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6234213
no
0
 
LVL 2

Accepted Solution

by:
Andrey_Kulik earned 205 total points
ID: 6234219
:)
very short comment

Best regards
Andrey
0
 

Author Comment

by:Dawn_rico
ID: 6234725
Thanks for offering ur solutions ... pls continue to offer your help too ;) I'm still at the beginning of MQSeries.

Dawn.
0
 

Author Comment

by:Dawn_rico
ID: 6234728
Andrey,

Pls look at this qn too : "MQSeries - MQ base Java Version 5.1". I can't find the link in IBM to download this file and I really need it for Java programming.

Thanks ...

Dawn.  
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now