所以这是我的问题!
我有一个带有身份验证的 Tibco EMS 主题
我有一个独立的应用程序,我想发布和使用来自该应用程序的消息
我想通过 Springs JMSTemplate、Listener 等来做到这一点
Ex 监听器:
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)类 ExampleProducer {
私有(private)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 查找。
关于java - 是否可以在独立的 Java 应用程序上实现 JMS、Spring 和 Tibco EMS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5980655/