[英]Is it possible to implement JMS, Spring and Tibco EMS on a standalone Java app?
所以這是我的問題!
我有一個帶有身份驗證的Tibco EMS主題
我有一個獨立的應用程序,我想發布並使用此消息
我想通過Springs JMSTemplate,Listener等來做到這一點。
前聽眾:
public class ExampleListener implements MessageListener {
public void onMessage(Message message) {
if (message instanceof TextMessage) {
try {
//TODO DAO interface to write to db
System.out.println(((TextMessage) message).getText());
} catch (JMSException e) {
throw new RuntimeException(e);
}
} else {
throw new IllegalArgumentException(
"Message must be of type TestMessage");
}
}
}
樣本發布者:
import org.springframework.jms.core.JmsTemplate;
public class ExampleProducer {
私人JmsTemplate jmsTemplate;
public ExampleProducer(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}
public void sendMessage() {
jmsTemplate.convertAndSend("Example Message");
}
}
and here's some of the properties:
jms.jndi.initialContextFactory = com.tibco.tibjms.naming.TibjmsInitialContextFactory jms.jndi.urlPkgs = com.tibco.tibjms.naming
jms.jndi.providerUrl = tibjmsnaming:/ * *** .net: ***
這可能嗎?
謝謝
是。 這是一個相當典型的設置。
您只需要一些額外的配置來補償您不在Java EE環境中運行的事實。 因此,您沒有通過資源引用進行簡單的JNDI查找。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.