How to Send a Message to an Apache ActiveMQ Topic with SISC

(import s2j)

(define-java-class <javax.jms.session>)

(define-java-class <org.apache.activemq.active-m-q-connection-factory>)

(define connFactory (java-new <org.apache.activemq.active-m-q-connection-factory>))

(define createConnection (generic-java-method '|createConnection|))

(define conn (createConnection connFactory))

(define createSession (generic-java-method '|createSession|))

(define autoAcknowledge (generic-java-field-accessor '|AUTO_ACKNOWLEDGE|))

(define sess (createSession conn (->jboolean #f) (autoAcknowledge (java-null <javax.jms.session>))))

(define createTopic (generic-java-method '|createTopic|))

(define dest (createTopic sess (->jstring "SampleTopic")))

(define createProducer (generic-java-method '|createProducer|))

(define prod (createProducer sess dest))

(define send (generic-java-method '|send|))

(define createTextMessage (generic-java-method '|createTextMessage|))

(define msg (createTextMessage sess (->jstring "Simples Assim")))

(send prod msg)

(define close (generic-java-method '|close|)) 

(close conn)

Published by:

Fernando Ribeiro

Experienced tech executive with a 24-year track record in enterprise computing. Leading AWS's professional services application modernization division in Brazil. He's held diverse roles including management, solutions architecture, sales consultancy, and full-stack development at major players like Oracle, Red Hat, and IBM. Fernando also contributes to open source and writes about emerging technologies. The views expressed here are his own and do not necessarily reflect the views of AWS.

Categories SoftwareTags , , , , , , , Leave a comment

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.