How to use the rhea.message function in rhea

To help you get started, we’ve selected a few rhea examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-event-hubs-node / dist / lib / eventHubSender.js View on Github external
}
                if (!this._isOpen()) {
                    debug("Acquiring lock %s for initializing the session, sender and " +
                        "possibly the connection.", this.senderLock);
                    yield utils_1.defaultLock.acquire(this.senderLock, () => { return this._init(); });
                }
                debug("[%s] Sender '%s', trying to send EventData[]: %O", this._context.connectionId, this.name, datas);
                const messages = [];
                // Convert EventData to AmqpMessage.
                for (let i = 0; i < datas.length; i++) {
                    const message = eventData_1.EventData.toAmqpMessage(datas[i]);
                    messages[i] = message;
                }
                // Encode every amqp message and then convert every encoded message to amqp data section
                const batchMessage = {
                    body: rhea.message.data_sections(messages.map(rhea.message.encode))
                };
                // Set message_annotations, application_properties and properties of the first message as
                // that of the envelope (batch message).
                if (messages[0].message_annotations) {
                    batchMessage.message_annotations = messages[0].message_annotations;
                }
                if (messages[0].application_properties) {
                    batchMessage.application_properties = messages[0].application_properties;
                }
                for (const prop of eventData_1.messageProperties) {
                    if (messages[0][prop]) {
                        batchMessage[prop] = messages[0][prop];
                    }
                }
                // Finally encode the envelope (batch message).
                const encodedBatchMessage = rhea.message.encode(batchMessage);
github Azure / azure-event-hubs-node / dist / lib / eventHubSender.js View on Github external
};
                // Set message_annotations, application_properties and properties of the first message as
                // that of the envelope (batch message).
                if (messages[0].message_annotations) {
                    batchMessage.message_annotations = messages[0].message_annotations;
                }
                if (messages[0].application_properties) {
                    batchMessage.application_properties = messages[0].application_properties;
                }
                for (const prop of eventData_1.messageProperties) {
                    if (messages[0][prop]) {
                        batchMessage[prop] = messages[0][prop];
                    }
                }
                // Finally encode the envelope (batch message).
                const encodedBatchMessage = rhea.message.encode(batchMessage);
                debug("[%s]Sender '%s', sending encoded batch message.", this._context.connectionId, this.name, encodedBatchMessage);
                return yield this._trySend(encodedBatchMessage, undefined, 0x80013700);
            }
            catch (err) {
                debug("An error occurred while sending the batch message %O", err);
                throw err;
            }
        });
    }