dcsimg
an asynchronous receiver doesn't wait a message on 6.1.0
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Tokoma_Tabashi
Posted On:   Wednesday, July 5, 2006 12:41 AM

On 6.1.0, the asynchronous receiver below doesn't wait a message and stops soon after had connected to swiftmq without an exception. I confirmed this waited a message on 5.2.6. import java.util.Hashtable; import javax.jms.*; import javax.naming.Context; import javax.naming.InitialContext; public class TestReceiver implements MessageListener, ExceptionListener { TestReceiver() throws Exception { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.swiftmq.jndi.InitialContextFactoryImpl"); env.put(Context.PROVIDER_URL, "smqp://localhost:8900/timeout=10000"); // update port num to 8900 Context jndiContext = n   More>>

On 6.1.0, the asynchronous receiver below doesn't wait a message and stops soon after had connected to swiftmq without an exception. I confirmed this waited a message on 5.2.6.

			
import java.util.Hashtable;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;

public class TestReceiver implements MessageListener, ExceptionListener {

TestReceiver() throws Exception {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.swiftmq.jndi.InitialContextFactoryImpl");
env.put(Context.PROVIDER_URL, "smqp://localhost:8900/timeout=10000"); // update port num to 8900
Context jndiContext = new InitialContext(env);
TopicConnectionFactory factory = (TopicConnectionFactory) jndiContext
.lookup("TopicConnectionFactory");
TopicConnection connection = factory.createTopicConnection();
TopicSubscriber subscriber = connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE).createSubscriber(
(Topic) jndiContext.lookup("TestTopic"));
subscriber.setMessageListener(this);
connection.start();
}

public void onMessage(Message message) {
try {
System.out.println(
"----- message received:["
+ message.getJMSMessageID()
+ "] -----");
} catch (Exception e) {
e.printStackTrace();
}
}

public void onException(JMSException exception) {
exception.printStackTrace();
System.out.println("--- LinkedException ---");
exception.getLinkedException().printStackTrace();
}

public static void main(String[] args) {
try {
new TestReceiver();
} catch (Exception e) {
e.printStackTrace();
}
}
}


Does anyone have any idea to make the asynchronous receiver wait a message on 6.1.0 ?



Thank you in advance.



Regards,

Tokoma
   <<Less

Re: an asynchronous receiver doesn't wait a message on 6.1.0

Posted By:   Tokoma_Tabashi  
Posted On:   Wednesday, July 5, 2006 01:11 AM

Let me correct java code in my message.
I forgot to write the line below in the costructor of "TestReceiver".


connection.setExceptionListener(this);


When the updated program was executed, any exception didn't occur. Then it doesn't wait a message and stops soon.



Regards,

Tokoma
About | Sitemap | Contact