November 2018
Intermediate to advanced
388 pages
9h 5m
English
We demonstrated the transactions in the point-to-point messaging model. The same can be enabled in the publish-subscribe model, as shown here:
class Publisher { @Inject private lateinit var initialContext: InitialContext fun publishMessage(message: String) { val topic = initialContext .lookup("jms/Topic") as Topic val connectionFactory = initialContext .lookup("jms/__defaultConnectionFactory") as ConnectionFactory val jmsContext = connectionFactory .createContext(JMSContext.SESSION_TRANSACTED) jmsContext.createProducer() .send(topic, message) jmsContext.commit() }}
The Subscriber model is as follows:
class Subscriber { @Inject private lateinit var initialContext: InitialContext ...
Read now
Unlock full access