1.1.0 • Published 8 months ago

multistomp v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

Multistomp

Install:

npm install --save multistomp

Usage:

import { IMessage } from '@stomp/stompjs';
import { Client } from 'multistomp';

const client = new Client({

    // Either pass in multiple for failover
    brokerURL: [
        'wss://first-server:61619',
        'wss://second-server:61619',
    ],

    // Or a single
    brokerURL: 'wss://some-server:61619',

    // Or a failover url
    brokerURL: 'failover:(wss://primary-server:61619,wss://secondary-server:61619)',
});

// Even pre-activated publishes are supported (queued until connected)
client.publish({ destination: "/my/queue/name", body: "hello world" });

client.activate();

// Regular publish
client.publish({ destination: "/my/queue/name", body: "foobar" });

const subscription = client.subscribe("/my/queue/name", (message: IMessage) => {
    // Do things
});

// Or, a subscription with custom headers:
const subscription = client.subscribe("/my/queue/name", (message: IMessage) => {
    try {
        // Do something
        message.ack();
    } catch {
        // We failed
        message.nack();
    }
}, { ack: 'client-individual', 'activemq.prefetchSize': '4' });


setTimeout(() => {
    subscription.unsubscribe();
}, 5000);

setTimeout(() => {
    client.deactivate();
}, 15000);
1.0.2

10 months ago

1.1.0

8 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

10 months ago

1.0.1

1 year ago

1.0.0

1 year ago