이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 4. Examples
This chapter demonstrates the use of AMQ JavaScript through example programs. To run them, make sure you have completed the steps in the Chapter 2, Installation chapter for your environment and you have a running and configured broker.
See the Rhea examples for more sample programs. Note that some of the sample programs there require the minimist package in order to parse command-line options.
4.1. Sending Messages 링크 복사링크가 클립보드에 복사되었습니다!
This client program connects to a server using CONNECTION_URL
, creates a sender for target ADDRESS
, sends a message containing MESSAGE_BODY
, closes the connection, and exits.
Example: Sending Messages
Running the Example
To run the example program, copy it to a local file and invoke it using the node
command.
node send.js amqp://localhost queue1 hello
$ node send.js amqp://localhost queue1 hello
4.2. Receiving Messages 링크 복사링크가 클립보드에 복사되었습니다!
This client program connects to a server using CONNECTION_URL
, creates a receiver for source ADDRESS
, and receives messages until it is terminated or it reaches COUNT
messages.
Example: Receiving Messages
Running the Example
To run the example program, copy it to a local file and invoke it using the python
command.
node receive.js amqp://localhost queue1
$ node receive.js amqp://localhost queue1