简体   繁体   English

是否可以在独立的Java应用程序上实现JMS,Spring和Tibco EMS?

[英]Is it possible to implement JMS, Spring and Tibco EMS on a standalone Java app?

So here's my problem! 所以这是我的问题!

I Have a Tibco EMS topic with authentication 我有一个带有身份验证的Tibco EMS主题

I have a standalone app I'd like to pub and consume messages from this 我有一个独立的应用程序,我想发布并使用此消息

And I'd like to do this through Springs JMSTemplate, Listener etc. 我想通过Springs JMSTemplate,Listener等来做到这一点。

Ex 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");
    }
} 

} }

Sample publisher: 样本发布者:

import org.springframework.jms.core.JmsTemplate;

public class ExampleProducer { public class ExampleProducer {

private JmsTemplate 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.initialContextFactory = com.tibco.tibjms.naming.TibjmsInitialContextFactory jms.jndi.urlPkgs = com.tibco.tibjms.naming

jms.jndi.providerUrl=tibjmsnaming:/ * *** jms.jndi.providerUrl = tibjmsnaming:/ * *** .net: *** .net: ***

Is this possible? 这可能吗?

Thanks 谢谢

Yes. 是。 This is a fairly typical setup. 这是一个相当典型的设置。

You will just require some extra configuration to compensate for the fact that you are not operating inside a Java EE environment. 您只需要一些额外的配置来补偿您不在Java EE环境中运行的事实。 Thus you don't have simple JNDI lookups via resource refs. 因此,您没有通过资源引用进行简单的JNDI查找。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM