سؤال

TopicConnection.createTopicSession hangs sometimes in one env and it is working fine in another env.

Env: JBoss5.1, jdk1.6.0_45, RHEL 5.8, Dell VM-ware

The below is the code.

TopicConnectionFactory _factory = (TopicConnectionFactory)context.lookup("java:JmsXA");

TopicConnection _connection = _factory.createTopicConnection();

TopicSession _session = _connection.createTopicSession(false, 1); --This is the place where it hangs.

Topic _topic = (Topic)context.lookup(s);

TopicPublisher _publisher = _session.createPublisher(_topic);

_connection.start();

I feel that it could be some server configuration related issue. Kindly provide your suggestion.

هل كانت مفيدة؟

المحلول

It is a race condition between initialized process by Jboss messaging and process by Web application.

This program is getting executed during service startup. It is working fine now after thread sleep of 1sec.

Before Change

TopicConnectionFactory _factory = (TopicConnectionFactory)context.lookup("java:JmsXA");

TopicConnection _connection = _factory.createTopicConnection();

TopicSession _session = _connection.createTopicSession(false, 1); //This is the place where it hanged.

Topic _topic = (Topic)context.lookup(s);

TopicPublisher _publisher = _session.createPublisher(_topic);

_connection.start();

After Change

TopicConnectionFactory _factory = (TopicConnectionFactory)context.lookup("java:JmsXA");

TopicConnection _connection = _factory.createTopicConnection();

Thread.sleep(1000); //After introducing this line, it is working fine.

TopicSession _session = _connection.createTopicSession(false, 1);

Topic _topic = (Topic)context.lookup(s);

TopicPublisher _publisher = _session.createPublisher(_topic);

_connection.start();

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top