简体   繁体   中英

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

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.

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 {

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

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. Thus you don't have simple JNDI lookups via resource refs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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