|
1 | 1 | // @flow
|
| 2 | +import type { PublishOptions } from 'amqplib'; |
2 | 3 | import AMQPMessageController from './AMQPMessageController';
|
3 | 4 | import AMQPMessage from './AMQPMessage';
|
4 | 5 | import RpcService from './Service';
|
@@ -30,24 +31,47 @@ class AMQPMessageRpcController extends AMQPMessageController {
|
30 | 31 | }
|
31 | 32 |
|
32 | 33 | async resendAsRetry() {
|
33 |
| - const { messageId, correlationId, replyTo } = this._message.props; |
34 |
| - |
35 | 34 | const retryLimit = this._message.applicationLevelRetryLimit;
|
36 | 35 |
|
37 | 36 | if (retryLimit === null) {
|
38 | 37 | throw new Error('Retry disabled');
|
39 | 38 | }
|
40 | 39 |
|
41 | 40 | const adapter = this._service._getAdapter();
|
42 |
| - await adapter.send(this._message.sourceQueue, this._message.payload, { |
43 |
| - messageId, |
44 |
| - correlationId, |
45 |
| - replyTo, |
| 41 | + |
| 42 | + await adapter.send( |
| 43 | + this._message.sourceQueue, |
| 44 | + this._message.payload, |
| 45 | + this._getPublishOptionsForRetry(), |
| 46 | + ); |
| 47 | + } |
| 48 | + |
| 49 | + _getPublishOptionsForRetry() { |
| 50 | + const { props, applicationLevelRetryLimit } = this._message; |
| 51 | + |
| 52 | + // @todo decremnt expiration |
| 53 | + // @todo pass routing key |
| 54 | + const mapped: PublishOptions = { |
| 55 | + expiration: props.expiration, |
| 56 | + correlationId: props.correlationId, |
| 57 | + replyTo: props.replyTo, |
| 58 | + exchange: props.exchange, |
| 59 | + userId: props.userId, |
| 60 | + priority: props.priority, |
| 61 | + persistent: props.persistent, |
| 62 | + contentType: props.contentType, |
| 63 | + contentEncoding: props.contentEncoding, |
| 64 | + timestamp: props.timestamp, |
| 65 | + type: props.type, |
| 66 | + appId: props.appId, |
| 67 | + messageId: props.messageId, |
46 | 68 | headers: {
|
47 |
| - ...this._message.props.headers, |
48 |
| - 'X-Retry-Limit': retryLimit, |
| 69 | + ...props.headers, |
| 70 | + 'X-Retry-Limit': applicationLevelRetryLimit, |
49 | 71 | },
|
50 |
| - }); |
| 72 | + }; |
| 73 | + |
| 74 | + return mapped; |
51 | 75 | }
|
52 | 76 | }
|
53 | 77 |
|
|
0 commit comments