Skip to content

qie.sendToChannelQueue

Signature: qie.sendToChannelQueue(channelQueueId, content, encoding*, returnAsByteArray*)

Returns: Object acknowledgement - an acknowledgement if the channel this was sent to is configured to send acknowledgements or 'null' if the channel is not configured to send acknowledgements. The type will be a String unless the parameter returnAsByteArray is true, then it will return as a byte[].

Sends a message to another channel.

Parameters

Type Name Description Default
String channelQueueId the channel's queue ID to send to
String or byte[] content the message content to send
String encoding* (optional) the character encoding for this message UTF-8
Boolean returnAsByteArray* (optional) changes the return type to be a byte[] instead of a String false

Example

/* Note that you can only send messages to a channel of type "Channel Queue" */

// Example: content as String, returns String (default behavior)
var ackString = qie.sendToChannelQueue(
   'queueIdNotChannelId',
   '{"type":"I was added from a channel"}'
);
// ackString is a String when optional parameter returnAsByteArray is not specified or is false

// Example: content as byte[], returns String
var contentBytes = message.getBytes(); // the current message as a raw byte[]
ackString = qie.sendToChannelQueue(
   'queueIdNotChannelId',
   contentBytes
);
// ackString is still a String when returnAsByteArray is false

// Example: content as String, returns byte[]
var ackBytes = qie.sendToChannelQueue(
   'queueIdNotChannelId',                    // channelQueueId
   '{"type":"I was added from a channel"}',  // content
   'UTF-8',                                  // encoding
   true                                      // returnAsByteArray
);
// ackBytes is a byte[] because returnAsByteArray = true

// Example: content as byte[], returns byte[]
ackBytes = qie.sendToChannelQueue(
   'queueIdNotChannelId',                    // channelQueueId
   contentBytes,                             // content
   'UTF-8',                                  // encoding
   true                                      // returnAsByteArray
);
// ackBytes is a byte[] because returnAsByteArray = true