Skip to content

Instantly share code, notes, and snippets.

@riyafa
Created March 11, 2019 08:08
Show Gist options
  • Save riyafa/b647186dfc256778f2c61c080877021a to your computer and use it in GitHub Desktop.
Save riyafa/b647186dfc256778f2c61c080877021a to your computer and use it in GitHub Desktop.
A publisher subscriber (pub-sub) producer using ActiveMQ Artemis connector for Ballerina
import ballerina/artemis;
import ballerina/log;
import ballerina/io;
public function main() {
artemis:Producer prod = new({host:"localhost", port:61616}, "my_address", addressConfig = {routingType:artemis:MULTICAST});
map<string> msg = {"Hello":"World", "some":"world"};
byte[6] vals = [1,2,2,3,3,2];
io:ReadableByteChannel ch = io:openReadableFile("/home/riyafa/abc.pdf");
var err = prod->send(vals);
err = prod->send(msg);
err = prod->send(ch);
if(err is error){
log:printError("Error occurred sending message", err = err);
}
if(!prod.isClosed()) {
err = prod->close();
if(err is error){
log:printError("Error occurred closing producer", err = err);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment