Created
July 28, 2012 21:36
-
-
Save mplacona/3194899 to your computer and use it in GitHub Desktop.
RabbitMQ ColdFusion "Add to queue example"
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
<cfscript> | |
QueueName = "QTransactions"; | |
durable = true; | |
loadPaths = arrayNew(1); | |
loadPaths[1] = expandPath("lib/rabbitmq-java-client-bin-2.8.4/rabbitmq-client.jar"); | |
// load jars | |
javaLoader = createObject("component", "lib.javaloader.JavaLoader").init(loadPaths); | |
// Create factory | |
factory = javaloader.create("com.rabbitmq.client.ConnectionFactory").init(); | |
factory.setHost("127.0.0.1"); | |
// Create properties | |
messageProperties = javaloader.create("com.rabbitmq.client.MessageProperties").init(); | |
props = messageProperties.PERSISTENT_TEXT_PLAIN; | |
// Connect | |
connection = factory.newConnection(); | |
channel = connection.createChannel(); | |
// Declare queue | |
channel.QueueDeclare(QueueName, durable, false, false, createJavaNull()); | |
// Create string | |
objStringByteArray = createByteArray("this is my CF message 12345"); | |
// Publish | |
try{ | |
channel.basicPublish("", QueueName, props, objStringByteArray); | |
} | |
finally{ | |
// Close connection | |
channel.close(); | |
connection.close(); | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do u have a sample of how to consume from the queue?