This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run --name rabbitmq -p 5672:5672 rabbitmq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"publish": "node producer.js", | |
"consume": "node consumer.js" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ampq = require('amqplib'); | |
const connect = async () => { | |
try { | |
// Connect to RabbitMQ | |
const connection = await ampq.connect('amqp://localhost:5672'); | |
// Create channel | |
const channel = await connection.createChannel(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ampq = require('amqplib'); | |
// Get text from command line | |
const text = process.argv[2] || 'Nothing to do.'; | |
const connect = async () => { | |
try { | |
// Connect to RabbitMQ | |
const connection = await ampq.connect('amqp://localhost:5672'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm i amqplib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Kafka } = require('kafkajs'); | |
const run = async () => { | |
try { | |
const kafka = new Kafka({ | |
clientId: 'kafkaApp', | |
brokers: ['127.0.0.1:9092'], | |
}); | |
const consumer = kafka.consumer({ groupId: 'teamA' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Kafka } = require('kafkajs'); | |
const run = async () => { | |
try { | |
const kafka = new Kafka({ | |
clientId: 'kafkaApp', | |
brokers: ['127.0.0.1:9092'], | |
}); | |
const producer = kafka.producer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Kafka } = require('kafkajs'); | |
const run = async () => { | |
try { | |
const kafka = new Kafka({ | |
clientId: 'kafkaApp', | |
brokers: ['127.0.0.1:9092'], | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker run --name kafka -p 9092:9092 \ | |
-e KAFKA_ZOOKEEPER_CONNECT=172.17.0.2:2181 \ | |
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092 \ | |
-e KAFKA_OFFSETS_TOPICS_REPLICATION_FACTOR=1 confluentinc/cp-kafka |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker inspect zookeeper --format='{{ .NetworkSettings.IPAddress}}' | |
> 172.17.0.2 |
NewerOlder