Created
March 11, 2019 08:08
-
-
Save riyafa/b647186dfc256778f2c61c080877021a to your computer and use it in GitHub Desktop.
A publisher subscriber (pub-sub) producer using ActiveMQ Artemis connector for Ballerina
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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