@axinom/mosaic-message-bus 0.19.0-rc.0 → 0.19.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/broker.d.ts +8 -3
- package/dist/broker.d.ts.map +1 -1
- package/dist/broker.js +10 -6
- package/dist/broker.js.map +1 -1
- package/dist/common/constants.d.ts +3 -0
- package/dist/common/constants.d.ts.map +1 -0
- package/dist/common/constants.js +6 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +2 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/utils.d.ts +6 -0
- package/dist/common/utils.d.ts.map +1 -0
- package/dist/common/utils.js +6 -0
- package/dist/common/utils.js.map +1 -0
- package/dist/publication.d.ts +9 -3
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +20 -13
- package/dist/publication.js.map +1 -1
- package/dist/rascal-config-builder.d.ts +7 -4
- package/dist/rascal-config-builder.d.ts.map +1 -1
- package/dist/rascal-config-builder.js +22 -5
- package/dist/rascal-config-builder.js.map +1 -1
- package/dist/types/message-envelope.d.ts +9 -1
- package/dist/types/message-envelope.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/broker.ts +12 -6
- package/src/common/constants.ts +2 -0
- package/src/common/index.ts +2 -0
- package/src/common/utils.ts +7 -0
- package/src/publication.spec.ts +16 -6
- package/src/publication.ts +34 -11
- package/src/rascal-config-builder.spec.ts +11 -9
- package/src/rascal-config-builder.ts +29 -10
- package/src/schemas/message-envelope.json +9 -0
- package/src/subscription.spec.ts +10 -2
- package/src/types/message-envelope.ts +9 -1
package/dist/broker.d.ts
CHANGED
|
@@ -28,18 +28,23 @@ export declare class BrokerProxy {
|
|
|
28
28
|
static create(config: BrokerConfig, logger: MessagingLogger, components?: Record<string, unknown>): Promise<BrokerProxy>;
|
|
29
29
|
/**
|
|
30
30
|
* Attaches a MessageHandler to a subscriptions "On Message" event.
|
|
31
|
-
* @param handler
|
|
31
|
+
* @param handler The message handler class to handle a specific message type
|
|
32
|
+
* @param middleware Apply middleware on receiving a message
|
|
32
33
|
*/
|
|
33
34
|
addMessageHandler<TContent>(handler: MessageHandler<TContent>, middleware?: OnMessageMiddleware[]): Promise<SubscriberSessionAsPromised>;
|
|
34
35
|
/**
|
|
35
36
|
* Publish a message with defined routing key.
|
|
36
37
|
*
|
|
37
|
-
* @param
|
|
38
|
+
* @param aggregateId The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.
|
|
39
|
+
* @param type - The aggregate type and message type e.g. `channel` and `ChannelPublishedEvent`
|
|
38
40
|
* @param payload - message payload
|
|
39
41
|
* @param envelopeOverrides - explicitly defined message envelope values, e.g. auth token or message context
|
|
40
42
|
* @param options - explicitly defined message options, e.g. if additional header values should be passed
|
|
41
43
|
*/
|
|
42
|
-
publish<T>(
|
|
44
|
+
publish<T>(aggregateId: string, type: {
|
|
45
|
+
messageType: string;
|
|
46
|
+
aggregateType: string;
|
|
47
|
+
}, payload: T, envelopeOverrides?: MessageEnvelopeOverrides, options?: PublicationConfig): Promise<PublicationSession>;
|
|
43
48
|
/**
|
|
44
49
|
* Allows to programmatically establish a connection to a vhost.
|
|
45
50
|
*
|
package/dist/broker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker.d.ts","sourceRoot":"","sources":["../src/broker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAEL,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,EAC3B,kBAAkB,EAEnB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"broker.d.ts","sourceRoot":"","sources":["../src/broker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAE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C1B,OAAO,CAAC,kBAAkB,CAAC;IAS9B;;;;OAIG;IACU,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAItD;;;OAGG;IACU,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC;;;OAGG;IACU,SAAS,CACpB,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,kBAAkB,GAC7B,OAAO,CAAC,2BAA2B,CAAC;IAIvC;;OAEG;IACI,WAAW,IAAI,OAAO;CAG9B"}
|
package/dist/broker.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BrokerProxy = void 0;
|
|
4
4
|
const rascal_1 = require("rascal");
|
|
5
|
+
const common_1 = require("./common");
|
|
5
6
|
const publication_1 = require("./publication");
|
|
6
7
|
const subscription_1 = require("./subscription");
|
|
7
8
|
/**
|
|
@@ -81,10 +82,11 @@ class BrokerProxy {
|
|
|
81
82
|
}
|
|
82
83
|
return sub;
|
|
83
84
|
}
|
|
84
|
-
getPublication(
|
|
85
|
+
getPublication(messageType) {
|
|
86
|
+
const key = (0, common_1.toAggregateMessageKey)(messageType);
|
|
85
87
|
let publication = this.publications.get(key);
|
|
86
88
|
if (!publication) {
|
|
87
|
-
publication = new publication_1.default(
|
|
89
|
+
publication = new publication_1.default(messageType, this.broker, this.logger);
|
|
88
90
|
this.publications.set(key, publication);
|
|
89
91
|
}
|
|
90
92
|
return publication;
|
|
@@ -102,7 +104,8 @@ class BrokerProxy {
|
|
|
102
104
|
}
|
|
103
105
|
/**
|
|
104
106
|
* Attaches a MessageHandler to a subscriptions "On Message" event.
|
|
105
|
-
* @param handler
|
|
107
|
+
* @param handler The message handler class to handle a specific message type
|
|
108
|
+
* @param middleware Apply middleware on receiving a message
|
|
106
109
|
*/
|
|
107
110
|
async addMessageHandler(handler, middleware = []) {
|
|
108
111
|
const subscription = await this.getSubscription(handler, middleware);
|
|
@@ -111,13 +114,14 @@ class BrokerProxy {
|
|
|
111
114
|
/**
|
|
112
115
|
* Publish a message with defined routing key.
|
|
113
116
|
*
|
|
114
|
-
* @param
|
|
117
|
+
* @param aggregateId The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.
|
|
118
|
+
* @param type - The aggregate type and message type e.g. `channel` and `ChannelPublishedEvent`
|
|
115
119
|
* @param payload - message payload
|
|
116
120
|
* @param envelopeOverrides - explicitly defined message envelope values, e.g. auth token or message context
|
|
117
121
|
* @param options - explicitly defined message options, e.g. if additional header values should be passed
|
|
118
122
|
*/
|
|
119
|
-
async publish(
|
|
120
|
-
return this.getPublication(
|
|
123
|
+
async publish(aggregateId, type, payload, envelopeOverrides, options) {
|
|
124
|
+
return this.getPublication(type).publish(aggregateId, payload, envelopeOverrides, options);
|
|
121
125
|
}
|
|
122
126
|
/**
|
|
123
127
|
* Allows to programmatically establish a connection to a vhost.
|
package/dist/broker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../src/broker.ts"],"names":[],"mappings":";;;AAEA,mCAQgB;
|
|
1
|
+
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../src/broker.ts"],"names":[],"mappings":";;;AAEA,mCAQgB;AAChB,qCAAuE;AAEvE,+CAAwC;AACxC,iDAA0C;AAuB1C;;GAEG;AACH,MAAa,WAAW;IAStB,YACU,MAAwB,EACxB,MAAuB;QADvB,WAAM,GAAN,MAAM,CAAkB;QACxB,WAAM,GAAN,MAAM,CAAiB;QATjC,8DAA8D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;;OAEG;IACI,KAAK,CAAC,QAAQ;QACnB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,SAAS,CACpB,GAAW,EACX,SAA8B;QAE9B,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,WAAW;QAChB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;CACF;AA/ND,kCA+NC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AACnD,eAAO,MAAM,sBAAsB,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MULTIPLE_AGGREGATE_IDS = exports.UNKNOWN_AGGREGATE_ID = void 0;
|
|
4
|
+
exports.UNKNOWN_AGGREGATE_ID = 'UNDEFINED_ID';
|
|
5
|
+
exports.MULTIPLE_AGGREGATE_IDS = 'MULTIPLE_IDS';
|
|
6
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,cAAc,CAAC;AACtC,QAAA,sBAAsB,GAAG,cAAc,CAAC"}
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
package/dist/common/index.js
CHANGED
|
@@ -14,5 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
17
18
|
__exportStar(require("./log-parser"), exports);
|
|
19
|
+
__exportStar(require("./utils"), exports);
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,+CAA6B;AAC7B,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,qBAAqB,SAAU,oBAAoB,KAAG,MACtB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toAggregateMessageKey = void 0;
|
|
4
|
+
const toAggregateMessageKey = (type) => `${type.aggregateType}@${type.messageType}`;
|
|
5
|
+
exports.toAggregateMessageKey = toAggregateMessageKey;
|
|
6
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":";;;AAKO,MAAM,qBAAqB,GAAG,CAAC,IAA0B,EAAU,EAAE,CAC1E,GAAG,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;AADjC,QAAA,qBAAqB,yBACY"}
|
package/dist/publication.d.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { BrokerAsPromised, PublicationConfig, PublicationSession } from 'rascal';
|
|
2
|
+
import { AggregateMessageType } from './common';
|
|
2
3
|
import { MessageEnvelopeOverrides, MessagingLogger } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* Handles publication of messages, including the generation of the message envelope object.
|
|
5
6
|
*/
|
|
6
7
|
export default class Publication {
|
|
7
|
-
private readonly key;
|
|
8
8
|
private readonly broker;
|
|
9
9
|
private readonly logger;
|
|
10
|
-
|
|
10
|
+
private readonly messageType;
|
|
11
|
+
private readonly aggregateType;
|
|
12
|
+
constructor({ aggregateType, messageType }: AggregateMessageType, broker: BrokerAsPromised, logger: MessagingLogger);
|
|
11
13
|
/**
|
|
12
14
|
* Publishes a message using a routing key and a set of headers to be passed as part of message options.
|
|
15
|
+
* @param aggregateId The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.
|
|
16
|
+
* @param payload - message payload
|
|
17
|
+
* @param envelopeOverrides - explicitly defined message envelope values, e.g. auth token or message context
|
|
18
|
+
* @param options - explicitly defined message options, e.g. if additional header values should be passed
|
|
13
19
|
*/
|
|
14
|
-
publish(payload: unknown, envelopeOverrides?: MessageEnvelopeOverrides, options?: PublicationConfig): Promise<PublicationSession>;
|
|
20
|
+
publish(aggregateId: string, payload: unknown, envelopeOverrides?: MessageEnvelopeOverrides, options?: PublicationConfig): Promise<PublicationSession>;
|
|
15
21
|
private createEnvelope;
|
|
16
22
|
private attachEventHandlers;
|
|
17
23
|
onSuccess(messageId: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publication.d.ts","sourceRoot":"","sources":["../src/publication.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAGL,wBAAwB,EACxB,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;
|
|
1
|
+
{"version":3,"file":"publication.d.ts","sourceRoot":"","sources":["../src/publication.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAGL,wBAAwB,EACxB,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAK5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAErC,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,oBAAoB,EACnC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,eAAe;IAM1C;;;;;;OAMG;IACU,OAAO,CAClB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,EAChB,iBAAiB,GAAE,wBAA6B,EAChD,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,kBAAkB,CAAC;IA8B9B,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,mBAAmB;IAOd,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3C,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQvD,QAAQ,CAAC,OAAO,EAAE;QAC7B,UAAU,CAAC,EAAE;YAAE,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACpC,MAAM,CAAC,EAAE;YACP,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB,CAAC;KACH,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBJ,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOxD"}
|
package/dist/publication.js
CHANGED
|
@@ -6,34 +6,41 @@ const uuid_1 = require("uuid");
|
|
|
6
6
|
* Handles publication of messages, including the generation of the message envelope object.
|
|
7
7
|
*/
|
|
8
8
|
class Publication {
|
|
9
|
-
constructor(
|
|
10
|
-
this.key = key;
|
|
9
|
+
constructor({ aggregateType, messageType }, broker, logger) {
|
|
11
10
|
this.broker = broker;
|
|
12
11
|
this.logger = logger;
|
|
12
|
+
this.aggregateType = aggregateType;
|
|
13
|
+
this.messageType = messageType;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Publishes a message using a routing key and a set of headers to be passed as part of message options.
|
|
17
|
+
* @param aggregateId The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.
|
|
18
|
+
* @param payload - message payload
|
|
19
|
+
* @param envelopeOverrides - explicitly defined message envelope values, e.g. auth token or message context
|
|
20
|
+
* @param options - explicitly defined message options, e.g. if additional header values should be passed
|
|
16
21
|
*/
|
|
17
|
-
async publish(payload, envelopeOverrides = {}, options = {}) {
|
|
22
|
+
async publish(aggregateId, payload, envelopeOverrides = {}, options = {}) {
|
|
18
23
|
const messageId = (0, uuid_1.v4)();
|
|
19
|
-
const envelope = this.createEnvelope(messageId, payload, envelopeOverrides);
|
|
24
|
+
const envelope = this.createEnvelope(messageId, aggregateId, payload, envelopeOverrides);
|
|
20
25
|
const overrides = (0, ramda_1.mergeDeepRight)(options, { options: { messageId } });
|
|
21
26
|
// Perform runtime validation for unreplaced placeholders on routing-keys of multi-tenant messages
|
|
22
27
|
if (['*', '#'].some((placeholder) => { var _a; return (_a = overrides.routingKey) === null || _a === void 0 ? void 0 : _a.includes(placeholder); })) {
|
|
23
|
-
throw new Error(`The routing-key [${overrides.routingKey}] for message-key [${this.
|
|
28
|
+
throw new Error(`The routing-key [${overrides.routingKey}] for message-key [${this.messageType}] has unresolved placeholders. Please ensure all placeholders are resolved with fixed values.`);
|
|
24
29
|
}
|
|
25
|
-
const session = await this.broker.publish(this.
|
|
30
|
+
const session = await this.broker.publish(this.messageType, envelope, overrides);
|
|
26
31
|
this.attachEventHandlers(session);
|
|
27
32
|
return session;
|
|
28
33
|
}
|
|
29
|
-
createEnvelope(messageId, payload, overrides) {
|
|
34
|
+
createEnvelope(messageId, aggregateId, payload, overrides) {
|
|
30
35
|
return {
|
|
31
36
|
payload,
|
|
32
37
|
message_context: overrides.message_context,
|
|
33
38
|
message_id: messageId,
|
|
34
39
|
timestamp: new Date().toISOString(),
|
|
35
|
-
message_type: this.
|
|
36
|
-
|
|
40
|
+
message_type: this.messageType,
|
|
41
|
+
aggregate_id: aggregateId,
|
|
42
|
+
aggregate_type: this.aggregateType,
|
|
43
|
+
message_version: '1.1',
|
|
37
44
|
auth_token: overrides.auth_token, //TODO: auto-assign is not straightforward to implement, since we need to create a shared context that subscription will share with a singleton broker
|
|
38
45
|
};
|
|
39
46
|
}
|
|
@@ -45,14 +52,14 @@ class Publication {
|
|
|
45
52
|
}
|
|
46
53
|
async onSuccess(messageId) {
|
|
47
54
|
this.logger.debug({
|
|
48
|
-
context: `${this.
|
|
55
|
+
context: `${this.messageType} PublicationSuccessEvent`,
|
|
49
56
|
message: `Publishing succeeded for message ${messageId}`,
|
|
50
57
|
details: { messageId },
|
|
51
58
|
});
|
|
52
59
|
}
|
|
53
60
|
async onError(error, messageId) {
|
|
54
61
|
this.logger.error(error, {
|
|
55
|
-
context: `${this.
|
|
62
|
+
context: `${this.messageType} PublicationErrorEvent`,
|
|
56
63
|
message: `Publishing error for message ${messageId}`,
|
|
57
64
|
details: { messageId },
|
|
58
65
|
});
|
|
@@ -61,7 +68,7 @@ class Publication {
|
|
|
61
68
|
var _a, _b, _c, _d, _e;
|
|
62
69
|
const messageId = (_b = (_a = message === null || message === void 0 ? void 0 : message.properties) === null || _a === void 0 ? void 0 : _a.messageId) !== null && _b !== void 0 ? _b : 'unknown message ID';
|
|
63
70
|
const logMessage = {
|
|
64
|
-
context: `${this.
|
|
71
|
+
context: `${this.messageType} PublicationReturnEvent`,
|
|
65
72
|
message: `Published message with ID ${messageId} was returned, no recipient found.`,
|
|
66
73
|
details: {
|
|
67
74
|
messageId,
|
|
@@ -83,7 +90,7 @@ Messaging settings should have a function 'getEnvironmentRoutingKey' to help wit
|
|
|
83
90
|
}
|
|
84
91
|
async onPaused(messageId) {
|
|
85
92
|
this.logger.debug({
|
|
86
|
-
context: `${this.
|
|
93
|
+
context: `${this.messageType} PublicationPausedEvent`,
|
|
87
94
|
message: `Publishing paused for message ${messageId}`,
|
|
88
95
|
details: { messageId },
|
|
89
96
|
});
|
package/dist/publication.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publication.js","sourceRoot":"","sources":["../src/publication.ts"],"names":[],"mappings":";;AAAA,iCAAuC;AAMvC,+BAAkC;
|
|
1
|
+
{"version":3,"file":"publication.js","sourceRoot":"","sources":["../src/publication.ts"],"names":[],"mappings":";;AAAA,iCAAuC;AAMvC,+BAAkC;AASlC;;GAEG;AACH,MAAqB,WAAW;IAG9B,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,CAAC,QAAQ,CAAC,OAQrB;;QACC,MAAM,SAAS,GAAG,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,0CAAE,SAAS,mCAAI,oBAAoB,CAAC;QACzE,MAAM,UAAU,GAAe;YAC7B,OAAO,EAAE,GAAG,IAAI,CAAC,WAAW,yBAAyB;YACrD,OAAO,EAAE,6BAA6B,SAAS,oCAAoC;YACnF,OAAO,EAAE;gBACP,SAAS;gBACT,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM;gBACvB,IAAI,EAAE;;;+FAGiF;aACxF;SACF,CAAC;QACF,IACE,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,0CAAE,QAAQ,MAAK,SAAS;YACvC,CAAC,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,0CAAE,UAAU,mCAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EACrD;YACA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;SAC/B;aAAM;YACL,+DAA+D;YAC/D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;SAC/B;IACH,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,SAAiB;QACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YAChB,OAAO,EAAE,GAAG,IAAI,CAAC,WAAW,yBAAyB;YACrD,OAAO,EAAE,iCAAiC,SAAS,EAAE;YACrD,OAAO,EAAE,EAAE,SAAS,EAAE;SACvB,CAAC,CAAC;IACL,CAAC;CACF;AAxID,8BAwIC"}
|
|
@@ -8,11 +8,11 @@ import { MessagingConfig } from './types';
|
|
|
8
8
|
* Multiple builders are used by `setupMessagingBroker` middleware to generate a complete rascal messaging configuration object.
|
|
9
9
|
*/
|
|
10
10
|
export declare class RascalConfigBuilder {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
protected readonly info: MessagingSettings;
|
|
12
|
+
protected readonly config: MessagingConfig;
|
|
13
13
|
private transformers;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
protected currentServiceId: string;
|
|
15
|
+
protected destinationServiceId: string;
|
|
16
16
|
/**
|
|
17
17
|
* @param info an info object that contains general information about message type
|
|
18
18
|
* @param config general RabbitMQ configuration object
|
|
@@ -61,5 +61,8 @@ export declare class RascalConfigBuilder {
|
|
|
61
61
|
private addSubscription;
|
|
62
62
|
private addMessagePublication;
|
|
63
63
|
private addRedirectBinding;
|
|
64
|
+
protected getSubscribeQueueName(): string;
|
|
65
|
+
protected getSendCommandQueueName(): string;
|
|
66
|
+
protected getSubscriptionKey(): string;
|
|
64
67
|
}
|
|
65
68
|
//# sourceMappingURL=rascal-config-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rascal-config-builder.d.ts","sourceRoot":"","sources":["../src/rascal-config-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAEL,YAAY,EAIb,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAsB1C;;;GAGG;AACH,qBAAa,mBAAmB;IAU5B,
|
|
1
|
+
{"version":3,"file":"rascal-config-builder.d.ts","sourceRoot":"","sources":["../src/rascal-config-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAEL,YAAY,EAIb,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,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SAAS,CAAC,uBAAuB,IAAI,MAAM;IAI3C,SAAS,CAAC,kBAAkB,IAAI,MAAM;CAGvC"}
|
|
@@ -48,7 +48,9 @@ class RascalConfigBuilder {
|
|
|
48
48
|
* Builder extension method to build rascal configuration part, which enables sending commands for a specific messageType.
|
|
49
49
|
*/
|
|
50
50
|
sendCommand() {
|
|
51
|
-
|
|
51
|
+
// To send a command the sending service can ensure that queues and bindings
|
|
52
|
+
// exist to not depend on a specific service startup order to create command queues.
|
|
53
|
+
const queueName = this.getSendCommandQueueName();
|
|
52
54
|
this.addQueue(this.destinationServiceId, queueName);
|
|
53
55
|
this.addRetryBinding(queueName);
|
|
54
56
|
this.addMessagePublication('command');
|
|
@@ -79,9 +81,10 @@ class RascalConfigBuilder {
|
|
|
79
81
|
}
|
|
80
82
|
subscribeForMessage(type, buildMessageHandler) {
|
|
81
83
|
this.setBuildMessageHandler(buildMessageHandler);
|
|
82
|
-
// Queue is added for local (config) serviceId, but bindings are using routingKey with
|
|
84
|
+
// Queue is added for local (config) serviceId, but bindings are using routingKey with
|
|
85
|
+
// remote (info) serviceId or local (config) serviceId, if remote is not specified
|
|
83
86
|
const routingKey = `${this.destinationServiceId}.${this.info.routingKey}`;
|
|
84
|
-
const queueName =
|
|
87
|
+
const queueName = this.getSubscribeQueueName();
|
|
85
88
|
this.addQueue(this.currentServiceId, queueName);
|
|
86
89
|
this.addRetryBinding(queueName);
|
|
87
90
|
this.addSubscription(queueName);
|
|
@@ -143,7 +146,7 @@ class RascalConfigBuilder {
|
|
|
143
146
|
}
|
|
144
147
|
this.transformers[actionKey] = (cfg) => {
|
|
145
148
|
const vhost = this.getVhostReference(cfg);
|
|
146
|
-
vhost.subscriptions[this.
|
|
149
|
+
vhost.subscriptions[this.getSubscriptionKey()] = {
|
|
147
150
|
queue: queueName,
|
|
148
151
|
prefetch: 10,
|
|
149
152
|
recovery: 'deferred_retry',
|
|
@@ -177,7 +180,12 @@ class RascalConfigBuilder {
|
|
|
177
180
|
}
|
|
178
181
|
this.transformers[actionKey] = (cfg) => {
|
|
179
182
|
const vhost = this.getVhostReference(cfg);
|
|
180
|
-
|
|
183
|
+
let bindingKey = routingKey;
|
|
184
|
+
let count = 2;
|
|
185
|
+
while (vhost.bindings[bindingKey]) {
|
|
186
|
+
bindingKey = `${bindingKey}-${count++}`;
|
|
187
|
+
}
|
|
188
|
+
vhost.bindings[bindingKey] = {
|
|
181
189
|
source: type,
|
|
182
190
|
bindingKey: routingKey,
|
|
183
191
|
destination: queueName,
|
|
@@ -185,6 +193,15 @@ class RascalConfigBuilder {
|
|
|
185
193
|
return cfg;
|
|
186
194
|
};
|
|
187
195
|
}
|
|
196
|
+
getSubscribeQueueName() {
|
|
197
|
+
return `${this.currentServiceId}:${this.info.queue}`;
|
|
198
|
+
}
|
|
199
|
+
getSendCommandQueueName() {
|
|
200
|
+
return `${this.destinationServiceId}:${this.info.queue}`;
|
|
201
|
+
}
|
|
202
|
+
getSubscriptionKey() {
|
|
203
|
+
return this.info.messageType;
|
|
204
|
+
}
|
|
188
205
|
}
|
|
189
206
|
exports.RascalConfigBuilder = RascalConfigBuilder;
|
|
190
207
|
//# sourceMappingURL=rascal-config-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rascal-config-builder.js","sourceRoot":"","sources":["../src/rascal-config-builder.ts"],"names":[],"mappings":";;;AAgCA;;;GAGG;AACH,MAAa,mBAAmB;IAK9B;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"rascal-config-builder.js","sourceRoot":"","sources":["../src/rascal-config-builder.ts"],"names":[],"mappings":";;;AAgCA;;;GAGG;AACH,MAAa,mBAAmB;IAK9B;;;OAGG;IACH,YACqB,IAAuB,EACvB,MAAuB;;QADvB,SAAI,GAAJ,IAAI,CAAmB;QACvB,WAAM,GAAN,MAAM,CAAiB;QAVpC,iBAAY,GAAsB,EAAE,CAAC;QAyGrC,sBAAiB,GAAG,CAAC,GAAiB,EAAuB,EAAE;;YACrE,GA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AAI,CAAC,IAAI,CAAC,WAAW,CAAC;IAC/B,CAAC;CACF;AAxQD,kDAwQC"}
|
|
@@ -10,12 +10,20 @@ export interface MessageEnvelope<TContent = unknown> {
|
|
|
10
10
|
* Time and date (UTC) when the message was published.
|
|
11
11
|
*/
|
|
12
12
|
timestamp: string;
|
|
13
|
+
/**
|
|
14
|
+
* The type of the aggregate (in DDD context) or entity for which this message is sent
|
|
15
|
+
*/
|
|
16
|
+
aggregate_type: string;
|
|
13
17
|
/**
|
|
14
18
|
* Type of the message e.g. ContentPublishEvent
|
|
15
19
|
*/
|
|
16
20
|
message_type: string;
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* The unique identifier of the aggregate
|
|
23
|
+
*/
|
|
24
|
+
aggregate_id: string;
|
|
25
|
+
/**
|
|
26
|
+
* Version of the format of the payload field.
|
|
19
27
|
*/
|
|
20
28
|
message_version: string;
|
|
21
29
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-envelope.d.ts","sourceRoot":"","sources":["../../src/types/message-envelope.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,QAAQ,GAAG,OAAO;IACjD;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC;CACnB"}
|
|
1
|
+
{"version":3,"file":"message-envelope.d.ts","sourceRoot":"","sources":["../../src/types/message-envelope.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,QAAQ,GAAG,OAAO;IACjD;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-message-bus",
|
|
3
|
-
"version": "0.19.0-rc.
|
|
3
|
+
"version": "0.19.0-rc.3",
|
|
4
4
|
"description": "Messaging library for Axinom Mosaic services",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"lint": "eslint . --ext .ts,.tsx,.js --color --cache"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@axinom/mosaic-message-bus-abstractions": "^0.
|
|
32
|
+
"@axinom/mosaic-message-bus-abstractions": "^0.6.0-rc.2",
|
|
33
33
|
"amqplib": "^0.10.3",
|
|
34
34
|
"dotenv": "^8.2.0",
|
|
35
35
|
"prom-client": "^13.2.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "1684458c348c8a75ff16d74ddc9650679413bba7"
|
|
55
55
|
}
|
package/src/broker.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
SubscriptionConfig,
|
|
10
10
|
withDefaultConfig,
|
|
11
11
|
} from 'rascal';
|
|
12
|
+
import { AggregateMessageType, toAggregateMessageKey } from './common';
|
|
12
13
|
import { MessageHandler } from './message-handler';
|
|
13
14
|
import Publication from './publication';
|
|
14
15
|
import Subscription from './subscription';
|
|
@@ -133,10 +134,11 @@ export class BrokerProxy {
|
|
|
133
134
|
return sub as Subscription<TContent>;
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
private getPublication(
|
|
137
|
+
private getPublication(messageType: AggregateMessageType): Publication {
|
|
138
|
+
const key = toAggregateMessageKey(messageType);
|
|
137
139
|
let publication = this.publications.get(key);
|
|
138
140
|
if (!publication) {
|
|
139
|
-
publication = new Publication(
|
|
141
|
+
publication = new Publication(messageType, this.broker, this.logger);
|
|
140
142
|
this.publications.set(key, publication);
|
|
141
143
|
}
|
|
142
144
|
return publication;
|
|
@@ -160,7 +162,8 @@ export class BrokerProxy {
|
|
|
160
162
|
|
|
161
163
|
/**
|
|
162
164
|
* Attaches a MessageHandler to a subscriptions "On Message" event.
|
|
163
|
-
* @param handler
|
|
165
|
+
* @param handler The message handler class to handle a specific message type
|
|
166
|
+
* @param middleware Apply middleware on receiving a message
|
|
164
167
|
*/
|
|
165
168
|
public async addMessageHandler<TContent>(
|
|
166
169
|
handler: MessageHandler<TContent>,
|
|
@@ -173,18 +176,21 @@ export class BrokerProxy {
|
|
|
173
176
|
/**
|
|
174
177
|
* Publish a message with defined routing key.
|
|
175
178
|
*
|
|
176
|
-
* @param
|
|
179
|
+
* @param aggregateId The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.
|
|
180
|
+
* @param type - The aggregate type and message type e.g. `channel` and `ChannelPublishedEvent`
|
|
177
181
|
* @param payload - message payload
|
|
178
182
|
* @param envelopeOverrides - explicitly defined message envelope values, e.g. auth token or message context
|
|
179
183
|
* @param options - explicitly defined message options, e.g. if additional header values should be passed
|
|
180
184
|
*/
|
|
181
185
|
public async publish<T>(
|
|
182
|
-
|
|
186
|
+
aggregateId: string,
|
|
187
|
+
type: { messageType: string; aggregateType: string },
|
|
183
188
|
payload: T,
|
|
184
189
|
envelopeOverrides?: MessageEnvelopeOverrides,
|
|
185
190
|
options?: PublicationConfig,
|
|
186
191
|
): Promise<PublicationSession> {
|
|
187
|
-
return this.getPublication(
|
|
192
|
+
return this.getPublication(type).publish(
|
|
193
|
+
aggregateId,
|
|
188
194
|
payload,
|
|
189
195
|
envelopeOverrides,
|
|
190
196
|
options,
|
package/src/common/index.ts
CHANGED
package/src/publication.spec.ts
CHANGED
|
@@ -28,7 +28,11 @@ describe('Publication', () => {
|
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
const logger = stub<MessagingLogger>();
|
|
31
|
-
publication = new Publication(
|
|
31
|
+
publication = new Publication(
|
|
32
|
+
{ messageType: 'TestRoutingKey', aggregateType: 'test' },
|
|
33
|
+
broker,
|
|
34
|
+
logger,
|
|
35
|
+
);
|
|
32
36
|
});
|
|
33
37
|
|
|
34
38
|
afterEach(async () => {
|
|
@@ -39,16 +43,18 @@ describe('Publication', () => {
|
|
|
39
43
|
describe('publish', () => {
|
|
40
44
|
it('publish without overrides or options -> only default override messageId exists', async () => {
|
|
41
45
|
// Act
|
|
42
|
-
await publication.publish({});
|
|
46
|
+
await publication.publish('1', {});
|
|
43
47
|
|
|
44
48
|
// Assert
|
|
45
49
|
expect(resultEnvelope?.message_id).toBeTruthy();
|
|
46
50
|
expect(resultEnvelope?.timestamp).toBeTruthy();
|
|
47
51
|
expect(resultEnvelope).toEqual({
|
|
48
52
|
message_id: resultEnvelope?.message_id,
|
|
49
|
-
timestamp: resultEnvelope?.timestamp,
|
|
50
53
|
message_type: 'TestRoutingKey',
|
|
51
|
-
|
|
54
|
+
aggregate_id: '1',
|
|
55
|
+
aggregate_type: 'test',
|
|
56
|
+
timestamp: resultEnvelope?.timestamp,
|
|
57
|
+
message_version: '1.1',
|
|
52
58
|
message_context: undefined,
|
|
53
59
|
auth_token: undefined,
|
|
54
60
|
payload: {},
|
|
@@ -69,6 +75,7 @@ describe('Publication', () => {
|
|
|
69
75
|
it('publish with overrides -> default override messageId and headers exist', async () => {
|
|
70
76
|
// Act
|
|
71
77
|
await publication.publish(
|
|
78
|
+
'1',
|
|
72
79
|
{},
|
|
73
80
|
{
|
|
74
81
|
auth_token: 'testTokenValue',
|
|
@@ -81,9 +88,11 @@ describe('Publication', () => {
|
|
|
81
88
|
expect(resultEnvelope?.timestamp).toBeTruthy();
|
|
82
89
|
expect(resultEnvelope).toEqual({
|
|
83
90
|
message_id: resultEnvelope?.message_id,
|
|
84
|
-
timestamp: resultEnvelope?.timestamp,
|
|
85
91
|
message_type: 'TestRoutingKey',
|
|
86
|
-
|
|
92
|
+
aggregate_id: '1',
|
|
93
|
+
aggregate_type: 'test',
|
|
94
|
+
timestamp: resultEnvelope?.timestamp,
|
|
95
|
+
message_version: '1.1',
|
|
87
96
|
message_context: { test: 'testContextValue' },
|
|
88
97
|
auth_token: 'testTokenValue',
|
|
89
98
|
payload: {},
|
|
@@ -105,6 +114,7 @@ describe('Publication', () => {
|
|
|
105
114
|
// Arrange
|
|
106
115
|
const publishFunction = () => {
|
|
107
116
|
return publication.publish(
|
|
117
|
+
'1',
|
|
108
118
|
{},
|
|
109
119
|
{
|
|
110
120
|
auth_token: 'testTokenValue',
|
package/src/publication.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
PublicationSession,
|
|
6
6
|
} from 'rascal';
|
|
7
7
|
import { v4 as uuid } from 'uuid';
|
|
8
|
+
import { AggregateMessageType } from './common';
|
|
8
9
|
import {
|
|
9
10
|
LogMessage,
|
|
10
11
|
MessageEnvelope,
|
|
@@ -16,22 +17,37 @@ import {
|
|
|
16
17
|
* Handles publication of messages, including the generation of the message envelope object.
|
|
17
18
|
*/
|
|
18
19
|
export default class Publication {
|
|
20
|
+
private readonly messageType: string;
|
|
21
|
+
private readonly aggregateType: string;
|
|
19
22
|
constructor(
|
|
20
|
-
|
|
23
|
+
{ aggregateType, messageType }: AggregateMessageType,
|
|
21
24
|
private readonly broker: BrokerAsPromised,
|
|
22
25
|
private readonly logger: MessagingLogger,
|
|
23
|
-
) {
|
|
26
|
+
) {
|
|
27
|
+
this.aggregateType = aggregateType;
|
|
28
|
+
this.messageType = messageType;
|
|
29
|
+
}
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
32
|
* Publishes a message using a routing key and a set of headers to be passed as part of message options.
|
|
33
|
+
* @param aggregateId The (database) ID of the aggregate type or use the const UNKNOWN_AGGREGATE_ID or MULTIPLE_AGGREGATE_IDS values.
|
|
34
|
+
* @param payload - message payload
|
|
35
|
+
* @param envelopeOverrides - explicitly defined message envelope values, e.g. auth token or message context
|
|
36
|
+
* @param options - explicitly defined message options, e.g. if additional header values should be passed
|
|
27
37
|
*/
|
|
28
38
|
public async publish(
|
|
39
|
+
aggregateId: string,
|
|
29
40
|
payload: unknown,
|
|
30
41
|
envelopeOverrides: MessageEnvelopeOverrides = {},
|
|
31
42
|
options: PublicationConfig = {},
|
|
32
43
|
): Promise<PublicationSession> {
|
|
33
44
|
const messageId = uuid();
|
|
34
|
-
const envelope = this.createEnvelope(
|
|
45
|
+
const envelope = this.createEnvelope(
|
|
46
|
+
messageId,
|
|
47
|
+
aggregateId,
|
|
48
|
+
payload,
|
|
49
|
+
envelopeOverrides,
|
|
50
|
+
);
|
|
35
51
|
const overrides = mergeDeepRight(options, { options: { messageId } });
|
|
36
52
|
|
|
37
53
|
// Perform runtime validation for unreplaced placeholders on routing-keys of multi-tenant messages
|
|
@@ -41,17 +57,22 @@ export default class Publication {
|
|
|
41
57
|
)
|
|
42
58
|
) {
|
|
43
59
|
throw new Error(
|
|
44
|
-
`The routing-key [${overrides.routingKey}] for message-key [${this.
|
|
60
|
+
`The routing-key [${overrides.routingKey}] for message-key [${this.messageType}] has unresolved placeholders. Please ensure all placeholders are resolved with fixed values.`,
|
|
45
61
|
);
|
|
46
62
|
}
|
|
47
63
|
|
|
48
|
-
const session = await this.broker.publish(
|
|
64
|
+
const session = await this.broker.publish(
|
|
65
|
+
this.messageType,
|
|
66
|
+
envelope,
|
|
67
|
+
overrides,
|
|
68
|
+
);
|
|
49
69
|
this.attachEventHandlers(session);
|
|
50
70
|
return session;
|
|
51
71
|
}
|
|
52
72
|
|
|
53
73
|
private createEnvelope(
|
|
54
74
|
messageId: string,
|
|
75
|
+
aggregateId: string,
|
|
55
76
|
payload: unknown,
|
|
56
77
|
overrides: MessageEnvelopeOverrides,
|
|
57
78
|
): MessageEnvelope {
|
|
@@ -60,8 +81,10 @@ export default class Publication {
|
|
|
60
81
|
message_context: overrides.message_context,
|
|
61
82
|
message_id: messageId,
|
|
62
83
|
timestamp: new Date().toISOString(),
|
|
63
|
-
message_type: this.
|
|
64
|
-
|
|
84
|
+
message_type: this.messageType,
|
|
85
|
+
aggregate_id: aggregateId,
|
|
86
|
+
aggregate_type: this.aggregateType,
|
|
87
|
+
message_version: '1.1', //TODO: not MVP
|
|
65
88
|
auth_token: overrides.auth_token, //TODO: auto-assign is not straightforward to implement, since we need to create a shared context that subscription will share with a singleton broker
|
|
66
89
|
};
|
|
67
90
|
}
|
|
@@ -75,7 +98,7 @@ export default class Publication {
|
|
|
75
98
|
|
|
76
99
|
public async onSuccess(messageId: string): Promise<void> {
|
|
77
100
|
this.logger.debug({
|
|
78
|
-
context: `${this.
|
|
101
|
+
context: `${this.messageType} PublicationSuccessEvent`,
|
|
79
102
|
message: `Publishing succeeded for message ${messageId}`,
|
|
80
103
|
details: { messageId },
|
|
81
104
|
});
|
|
@@ -83,7 +106,7 @@ export default class Publication {
|
|
|
83
106
|
|
|
84
107
|
public async onError(error: Error, messageId: string): Promise<void> {
|
|
85
108
|
this.logger.error(error, {
|
|
86
|
-
context: `${this.
|
|
109
|
+
context: `${this.messageType} PublicationErrorEvent`,
|
|
87
110
|
message: `Publishing error for message ${messageId}`,
|
|
88
111
|
details: { messageId },
|
|
89
112
|
});
|
|
@@ -100,7 +123,7 @@ export default class Publication {
|
|
|
100
123
|
}): Promise<void> {
|
|
101
124
|
const messageId = message?.properties?.messageId ?? 'unknown message ID';
|
|
102
125
|
const logMessage: LogMessage = {
|
|
103
|
-
context: `${this.
|
|
126
|
+
context: `${this.messageType} PublicationReturnEvent`,
|
|
104
127
|
message: `Published message with ID ${messageId} was returned, no recipient found.`,
|
|
105
128
|
details: {
|
|
106
129
|
messageId,
|
|
@@ -124,7 +147,7 @@ Messaging settings should have a function 'getEnvironmentRoutingKey' to help wit
|
|
|
124
147
|
|
|
125
148
|
public async onPaused(messageId: string): Promise<void> {
|
|
126
149
|
this.logger.debug({
|
|
127
|
-
context: `${this.
|
|
150
|
+
context: `${this.messageType} PublicationPausedEvent`,
|
|
128
151
|
message: `Publishing paused for message ${messageId}`,
|
|
129
152
|
details: { messageId },
|
|
130
153
|
});
|
|
@@ -19,6 +19,8 @@ describe('RascalConfigBuilder', () => {
|
|
|
19
19
|
): RascalConfigBuilder => {
|
|
20
20
|
return new RascalConfigBuilder(
|
|
21
21
|
{
|
|
22
|
+
action: 'event',
|
|
23
|
+
aggregateType: 'test',
|
|
22
24
|
messageType: 'TestKey',
|
|
23
25
|
queue: 'test-queue',
|
|
24
26
|
routingKey: 'test.key',
|
|
@@ -177,7 +179,7 @@ describe('RascalConfigBuilder', () => {
|
|
|
177
179
|
destination: 'test-service-id:test-queue',
|
|
178
180
|
source: 'retry',
|
|
179
181
|
},
|
|
180
|
-
'test-service-id
|
|
182
|
+
'test-service-id.test.key': {
|
|
181
183
|
bindingKey: 'test-service-id.test.key',
|
|
182
184
|
destination: 'test-service-id:test-queue',
|
|
183
185
|
source: 'command',
|
|
@@ -229,7 +231,7 @@ describe('RascalConfigBuilder', () => {
|
|
|
229
231
|
destination: 'test-service-id:test-queue',
|
|
230
232
|
source: 'retry',
|
|
231
233
|
},
|
|
232
|
-
'test-service-id
|
|
234
|
+
'test-service-id.test.routing.key': {
|
|
233
235
|
bindingKey: 'test-service-id.test.routing.key',
|
|
234
236
|
destination: 'test-service-id:test-queue',
|
|
235
237
|
source: 'event',
|
|
@@ -284,7 +286,7 @@ describe('RascalConfigBuilder', () => {
|
|
|
284
286
|
destination: 'test-service-id:test-queue',
|
|
285
287
|
source: 'retry',
|
|
286
288
|
},
|
|
287
|
-
'
|
|
289
|
+
'external-service-id.test.routing.key': {
|
|
288
290
|
bindingKey: 'external-service-id.test.routing.key',
|
|
289
291
|
destination: 'test-service-id:test-queue',
|
|
290
292
|
source: 'event',
|
|
@@ -336,7 +338,7 @@ describe('RascalConfigBuilder', () => {
|
|
|
336
338
|
destination: 'test-service-id:test-queue',
|
|
337
339
|
source: 'retry',
|
|
338
340
|
},
|
|
339
|
-
'test-service-id
|
|
341
|
+
'test-service-id.test.routing.key': {
|
|
340
342
|
bindingKey: 'test-service-id.test.routing.key',
|
|
341
343
|
destination: 'test-service-id:test-queue',
|
|
342
344
|
source: 'event',
|
|
@@ -392,7 +394,7 @@ describe('RascalConfigBuilder', () => {
|
|
|
392
394
|
destination: 'test-service-id:test-queue',
|
|
393
395
|
source: 'retry',
|
|
394
396
|
},
|
|
395
|
-
'test-service-id
|
|
397
|
+
'test-service-id.test.key': {
|
|
396
398
|
bindingKey: 'test-service-id.test.key',
|
|
397
399
|
destination: 'test-service-id:test-queue',
|
|
398
400
|
source: 'command',
|
|
@@ -460,14 +462,14 @@ describe('RascalConfigBuilder', () => {
|
|
|
460
462
|
destination: 'test-service-id:test-queue',
|
|
461
463
|
source: 'retry',
|
|
462
464
|
},
|
|
463
|
-
'test-service-id
|
|
465
|
+
'test-service-id.test.key': {
|
|
464
466
|
bindingKey: 'test-service-id.test.key',
|
|
465
|
-
destination: 'test-service-id:
|
|
467
|
+
destination: 'test-service-id:test-queue',
|
|
466
468
|
source: 'command',
|
|
467
469
|
},
|
|
468
|
-
'test-service-id
|
|
470
|
+
'test-service-id.test.key-2': {
|
|
469
471
|
bindingKey: 'test-service-id.test.key',
|
|
470
|
-
destination: 'test-service-id:test-queue',
|
|
472
|
+
destination: 'test-service-id:second-test-queue',
|
|
471
473
|
source: 'command',
|
|
472
474
|
},
|
|
473
475
|
},
|
|
@@ -36,16 +36,16 @@ interface AssertedVhostConfig {
|
|
|
36
36
|
*/
|
|
37
37
|
export class RascalConfigBuilder {
|
|
38
38
|
private transformers: ConfigTransformer = {};
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
protected currentServiceId: string;
|
|
40
|
+
protected destinationServiceId: string;
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* @param info an info object that contains general information about message type
|
|
44
44
|
* @param config general RabbitMQ configuration object
|
|
45
45
|
*/
|
|
46
46
|
constructor(
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
protected readonly info: MessagingSettings,
|
|
48
|
+
protected readonly config: MessagingConfig,
|
|
49
49
|
) {
|
|
50
50
|
this.currentServiceId = this.config.serviceId;
|
|
51
51
|
this.destinationServiceId = this.info.serviceId ?? this.config.serviceId;
|
|
@@ -72,7 +72,9 @@ export class RascalConfigBuilder {
|
|
|
72
72
|
* Builder extension method to build rascal configuration part, which enables sending commands for a specific messageType.
|
|
73
73
|
*/
|
|
74
74
|
public sendCommand(): RascalConfigBuilder {
|
|
75
|
-
|
|
75
|
+
// To send a command the sending service can ensure that queues and bindings
|
|
76
|
+
// exist to not depend on a specific service startup order to create command queues.
|
|
77
|
+
const queueName = this.getSendCommandQueueName();
|
|
76
78
|
this.addQueue(this.destinationServiceId, queueName);
|
|
77
79
|
this.addRetryBinding(queueName);
|
|
78
80
|
this.addMessagePublication('command');
|
|
@@ -115,9 +117,10 @@ export class RascalConfigBuilder {
|
|
|
115
117
|
): RascalConfigBuilder {
|
|
116
118
|
this.setBuildMessageHandler(buildMessageHandler);
|
|
117
119
|
|
|
118
|
-
// Queue is added for local (config) serviceId, but bindings are using routingKey with
|
|
120
|
+
// Queue is added for local (config) serviceId, but bindings are using routingKey with
|
|
121
|
+
// remote (info) serviceId or local (config) serviceId, if remote is not specified
|
|
119
122
|
const routingKey = `${this.destinationServiceId}.${this.info.routingKey}`;
|
|
120
|
-
const queueName =
|
|
123
|
+
const queueName = this.getSubscribeQueueName();
|
|
121
124
|
|
|
122
125
|
this.addQueue(this.currentServiceId, queueName);
|
|
123
126
|
this.addRetryBinding(queueName);
|
|
@@ -223,7 +226,7 @@ export class RascalConfigBuilder {
|
|
|
223
226
|
this.transformers[actionKey] = (cfg) => {
|
|
224
227
|
const vhost = this.getVhostReference(cfg);
|
|
225
228
|
|
|
226
|
-
vhost.subscriptions[this.
|
|
229
|
+
vhost.subscriptions[this.getSubscriptionKey()] = {
|
|
227
230
|
queue: queueName,
|
|
228
231
|
prefetch: 10,
|
|
229
232
|
recovery: 'deferred_retry',
|
|
@@ -270,8 +273,12 @@ export class RascalConfigBuilder {
|
|
|
270
273
|
|
|
271
274
|
this.transformers[actionKey] = (cfg) => {
|
|
272
275
|
const vhost = this.getVhostReference(cfg);
|
|
273
|
-
|
|
274
|
-
|
|
276
|
+
let bindingKey = routingKey;
|
|
277
|
+
let count = 2;
|
|
278
|
+
while (vhost.bindings[bindingKey]) {
|
|
279
|
+
bindingKey = `${bindingKey}-${count++}`;
|
|
280
|
+
}
|
|
281
|
+
vhost.bindings[bindingKey] = {
|
|
275
282
|
source: type,
|
|
276
283
|
bindingKey: routingKey,
|
|
277
284
|
destination: queueName,
|
|
@@ -279,4 +286,16 @@ export class RascalConfigBuilder {
|
|
|
279
286
|
return cfg;
|
|
280
287
|
};
|
|
281
288
|
}
|
|
289
|
+
|
|
290
|
+
protected getSubscribeQueueName(): string {
|
|
291
|
+
return `${this.currentServiceId}:${this.info.queue}`;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
protected getSendCommandQueueName(): string {
|
|
295
|
+
return `${this.destinationServiceId}:${this.info.queue}`;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
protected getSubscriptionKey(): string {
|
|
299
|
+
return this.info.messageType;
|
|
300
|
+
}
|
|
282
301
|
}
|
|
@@ -12,10 +12,18 @@
|
|
|
12
12
|
"type": "string",
|
|
13
13
|
"format": "date-time"
|
|
14
14
|
},
|
|
15
|
+
"aggregate_type": {
|
|
16
|
+
"description": "Type of the aggregate root e.g. movie",
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
15
19
|
"message_type": {
|
|
16
20
|
"description": "Type of the message e.g. SomeActionFinished",
|
|
17
21
|
"type": "string"
|
|
18
22
|
},
|
|
23
|
+
"aggregate_id": {
|
|
24
|
+
"description": "The unique identifier of the aggregate",
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
19
27
|
"message_version": {
|
|
20
28
|
"description": "Message version inside the payload.",
|
|
21
29
|
"type": "string",
|
|
@@ -38,6 +46,7 @@
|
|
|
38
46
|
"message_id",
|
|
39
47
|
"timestamp",
|
|
40
48
|
"message_type",
|
|
49
|
+
"aggregate_type",
|
|
41
50
|
"message_version",
|
|
42
51
|
"payload"
|
|
43
52
|
]
|
package/src/subscription.spec.ts
CHANGED
|
@@ -255,8 +255,10 @@ describe('Subscription', () => {
|
|
|
255
255
|
});
|
|
256
256
|
const envelope: MessageEnvelope = {
|
|
257
257
|
message_id: 'testMessageId',
|
|
258
|
-
timestamp: new Date().toISOString(),
|
|
259
258
|
message_type: 'TestMessageType',
|
|
259
|
+
aggregate_id: '1',
|
|
260
|
+
aggregate_type: 'test',
|
|
261
|
+
timestamp: new Date().toISOString(),
|
|
260
262
|
message_version: '1.0',
|
|
261
263
|
message_context: {},
|
|
262
264
|
auth_token:
|
|
@@ -297,6 +299,8 @@ describe('Subscription', () => {
|
|
|
297
299
|
message_context: envelope.message_context,
|
|
298
300
|
message_id: envelope.message_id,
|
|
299
301
|
message_type: envelope.message_type,
|
|
302
|
+
aggregate_id: '1',
|
|
303
|
+
aggregate_type: 'test',
|
|
300
304
|
message_version: envelope.message_version,
|
|
301
305
|
payload: envelope.payload,
|
|
302
306
|
timestamp: envelope.timestamp,
|
|
@@ -319,8 +323,10 @@ describe('Subscription', () => {
|
|
|
319
323
|
});
|
|
320
324
|
const envelope: MessageEnvelope = {
|
|
321
325
|
message_id: 'testMessageId',
|
|
322
|
-
timestamp: new Date().toISOString(),
|
|
323
326
|
message_type: 'TestMessageType',
|
|
327
|
+
aggregate_id: '1',
|
|
328
|
+
aggregate_type: 'test',
|
|
329
|
+
timestamp: new Date().toISOString(),
|
|
324
330
|
message_version: '1.0',
|
|
325
331
|
message_context: {},
|
|
326
332
|
auth_token: 'invalid_token_value',
|
|
@@ -344,6 +350,8 @@ describe('Subscription', () => {
|
|
|
344
350
|
message_context: envelope.message_context,
|
|
345
351
|
message_id: envelope.message_id,
|
|
346
352
|
message_type: envelope.message_type,
|
|
353
|
+
aggregate_id: '1',
|
|
354
|
+
aggregate_type: 'test',
|
|
347
355
|
message_version: envelope.message_version,
|
|
348
356
|
payload: envelope.payload,
|
|
349
357
|
timestamp: envelope.timestamp,
|
|
@@ -10,12 +10,20 @@ export interface MessageEnvelope<TContent = unknown> {
|
|
|
10
10
|
* Time and date (UTC) when the message was published.
|
|
11
11
|
*/
|
|
12
12
|
timestamp: string;
|
|
13
|
+
/**
|
|
14
|
+
* The type of the aggregate (in DDD context) or entity for which this message is sent
|
|
15
|
+
*/
|
|
16
|
+
aggregate_type: string;
|
|
13
17
|
/**
|
|
14
18
|
* Type of the message e.g. ContentPublishEvent
|
|
15
19
|
*/
|
|
16
20
|
message_type: string;
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* The unique identifier of the aggregate
|
|
23
|
+
*/
|
|
24
|
+
aggregate_id: string;
|
|
25
|
+
/**
|
|
26
|
+
* Version of the format of the payload field.
|
|
19
27
|
*/
|
|
20
28
|
message_version: string;
|
|
21
29
|
/**
|