|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Am able to send the message but not able to receive it.. |
« View previous topic :: View next topic » |
Author |
Message
|
SG |
Posted: Mon Mar 11, 2002 8:14 am Post subject: |
|
|
Newbie
Joined: 10 Mar 2002 Posts: 2
|
hi
I am having this strange prob for last one day. Till yesterday, I was able to send and recieve messages properly with this code.
MQEnvironment.hostname = "usnt_loanergaur";
//MQEnvironment.channel = "stwdReceiverChanel";
MQEnvironment.port = 1414;
// get JNDI context
InitialContext ctx = new InitialContext();
// get local JNDI environment
Context env = (Context) ctx.lookup("java:comp/env");
// get queue connection factory
QueueConnectionFactory qcf = (QueueConnectionFactory) env.lookup("myQCF");
// create a connection
QueueConnection qc = qcf.createQueueConnection();
// create a session.
QueueSession session1 =
qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
// get queue
Queue q = (Queue) env.lookup("myQ");
// create a queue sender for the queue
QueueSender queueSender = session1.createSender(q);
// Create a QueueReceiver in the same way
out.println( "Creating a QueueReceiver");
QueueReceiver queueReceiver = session1.createReceiver(q);
// The session is used to create messages, so create an empty
// TextMessage and fill it with some data
String outString = "khsadfjksdf";
out.println( "Creating a TextMessage" );
TextMessage outMessage = session1.createTextMessage();
//out.println("Adding Text");
outMessage.setText(outString);
// Ask the QueueSender to send the message we have created
//out.println( "Sending the message to " + q.getQueueName() );
queueSender.send(outMessage);
// Now use the QueueReceiver to retrieve the message, blocking
// for a maximum of 1000ms. The receive call returns when the
// message arrives, or after 1000ms, whichever is sooner
out.println( "Reading the message back again" );
Message inMessage = queueReceiver.receive(10000);
But, after creating a new queuemanager and a new queue in it, I am not able to recieve messages. Its sending messages properly. Any idea..
thanks in advance
SG |
|
Back to top |
|
 |
kolban |
Posted: Mon Mar 11, 2002 5:55 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2001 Posts: 1072 Location: Fort Worth, TX, USA
|
What is the nature of the error (if any) reported. I think we will need some additional information to assist. |
|
Back to top |
|
 |
abmanesh |
Posted: Tue Mar 12, 2002 6:31 am Post subject: |
|
|
Apprentice
Joined: 06 Nov 2001 Posts: 39
|
Hi,
One obvious thing I noticed in the code was that, after obtaining a QueueConnection the connection is not started. In the JMS implementation the Connections are created in a stopped mode. You have to start them explicitly using the start() method on the Connection object. |
|
Back to top |
|
 |
SG |
Posted: Tue Mar 12, 2002 6:46 am Post subject: |
|
|
Newbie
Joined: 10 Mar 2002 Posts: 2
|
yes
start on conn was missing
thats w3hat I was wondering that what can be missing as I have trie dit before.
but I am still wondering that how was I able to send the messages though..
thanks for help.
SG |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|