Я пытаюсь установить соединение с внешним сервером, чтобы я мог подписаться на удаленную тему, но получаю сообщение об ошибке:
java.util.EmptyStackException
tr: com.example.jms.TopicReceive@5729e7ge
at weblogic.utils.StackTraceDisabled.unknownMethod()
На самом деле, соединение происходит, но я не могу получить от линии, где я смотрю в теме. Что я должен сделать, чтобы получить правильное соединение с внешним сервером и подписаться на пакет тем com.example.jms;
import java.util.*;
import javax.naming.*;
import javax.jms.*;
import javax.rmi.PortableRemoteObject;
import org.springframework.context.annotation.Bean;
public class TopicReceive implements MessageListener {
private TopicConnectionFactory tconFactory;
private TopicConnection tcon;
private TopicSession tsession;
private TopicSubscriber tsubscriber;
private Topic topic;
public boolean quit = false;
public void onMessage(Message msg)
{
try {
String msgText;
if (msg instanceof TextMessage) {
msgText = ((TextMessage)msg).getText();
try {
System.out.println("Message Received" +msgText);
} catch (Exception e) {
}finally{
}
} else {
msgText = msg.toString();
}
DatabaseConn.saveJSON(msgText);
DatabaseConn.DatabaseConnection();
if (msgText.equalsIgnoreCase("quit")) {
synchronized(this) {
quit = true;
this.notifyAll();
System.out.println("no message found");
}
}
} catch (JMSException jmse) {
}
}
public void init(Context ctx)
{
try {
TopicConnectionFactory connectionFactory = (TopicConnectionFactory) ctx.lookup("jms/tdefCF");
tcon = connectionFactory.createTopicConnection();
//tcon.setClientID("test1");
tsession = tcon.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
topic = (Topic) ctx.lookup("jms/weblogictopic");
tsubscriber = tsession.createSubscriber(topic);
tsubscriber.setMessageListener(this);
tcon.start();
} catch (Exception e) {
e.printStackTrace();
}
}
public void close() throws JMSException {
tsubscriber.close();
tsession.close();
tcon.close();
}
//HERE WE ARE MAKING CONNECTION TO WEBLOGIC
@Bean
public static InitialContext getInitialContext() throws NamingException
{
System.out.println("Message method");
Hashtable<String, String> h = new Hashtable<String, String>();
h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL,"t3://localhost:7001");
return new InitialContext(h);
}
}