W/o Durability
import std.socket : InternetAddress, TcpSocket; import std.socketstream : SocketStream; import std.stdio; import std.stream : Stream; void main() { Stream stream = new SocketStream(new TcpSocket(new InternetAddress("localhost", 61613))); stream.writeString("CONNECT\n\n\0"); auto line = stream.readLine(); /** Skip the CONNECTED frame */ while (line != "\0") line = stream.readLine(); stream.writeString("SUBSCRIBE\ndestination:/topic/SampleTopic\n\nack:auto\n\n\0"); line = stream.readLine(); /** Seek to the body of the MESSAGE frame */ while (line != "") line = stream.readLine(); writeln(stream.readLine()); stream.writeString("DISCONNECT\n\n\0"); stream.close(); }
W/ Durability
import std.socket : InternetAddress, TcpSocket; import std.socketstream : SocketStream; import std.stdio; import std.stream : Stream; void main() { Stream stream = new SocketStream(new TcpSocket(new InternetAddress("localhost", 61613))); stream.writeString("CONNECT\nclient-id:SampleClient\n\n\0"); auto line = stream.readLine(); /** Skip the CONNECTED frame */ while (line != "\0") line = stream.readLine(); stream.writeString("SUBSCRIBE\ndestination:/topic/SampleTopic\n\nack:auto\nactivemq.subscriptionName:SampleSubscription\n\n\0"); line = stream.readLine(); /** Seek to the body of the MESSAGE frame */ while (line != "") line = stream.readLine(); writeln(stream.readLine()); stream.writeString("DISCONNECT\n\n\0"); stream.close(); }
Leave a comment