@@ -8,11 +8,10 @@ const nock = require('nock');
88
99const env = process . env ;
1010
11-
1211class AmqpHelper extends EventEmitter {
13-
1412 constructor ( ) {
1513 super ( ) ;
14+
1615 this . httpReplyQueueName = PREFIX + 'request_reply_queue' ;
1716 this . httpReplyQueueRoutingKey = PREFIX + 'request_reply_routing_key' ;
1817 this . nextStepQueue = PREFIX + '_next_step_queue' ;
@@ -37,11 +36,11 @@ class AmqpHelper extends EventEmitter {
3736 return this . subscriptionChannel . publish (
3837 env . ELASTICIO_LISTEN_MESSAGES_ON ,
3938 env . ELASTICIO_DATA_ROUTING_KEY ,
40- new Buffer ( JSON . stringify ( message ) ) ,
41- {
39+ new Buffer ( JSON . stringify ( message ) ) , {
4240 headers : Object . assign ( {
4341 execId : env . ELASTICIO_EXEC_ID ,
4442 taskId : env . ELASTICIO_FLOW_ID ,
43+ workspaceId : env . ELASTICIO_WORKSPACE_ID ,
4544 userId : env . ELASTICIO_USER_ID ,
4645 threadId,
4746 messageId : parentMessageId
@@ -62,6 +61,7 @@ class AmqpHelper extends EventEmitter {
6261 durable : true ,
6362 autoDelete : false
6463 } ;
64+
6565 yield subscriptionChannel . assertExchange ( env . ELASTICIO_LISTEN_MESSAGES_ON , 'direct' , exchangeOptions ) ;
6666 yield publishChannel . assertExchange ( env . ELASTICIO_PUBLISH_MESSAGES_TO , 'direct' , exchangeOptions ) ;
6767
@@ -114,11 +114,13 @@ class AmqpHelper extends EventEmitter {
114114 that . consumer . bind ( that , that . nextStepQueue ) ,
115115 { consumerTag : 'sailor_nodejs_1' }
116116 ) ;
117+
117118 yield that . publishChannel . consume (
118119 that . nextStepErrorQueue ,
119120 that . consumer . bind ( that , that . nextStepErrorQueue ) ,
120121 { consumerTag : 'sailor_nodejs_2' }
121122 ) ;
123+
122124 yield that . publishChannel . consume (
123125 that . httpReplyQueueName ,
124126 that . consumer . bind ( that , that . httpReplyQueueName ) ,
@@ -128,7 +130,6 @@ class AmqpHelper extends EventEmitter {
128130 }
129131
130132 consumer ( queue , message ) {
131-
132133 this . publishChannel . ack ( message ) ;
133134
134135 const emittedMessage = JSON . parse ( message . content . toString ( ) ) ;
@@ -138,22 +139,19 @@ class AmqpHelper extends EventEmitter {
138139 body : emittedMessage . body ,
139140 emittedMessage
140141 } ;
142+
141143 this . dataMessages . push ( data ) ;
142144 this . emit ( 'data' , data , queue ) ;
143145
144146 // publishChannel.cancel('sailor_nodejs');
145-
146147 // done();
147-
148148 }
149149}
150150
151151function amqp ( ) {
152-
153152 const handle = {
154153 //eslint-disable-next-line no-empty-function
155154 getMessages ( ) {
156-
157155 }
158156 } ;
159157 return handle ;
@@ -166,6 +164,9 @@ function prepareEnv() {
166164 env . ELASTICIO_STEP_ID = 'step_1' ;
167165 env . ELASTICIO_EXEC_ID = 'some-exec-id' ;
168166
167+ env . ELASTICIO_WORKSPACE_ID = '5559edd38968ec073600683' ;
168+ env . ELASTICIO_CONTAINER_ID = 'dc1c8c3f-f9cb-49e1-a6b8-716af9e15948' ;
169+
169170 env . ELASTICIO_USER_ID = '5559edd38968ec0736000002' ;
170171 env . ELASTICIO_COMP_ID = '5559edd38968ec0736000456' ;
171172
@@ -177,8 +178,6 @@ function prepareEnv() {
177178 env . ELASTICIO_FLOW_WEBHOOK_URI = 'https://in.elastic.io/hooks/' + env . ELASTICIO_FLOW_ID ;
178179
179180 env . DEBUG = 'sailor:debug' ;
180-
181-
182181}
183182
184183function mockApiTaskStepResponse ( response ) {
@@ -205,4 +204,3 @@ exports.amqp = function amqp() {
205204
206205exports . prepareEnv = prepareEnv ;
207206exports . mockApiTaskStepResponse = mockApiTaskStepResponse ;
208-
0 commit comments