File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Properties in InitialContext for, MQ5.3 server remotely Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Properties in InitialContext for, MQ5.3 server remotely" Watch "Properties in InitialContext for, MQ5.3 server remotely" New topic

Properties in InitialContext for, MQ5.3 server remotely

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
What are the properties to be set in Initial Context for using from Sun's JMS tutorial?

I am using MQ5.3 and the server machine is remote from my local computer. I am using it as Proof of Concept for simplest form of P2P messaging.

My QueueName is: QueueName
QueManagerName: QMDOCDAA

MQ Server is set as:

Channel is: SVRCONN
Server Name: BNDOC-AP01D
Port: 1414

Which API of InitialContext should I use?

bind(Name, Object)
bind(String, Object)
addToEnvironment(String, Object)

Please give me an example, using thge paramets above so that I can run

I am copying from Sun's tutorial below:

import javax.jms.*;
import javax.naming.*;

public class SimpleQueueReceiver {

* Main method.
* @param args the queue used by the example
public static void main(String[] args) {
String queueName = "myQueue";
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueReceiver queueReceiver = null;
TextMessage message = null;

* Create a JNDI API InitialContext object if none exists
* yet.
try {
jndiContext = new InitialContext();

} catch (NamingException e) {
System.out.println("Could not create JNDI API " +
"context: " + e.toString());

* Look up connection factory and queue. If either does
* not exist, exit.
try {
queueConnectionFactory = (QueueConnectionFactory)
queue = (Queue) jndiContext.lookup(queueName);
} catch (NamingException e) {
System.out.println("JNDI API lookup failed: " +

* Create connection.
* Create session from connection; false means session is
* not transacted.
* Create receiver, then start message delivery.
* Receive all text messages from queue until
* a non-text message is received indicating end of
* message stream.
* Close connection.
try {
queueConnection =
queueSession =
queueReceiver = queueSession.createReceiver(queue);
while (true) {
Message m = queueReceiver.receive(1);
if (m != null) {
if (m instanceof TextMessage) {
message = (TextMessage) m;
System.out.println("Reading message: " +
} else {
} catch (JMSException e) {
System.out.println("Exception occurred: " +
} finally {
if (queueConnection != null) {
try {
} catch (JMSException e) {}
Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
I am using WSAD5.1.1 as IDE for Proof of concept. Application will be deployed in WAS as proof of concept.
I agree. Here's the link:
subject: Properties in InitialContext for, MQ5.3 server remotely
jQuery in Action, 3rd edition