能否在独立的Java应用程序上实现JMS、Spring和Tibco EMS?

3

以下是我的问题!

我有一个带有身份验证的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;

公共类示例生产者 {

私有 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:***

这个可行吗?谢谢。

1个回答

1

是的,这是一个相当典型的设置。

您只需要进行一些额外的配置来弥补您不在Java EE环境中运行的事实。因此,您无法通过资源引用进行简单的JNDI查找。


请问您能否提供更多信息或指向一些好的在线示例。我原以为这是相当典型的,但似乎没有任何使用tibco的资料!此外,JNDI问题正是我预期的主要问题。感谢您的帮助! - Michael W
我自己从未使用过Tibco,但你要找的通常被称为“轻客户端”。配置和jar要求将针对供应商进行特定设置。 - Robin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接