@amqp-contract/client
@amqp-contract/client
Classes
MessageValidationError
Defined in: packages/core/dist/index.d.mts:83
Error thrown when message validation fails (payload or headers).
Used by both the client (publish-time payload validation) and the worker (consume-time payload and headers validation).
Param
The name of the publisher or consumer that triggered the validation
Param
The validation issues from the Standard Schema validation
Extends
Error
Constructors
Constructor
new MessageValidationError(source, issues): MessageValidationError;Defined in: packages/core/dist/index.d.mts:86
Parameters
| Parameter | Type |
|---|---|
source | string |
issues | unknown |
Returns
Overrides
Error.constructorProperties
Methods
captureStackTrace()
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.pnpm/@types+node@25.3.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.
The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTraceprepareStackTrace()
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.pnpm/@types+node@25.3.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTraceTypedAmqpClient
Defined in: packages/client/src/client.ts:56
Type-safe AMQP client for publishing messages
Type Parameters
| Type Parameter |
|---|
TContract extends ContractDefinition |
Methods
close()
close(): Future<Result<void, TechnicalError>>;Defined in: packages/client/src/client.ts:203
Close the channel and connection
Returns
Future<Result<void, TechnicalError>>
publish()
publish<TName>(
publisherName,
message,
options?): Future<Result<void, TechnicalError | MessageValidationError>>;Defined in: packages/client/src/client.ts:109
Publish a message using a defined publisher. TypeScript guarantees publisher exists for valid publisher names.
Type Parameters
| Type Parameter |
|---|
TName extends string | number | symbol |
Parameters
| Parameter | Type |
|---|---|
publisherName | TName |
message | ClientInferPublisherInput<TContract, TName> |
options? | PublishOptions |
Returns
Future<Result<void, TechnicalError | MessageValidationError>>
create()
static create<TContract>(__namedParameters): Future<Result<TypedAmqpClient<TContract>, TechnicalError>>;Defined in: packages/client/src/client.ts:74
Create a type-safe AMQP client from a contract.
Connection management (including automatic reconnection) is handled internally by amqp-connection-manager via the AmqpClient. The client establishes infrastructure asynchronously in the background once the connection is ready.
Connections are automatically shared across clients with the same URLs and connection options, following RabbitMQ best practices.
Type Parameters
| Type Parameter |
|---|
TContract extends ContractDefinition |
Parameters
| Parameter | Type |
|---|---|
__namedParameters | CreateClientOptions<TContract> |
Returns
Future<Result<TypedAmqpClient<TContract>, TechnicalError>>
Type Aliases
ClientInferPublisherInput
type ClientInferPublisherInput<TContract, TName> = PublisherInferInput<InferPublisher<TContract, TName>>;Defined in: packages/client/src/types.ts:41
Infer publisher input type (message payload) for a specific publisher in a contract
Type Parameters
| Type Parameter |
|---|
TContract extends ContractDefinition |
TName extends InferPublisherNames<TContract> |
CreateClientOptions
type CreateClientOptions<TContract> = object;Defined in: packages/client/src/client.ts:40
Options for creating a client
Type Parameters
| Type Parameter |
|---|
TContract extends ContractDefinition |
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
connectionOptions? | AmqpConnectionManagerOptions | - | packages/client/src/client.ts:43 |
contract | TContract | - | packages/client/src/client.ts:41 |
logger? | Logger | - | packages/client/src/client.ts:44 |
telemetry? | TelemetryProvider | Optional telemetry provider for tracing and metrics. If not provided, uses the default provider which attempts to load OpenTelemetry. OpenTelemetry instrumentation is automatically enabled if @opentelemetry/api is installed. | packages/client/src/client.ts:50 |
urls | ConnectionUrl[] | - | packages/client/src/client.ts:42 |
PublishOptions
type PublishOptions = Options.Publish & object;Defined in: packages/client/src/client.ts:28
Publish options that extend amqplib's Options.Publish with optional compression support.
Type Declaration
| Name | Type | Description | Defined in |
|---|---|---|---|
compression? | CompressionAlgorithm | Optional compression algorithm to use for the message payload. When specified, the message will be compressed using the chosen algorithm and the contentEncoding header will be set automatically. | packages/client/src/client.ts:34 |