MessageQueue Series connection

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 ..
Dawn_ricoAsked:
Who is Participating?
 
Andrey_KulikCommented:
:)
very short comment

Best regards
Andrey
0
 
Dawn_ricoAuthor Commented:
hi,

You may have found some useful contents to setup the connection using MQseries. Pls kindly do tell me too, thanks...
0
 
Andrey_KulikCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Dawn_ricoAuthor Commented:
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
 
Andrey_KulikCommented:
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
 
Dawn_ricoAuthor Commented:
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
 
Dawn_ricoAuthor Commented:
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
 
Dawn_ricoAuthor Commented:
I'm now exploring on the creation of the client and server environment.
0
 
Andrey_KulikCommented:
OK :)
 u r welcome

Andrey
0
 
Dawn_ricoAuthor Commented:
I'm now exploring on the creation of the client and server environment.
0
 
Dawn_ricoAuthor Commented:
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
 
Dawn_ricoAuthor Commented:
may I know where should I go to configure?
0
 
Dawn_ricoAuthor Commented:
I've solved this by using another login with administrator rights, that auto give me rights to access the Explorer too.
0
 
Andrey_KulikCommented:
I havenot this problem... I know that your Windows should has preinstall MCI for management facilities. And that's all

Andrey
0
 
Dawn_ricoAuthor Commented:
May I know what's MCI? This will be my last question.

0
 
Dawn_ricoAuthor Commented:
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
 
Andrey_KulikCommented:
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
 
Dawn_ricoAuthor Commented:
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
 
Andrey_KulikCommented:
no
0
 
Dawn_ricoAuthor Commented:
Thanks for offering ur solutions ... pls continue to offer your help too ;) I'm still at the beginning of MQSeries.

Dawn.
0
 
Dawn_ricoAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.