Last active
March 14, 2019 09:44
-
-
Save riyafa/00a0673b12d18f59a283b1eace441f56 to your computer and use it in GitHub Desktop.
A point to point consumer 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/io; | |
@artemis:ServiceConfig{ | |
queueConfig:{ | |
queueName:"my_queue" | |
} | |
} | |
service artemisConsumer on new artemis:Listener({host:"localhost", port:61616}){ | |
resource function onMessage(artemis:Message message) returns error? { | |
var payload = message.getPayload(); | |
if(payload is map<string>){ | |
io:println("map<string>"); | |
} else if(payload is map<int>){ | |
io:println("int map"); | |
} else if (payload is string){ | |
io:println("string"); | |
} else if(payload is byte[]){ | |
io:println("byte[]"); | |
} else if(payload is map<byte[]>){ | |
io:println("map<byte[]>"); | |
} else if(payload is map<boolean>){ | |
io:println("map<boolean>"); | |
} else if(payload is map<float>){ | |
io:println("map<float>"); | |
} else if(message.getType()==artemis:STREAM){ | |
io:println("stream"); | |
io:WritableByteChannel destinationChannel = io:openWritableFile("./tech.pdf"); | |
check message.saveToWritableByteChannel(destinationChannel); | |
} | |
io:println(payload); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment