How to Receive a Message from an Apache ActiveMQ Topic with Jekejeke Prolog

W/o Durability

foreign(create_connection_factory/1, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createConnectionFactory),

foreign(create_connection/2, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createConnection('Object')),

foreign(create_session/4, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createSession('Object', 'String', 'Integer')),

foreign(create_topic/3, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createTopic('Object', 'String')),

foreign(create_consumer/3, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createConsumer('Object', 'Object')),

foreign(start_connection/1, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', startConnection('Object')),

foreign(receive_message/2, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', receiveMessage('Object')),

foreign(print_message/1, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', printMessage('Object')),

foreign(close_connection/1, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', closeConnection('Object')),

create_connection_factory(ConnFactory),

create_connection(ConnFactory, Conn),

create_session(Conn, 'false', 1, Sess),

create_topic(Sess, 'SampleTopic', Dest),

create_consumer(Sess, Dest, Cons),

start_connection(Conn),

receive_message(Cons, Msg),

current_prolog_flag(sys_disp_output, Out),

sys_write(Out, Msg),

close_connection(Conn).

W/ Durability

foreign(create_connection_factory/1, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createConnectionFactory),

foreign(create_connection/2, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createConnection('Object')),

foreign(set_client_id/2, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', setClientID('Object', 'String')),

foreign(create_session/4, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createSession('Object', 'String', 'Integer')),

foreign(create_topic/3, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createTopic('Object', 'String')),

foreign(create_durable_subscriber/4, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', createDurableSubscriber('Object', 'Object', 'String')),

foreign(start_connection/1, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', startConnection('Object')),

foreign(receive_message/2, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', receiveMessage('Object')),

foreign(print_message/1, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', printMessage('Object')),

foreign(close_connection/1, 'br.eti.fernandoribeiro.jekpro.activemq.ActiveMQLibrary', closeConnection('Object')),

create_connection_factory(ConnFactory),

create_connection(ConnFactory, Conn),

set_client_id(Conn, 'SampleClient'),

create_session(Conn, 'false', 1, Sess),

create_topic(Sess, 'SampleTopic', Dest),

create_durable_subscriber(Sess, Dest, 'SampleSubscription', Cons),

start_connection(Conn).

receive_message(Cons, Msg),

current_prolog_flag(sys_disp_output, Out),

sys_write(Out, Msg),

close_connection(Conn).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s