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

RPC: how can I send multiples messages to some queue (error reply consumer already set) #51

Open
cocodrino opened this issue Jul 11, 2020 · 0 comments

Comments

@cocodrino
Copy link

cocodrino commented Jul 11, 2020

Hi, I'm not sure if I'm doing a noob mistake here, my code is something like this

  const connection = await new amqp.Connection("amqp://...");
  const queue = await connection.declareQueue('rpc_queue', {durable: false});
  const numbers = [5, 10, 15, 20];


  console.time("calc");
    // eslint-disable-next-line id-length
  const calc = numbers.map((n) => queue.rpc(n));
  const results : amqp.Message[] = await Promise.all(calc);
  results.forEach((response) => {
    console.info("getting value ", response.getContent());
  });
  console.timeEnd("calc");

and I'm getting

(node:81089) UnhandledPromiseRejectionWarning: Error: amqp-ts: Queue.rpc error: Operation failed: BasicConsume; 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED - reply consumer already set"
    at /Users/Admin/Downloads/proj/avanti/bita_dashboard_websocket_backend/node_modules/amqp-ts/lib/amqp-ts.js:804:32
    at /Users/Admin/Downloads/proj/avanti/bita_dashboard_websocket_backend/node_modules/amqp-ts/node_modules/amqplib/lib/callback_model.js:61:10
    at /Users/Admin/Downloads/proj/avanti/bita_dashboard_websocket_backend/node_modules/amqp-ts/node_modules/amqplib/lib/callback_model.js:189:12
    at reply (/Users/Admin/Downloads/proj/avanti/bita_dashboard_websocket_backend/node_modules/amqp-ts/node_modules/amqplib/lib/channel.js:127:14)
    at Channel.C.accept (/Users/Admin/Downloads/proj/avanti/bita_dashboard_websocket_backend/node_modules/amqp-ts/node_modules/amqplib/lib/channel.js:401:7)
    at Connection.mainAccept [as accept] (/Users/Admin/Downloads/proj/avanti/bita_dashboard_websocket_backend/node_modules/amqp-ts/node_modules/amqplib/lib/connection.js:63:33)
    at Socket.go (/Users/Admin/Downloads/proj/avanti/bita_dashboard_websocket_backend/node_modules/amqp-ts/node_modules/amqplib/lib/connection.js:476:48)
    at Socket.emit (events.js:210:5)
    at Socket.EventEmitter.emit (domain.js:475:20)
    at emitReadable_ (_stream_readable.js:575:12)
    at processTicksAndRejections (internal/process/task_queues.js:79:21)
(node:81089) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:81089) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

it's possible achieve something like what am I trying or it's not possible? thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant