How to Receive a Message from an Apache ActiveMQ Topic with GNU Smalltalk

W/o Durability

PackageLoader fileInPackage: 'TCP'!

socket := TCP.Socket remote: 'localhost' port: 61613.

'CONNECT', Character nl asString, Character nl asString, Character nul asString displayOn: socket.

socket flush.

line := socket nextLine.

[line ~= Character nul asString] whileTrue: [line := socket nextLine]. "Skip the CONNECTED frame"

'SUBSCRIBE', Character nl asString, 'destination:/topic/SampleTopic', Character nl asString, 'ack:auto', Character nl asString, Character nl asString, Character nul asString displayOn: socket.

socket flush.

line := socket nextLine.

[line ~= ''] whileTrue: [line := socket nextLine]. "Seek to the body of the MESSAGE frame"

Transcript show: socket nextLine, Character nl asString.

'DISCONNECT', Character nl asString, Character nl asString, Character nul asString displayOn: socket.

socket close!

W/ Durability

PackageLoader fileInPackage: 'TCP'!

socket := TCP.Socket remote: 'localhost' port: 61613.

'CONNECT', Character nl asString, 'client-id:SampleClient', Character nl asString, Character nl asString, Character nul asString displayOn: socket.

socket flush.

line := socket nextLine.

[line ~= Character nul asString] whileTrue: [line := socket nextLine]. "Skip the CONNECTED frame"

'SUBSCRIBE', Character nl asString, 'destination:/topic/SampleTopic', Character nl asString, 'ack:auto', Character nl asString, 'activemq.subscriptionName:SampleSubscription', Character nl asString, Character nl asString, Character nul asString displayOn: socket.

socket flush.

line := socket nextLine.

[line ~= ''] whileTrue: [line := socket nextLine]. "Seek to the body of the MESSAGE frame"

Transcript show: socket nextLine, Character nl asString.

'DISCONNECT', Character nl asString, Character nl asString, Character nul asString displayOn: socket.

socket close!
Advertisements

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

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