Pesquisar

Este conteúdo não está disponível no idioma selecionado.

Chapter 11. Interoperability

download PDF

This chapter discusses how to use AMQ JavaScript in combination with other AMQ components. For an overview of the compatibility of AMQ components, see the product introduction.

11.1. Interoperating with other AMQP clients

AMQP messages are composed using the AMQP type system. This common format is one of the reasons AMQP clients in different languages are able to interoperate with each other.

When sending messages, AMQ JavaScript automatically converts language-native types to AMQP-encoded data. When receiving messages, the reverse conversion takes place.

Note

More information about AMQP types is available at the interactive type reference maintained by the Apache Qpid project.

Table 11.1. AMQP types
AMQP typeDescription

null

An empty value

boolean

A true or false value

char

A single Unicode character

string

A sequence of Unicode characters

binary

A sequence of bytes

byte

A signed 8-bit integer

short

A signed 16-bit integer

int

A signed 32-bit integer

long

A signed 64-bit integer

ubyte

An unsigned 8-bit integer

ushort

An unsigned 16-bit integer

uint

An unsigned 32-bit integer

ulong

An unsigned 64-bit integer

float

A 32-bit floating point number

double

A 64-bit floating point number

array

A sequence of values of a single type

list

A sequence of values of variable type

map

A mapping from distinct keys to values

uuid

A universally unique identifier

symbol

A 7-bit ASCII string from a constrained domain

timestamp

An absolute point in time

JavaScript has fewer native types than AMQP can encode. To send messages containing specific AMQP types, use the wrap_ functions from the rhea/types.js module.

Table 11.2. AMQ JavaScript types before encoding and after decoding
AMQP typeAMQ JavaScript type before encodingAMQ JavaScript type after decoding

null

null

null

boolean

boolean

boolean

char

wrap_char(number)

number

string

string

string

binary

wrap_binary(string)

string

byte

wrap_byte(number)

number

short

wrap_short(number)

number

int

wrap_int(number)

number

long

wrap_long(number)

number

ubyte

wrap_ubyte(number)

number

ushort

wrap_ushort(number)

number

uint

wrap_uint(number)

number

ulong

wrap_ulong(number)

number

float

wrap_float(number)

number

double

wrap_double(number)

number

array

wrap_array(Array, code)

Array

list

wrap_list(Array)

Array

map

wrap_map(object)

object

uuid

wrap_uuid(number)

number

symbol

wrap_symbol(string)

string

timestamp

wrap_timestamp(number)

number

Table 11.3. AMQ JavaScript and other AMQ client types (1 of 2)
AMQ JavaScript type before encodingAMQ C++ typeAMQ .NET type

null

nullptr

null

boolean

bool

System.Boolean

wrap_char(number)

wchar_t

System.Char

string

std::string

System.String

wrap_binary(string)

proton::binary

System.Byte[]

wrap_byte(number)

int8_t

System.SByte

wrap_short(number)

int16_t

System.Int16

wrap_int(number)

int32_t

System.Int32

wrap_long(number)

int64_t

System.Int64

wrap_ubyte(number)

uint8_t

System.Byte

wrap_ushort(number)

uint16_t

System.UInt16

wrap_uint(number)

uint32_t

System.UInt32

wrap_ulong(number)

uint64_t

System.UInt64

wrap_float(number)

float

System.Single

wrap_double(number)

double

System.Double

wrap_array(Array, code)

-

-

wrap_list(Array)

std::vector

Amqp.List

wrap_map(object)

std::map

Amqp.Map

wrap_uuid(number)

proton::uuid

System.Guid

wrap_symbol(string)

proton::symbol

Amqp.Symbol

wrap_timestamp(number)

proton::timestamp

System.DateTime

Table 11.4. AMQ JavaScript and other AMQ client types (2 of 2)
AMQ JavaScript type before encodingAMQ Python typeAMQ Ruby type

null

None

nil

boolean

bool

true, false

wrap_char(number)

unicode

String

string

unicode

String

wrap_binary(string)

bytes

String

wrap_byte(number)

int

Integer

wrap_short(number)

int

Integer

wrap_int(number)

long

Integer

wrap_long(number)

long

Integer

wrap_ubyte(number)

long

Integer

wrap_ushort(number)

long

Integer

wrap_uint(number)

long

Integer

wrap_ulong(number)

long

Integer

wrap_float(number)

float

Float

wrap_double(number)

float

Float

wrap_array(Array, code)

proton.Array

Array

wrap_list(Array)

list

Array

wrap_map(object)

dict

Hash

wrap_uuid(number)

-

-

wrap_symbol(string)

str

Symbol

wrap_timestamp(number)

long

Time

11.2. Interoperating with AMQ JMS

AMQP defines a standard mapping to the JMS messaging model. This section discusses the various aspects of that mapping. For more information, see the AMQ JMS Interoperability chapter.

JMS message types

AMQ JavaScript provides a single message type whose body type can vary. By contrast, the JMS API uses different message types to represent different kinds of data. The table below indicates how particular body types map to JMS message types.

For more explicit control of the resulting JMS message type, you can set the x-opt-jms-msg-type message annotation. See the AMQ JMS Interoperability chapter for more information.

Table 11.5. AMQ JavaScript and JMS message types
AMQ JavaScript body typeJMS message type

string

TextMessage

null

TextMessage

wrap_binary(string)

BytesMessage

Any other type

ObjectMessage

11.3. Connecting to AMQ Broker

AMQ Broker is designed to interoperate with AMQP 1.0 clients. Check the following to ensure the broker is configured for AMQP messaging:

  • Port 5672 in the network firewall is open.
  • The AMQ Broker AMQP acceptor is enabled. See Default acceptor settings.
  • The necessary addresses are configured on the broker. See Addresses, Queues, and Topics.
  • The broker is configured to permit access from your client, and the client is configured to send the required credentials. See Broker Security.

11.4. Connecting to AMQ Interconnect

AMQ Interconnect works with any AMQP 1.0 client. Check the following to ensure the components are configured correctly:

  • Port 5672 in the network firewall is open.
  • The router is configured to permit access from your client, and the client is configured to send the required credentials. See Securing network connections.
Red Hat logoGithubRedditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja oBlog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

© 2024 Red Hat, Inc.