Solved

MessageQueue Series connection

Posted on 2001-06-18
21
287 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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
 

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java Jpanels and Jframe 8 33
jar file executable 12 51
servlet web applications   metadata-complete="true" or false 3 39
eclipse console opening separately 2 19
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

770 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