Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support of object storage on error #97

Open
wants to merge 4 commits into
base: elasticio-1456-add-maester-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/amqp.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ class Amqp {
const payload = {
error: encryptedError
};

if (originalMessageContent && originalMessageContent !== '') {
if (headers.objectId) {
VitaliyKovalchuk marked this conversation as resolved.
Show resolved Hide resolved
payload.objectId = headers.objectId;
} else if (originalMessageContent && originalMessageContent !== '') {
payload.errorInput = originalMessageContent.toString();
}
const errorPayload = JSON.stringify(payload);
Expand Down
44 changes: 44 additions & 0 deletions spec/amqp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,50 @@ describe('AMQP', () => {
expect(publishParameters[3]).toEqual(props);
});

it('Should send objectId instead of message when process error', () => {
VitaliyKovalchuk marked this conversation as resolved.
Show resolved Hide resolved

const amqp = new Amqp(settings);
const objectId = 'aef703e0-7ebf-456f-a7b9-20b647ab43cd';
amqp.publishChannel = jasmine.createSpyObj('publishChannel', ['publish']);


const props = {
contentType: 'application/json',
contentEncoding: 'utf8',
mandatory: true,
headers: {
objectId,
taskId: 'task1234567890',
stepId: 'step_456'
}
};

amqp.sendError(new Error('Test error'), props, message.content);

expect(amqp.publishChannel.publish).toHaveBeenCalled();
expect(amqp.publishChannel.publish.callCount).toEqual(1);

const publishParameters = amqp.publishChannel.publish.calls[0].args;
expect(publishParameters).toEqual([
settings.PUBLISH_MESSAGES_TO,
settings.ERROR_ROUTING_KEY,
jasmine.any(Object),
props
]);

const payload = JSON.parse(publishParameters[2].toString());
payload.error = encryptor.decryptMessageContent(payload.error);

expect(payload).toEqual({
error: {
name: 'Error',
message: 'Test error',
stack: jasmine.any(String)
},
objectId
});
});

it('Should send message to rebounds when rebound happened', () => {

const amqp = new Amqp(settings);
Expand Down