Watch Aspire live streamsDokumentationPrøv Aspire

Set up ActiveMQ with the Aspire integration

Dette indhold er ikke tilgængeligt i dit sprog endnu.

⭐ Community Toolkit ActiveMQ logo

Use the ActiveMQ hosting integration to add ActiveMQ Classic or ActiveMQ Artemis to your Aspire application model. For an introduction, see Get started with ActiveMQ integration.

Aspire CLI — Tilføj CommunityToolkit.Aspire.Hosting.ActiveMQ-pakke
aspire add communitytoolkit-activemq

Aspire CLI er interaktiv; vælg det passende søgeresultat når du bliver spurgt:

Aspire CLI — Eksempel output
Select an integration to add:
> communitytoolkit-activemq (CommunityToolkit.Aspire.Hosting.ActiveMQ)
> Other results listed as selectable options...

Pass Aspire parameters for the broker username and password. Aspire marks the password parameter as secret so its value is not displayed in plain text in the dashboard.

apphost.mts
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const username = await builder.addParameter('activemq-user', {
value: 'admin',
publishValueAsDefault: true,
});
const password = await builder.addParameter('activemq-password', {
value: 'admin',
secret: true,
});
const broker = await builder.addActiveMQ('activemq', {
userName: username,
password,
});
const api = await builder.addProject('api', '../Api/Api.csproj');
await api.withReference(broker);
await builder.build().run();

The integration also provides AddActiveMQArtemis and addActiveMQArtemis. Both resource types accept optional host ports for the broker and web console.

The scheme argument controls the scheme in the broker connection URI. It defaults to tcp; use activemq when a client such as MassTransit expects that scheme.

apphost.mts
const broker = await builder.addActiveMQ('activemq', {
userName: username,
password,
scheme: 'activemq',
webPort: 8161,
});
await broker.withDataVolume();
await broker.withConfVolume();

Use the optional port argument to pin the broker’s host port. Use webPort to pin the web console port. The data volume persists broker data outside the container lifecycle. The configuration volume lets you provide broker configuration files. Bind-mount alternatives are available through WithDataBindMount and WithConfBindMount.

The package exports these hosting methods:

MethodPurpose
AddActiveMQ / addActiveMQAdd an ActiveMQ Classic container with optional username, password, broker port, connection scheme, and web console port.
AddActiveMQArtemis / addActiveMQArtemisAdd an ActiveMQ Artemis container with the same options.
WithDataVolume / withDataVolumePersist broker data in a named container volume.
WithDataBindMount / withDataBindMountStore broker data in a host directory.
WithConfVolume / withConfVolumeMount configuration from a container volume.
WithConfBindMount / withConfBindMountMount configuration from a host directory.