Skip to content

Need possibility to send byte-arrays to rabbitMq #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/groovy/org/grails/rabbitmq/RabbitDynamicMethods.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.grails.rabbitmq
import org.springframework.amqp.core.Address
import org.springframework.amqp.core.Message
import org.springframework.amqp.core.MessagePostProcessor
import org.springframework.amqp.core.MessageProperties

/**
* Class for applying the dynamic rabbitSend() and rabbitRpcSend() methods to
Expand All @@ -12,6 +13,7 @@ class RabbitDynamicMethods {

static void applyAllMethods(target, ctx) {
applyRabbitSend(target, ctx)
applyRabbitSendByteArray(target, ctx)
// applyRabbitRpcSend(target, ctx)
}

Expand All @@ -26,6 +28,15 @@ class RabbitDynamicMethods {
}
}

static void applyRabbitSendByteArray(target, ctx) {
target.metaClass.rabbitSendByteArray = { Object[] args ->
String routingKey = args[0]
MessageProperties messageProperties = new MessageProperties()
Message message = new Message(args[1], messageProperties)
ctx.rabbitTemplate.send(routingKey, message)
}
}

static void applyRabbitRpcSend(target, ctx) {
target.metaClass.rabbitRpcSend = { Object[] args ->
// Last argument is a reply queue name
Expand Down