Tag Archives: OpenWire

How to Receive a Message from an Apache ActiveMQ Topic with Ioke

W/o Durability

import javax:jms:Session

import org:apache:activemq:ActiveMQConnectionFactory

connFactory = ActiveMQConnectionFactory new

conn = connFactory createConnection

sess = conn createSession(false, Session field:AUTO_ACKNOWLEDGE)

dest = sess createTopic("SampleTopic")

cons = sess createConsumer(dest)

conn start

msg = cons receive

msg println

conn close

W/ Durability

import javax:jms:Session

import org:apache:activemq:ActiveMQConnectionFactory

connFactory = ActiveMQConnectionFactory new

conn = connFactory createConnection

conn setClientID("SampleClient")

sess = conn createSession(false, Session field:AUTO_ACKNOWLEDGE)

dest = sess createTopic("SampleTopic")

cons = sess createDurableSubscriber(dest, "SampleSubscription")

conn start

msg = cons receive

msg println

conn close
Advertisements

How to Receive a Message from an Apache ActiveMQ Queue with Ioke

import javax:jms:Session

import org:apache:activemq:ActiveMQConnectionFactory

connFactory = ActiveMQConnectionFactory new

conn = connFactory createConnection

sess = conn createSession(false, Session field:AUTO_ACKNOWLEDGE)

dest = sess createQueue("SampleQueue")

cons = sess createConsumer(dest)

conn start

msg = cons receive

msg println

conn close

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

import javax:jms:Session

import org:apache:activemq:ActiveMQConnectionFactory

connFactory = ActiveMQConnectionFactory new

conn = connFactory createConnection

sess = conn createSession(false, Session field:AUTO_ACKNOWLEDGE)

dest = sess createTopic("SampleTopic")

prod = sess createProducer(dest)

msg = sess createTextMessage("Simples Assim")

prod send(msg)

conn close

How to Send a Message to an Apache ActiveMQ Queue with Ioke

import javax:jms:Session

import org:apache:activemq:ActiveMQConnectionFactory

connFactory = ActiveMQConnectionFactory new

conn = connFactory createConnection

sess = conn createSession(false, Session field:AUTO_ACKNOWLEDGE)

dest = sess createQueue("SampleQueue")

prod = sess createProducer(dest)

msg = sess createTextMessage("Simples Assim")

prod send(msg)

conn close

How to Receive a Message from an Apache ActiveMQ Topic with OCaml-Java

W/o Durability

open Java

open JavaString

open Package'java'io

open Package'javax'jms

open Package'org'apache'activemq

let conn_factory = Java.make "ActiveMQConnectionFactory()" ()

let conn = call "ConnectionFactory.createConnection()" conn_factory

let sess = call "Connection.createSession(boolean, int)" conn false (get "Session.AUTO_ACKNOWLEDGE" ())

let dest = call "Session.createTopic(String)" sess (of_string "SampleTopic")

let cons = call "Session.createConsumer(Destination)" sess dest

let _ = call "Connection.start()" conn

let msg = call "MessageConsumer.receive()" cons

let _ = call "PrintStream.println(Object)" (get "System.out" ()) msg

let _ = call "Connection.close()" conn

W/ Durability

open Java

open JavaString

open Package'java'io

open Package'javax'jms

open Package'org'apache'activemq

let conn_factory = Java.make "ActiveMQConnectionFactory()" ()

let conn = call "ConnectionFactory.createConnection()" conn_factory

let _ = call "Connection.setClientID(String)" conn (of_string "SampleClient")

let sess = call "Connection.createSession(boolean, int)" conn false (get "Session.AUTO_ACKNOWLEDGE" ())

let dest = call "Session.createTopic(String)" sess (of_string "SampleTopic")

let cons = call "Session.createDurableSubscriber(Topic, String)" sess dest (of_string "SampleSubscription")

let _ = call "Connection.start()" conn

let msg = call "MessageConsumer.receive()" cons

let _ = call "PrintStream.println(Object)" (get "System.out" ()) msg

let _ = call "Connection.close()" conn

How to Receive a Message from an Apache ActiveMQ Queue with OCaml-Java

open Java

open JavaString

open Package'java'io

open Package'javax'jms

open Package'org'apache'activemq

let conn_factory = Java.make "ActiveMQConnectionFactory()" ()

let conn = call "ConnectionFactory.createConnection()" conn_factory

let sess = call "Connection.createSession(boolean, int)" conn false (get "Session.AUTO_ACKNOWLEDGE" ())

let dest = call "Session.createQueue(String)" sess (of_string "SampleQueue")

let cons = call "Session.createConsumer(Destination)" sess dest

let _ = call "Connection.start()" conn

let msg = call "MessageConsumer.receive()" cons

let _ = call "PrintStream.println(Object)" (get "System.out" ()) msg

let _ = call "Connection.close()" conn