- 浏览: 2539526 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
NodeJS work with ActiveMQ(1)Basic Connect to Local ActiveMQ
Long time ago, I am using activeMQ, that is 15 years back, old days in Alibaba? Hudsun? Taobao? Alipay? China telecom? I can not remember, but that is really long time ago.
Today, I will try to use TypeScript under server less framework in AWS Lambda to connect to ActiveMQ as a producer. Yeah. Enjoy coding.
First of all, Set Up an ActiveMQ Server on Local
Old Old Home Page http://activemq.apache.org/
http://activemq.apache.org/web-console.html
I am using the Mac OS, so I will try the package http://apache.mirrors.pair.com//activemq/5.15.7/apache-activemq-5.15.7-bin.tar.gz
Unzip and move the file to the working directory
> sudo ln -s /Users/hluo/tool/apache-activemq-5.15.7 /opt/apache-activemq-5.15.7
> sudo ln -s /opt/apache-activemq-5.15.7 /opt/activemq
http://activemq.apache.org/getting-started.html
Start the service in the foreground
> cd /opt/activemq
> bin/activemq console
ActiveMQ WebConsole available at http://0.0.0.0:8161/
ActiveMQ Jolokia REST API available at http://0.0.0.0:8161/api/jolokia/
We can also start the activeMQ on the background
> bin/activemq start
Visit the web console here http://127.0.0.1:8161/admin/
We can easily create a queue and test message sending.
Command to stop the service
> bin/activemq stop
Connect to ActiveMQ with NodeJS
STOMP protocol - Streaming Text Orientated Message Protocol: SEND, SUBSCRIBE, UNSUBSCRIBE, BEGIN, COMMIT, ABORT, ACK, DISCONNECT.
On the official website, there is one I can try https://github.com/gdaws/node-stomp
API document is here http://gdaws.github.io/node-stomp/api/
Ports information http://activemq.apache.org/nms/stomp-uri-configuration.html
Default Port is 61616, JAVA Client is connecting as follow:
package com.sillycat.feeds2g;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
public class ActiveMQApp {
public static void main(String[] args) throws JMSException {
Connection connection;
Session session;
MessageProducer producer;
String url = "failover:(tcp://localhost:61616)";
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(session.createQueue("dwh_datawarehouse" + "," + "dwh_datawarehouse-raw"));
Message msg = session.createTextMessage("test connection to the server");
producer.send(msg);
producer.close();
session.close();
connection.close();
}
}
Package dependency is as follow:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.15.7</version>
</dependency>
STOMP in nodeJS is doing as follow:
var stompit = require('stompit');
var connectOptions = {
'host': 'localhost',
'port': 61613,
'timeout': 6000,
'connectHeaders':{
'host': '/',
//'login': 'username',
//'passcode': 'password',
'heart-beat': '5000,5000'
}
};
stompit.connect(connectOptions, function(error, client) {
if (error) {
console.log('connect error ' + error.message);
return;
}
var sendHeaders = {
'destination': '/queue/dwh_datawarehouse',
'content-type': 'text/plain'
};
var frame = client.send(sendHeaders);
frame.write('hello from nodejs' + new Date());
frame.end();
client.disconnect();
});
Here is the package dependency
"stompit": "0.26.0"
There are maybe more things need to care about, but we can check the documents here http://gdaws.github.io/node-stomp/api/
References:
http://activemq.apache.org/cross-language-clients.html
https://blog.csdn.net/qq_37398530/article/details/78140371
https://medium.com/@mackplevine/using-activemq-with-node-js-stomp-and-http-b251ce8d995
https://simplesassim.wordpress.com/2016/03/13/how-to-send-a-message-to-an-apache-activemq-queue-with-node-js/
STOMP
https://blog.csdn.net/chszs/article/details/5200554
Monitor tool
http://activemq.apache.org/how-can-i-monitor-activemq.html
100 years ago
http://sillycat.iteye.com/blog/563655
http://sillycat.iteye.com/blog/562675
http://sillycat.iteye.com/blog/1028467
https://www.soapui.org/documentation/jms/config.html
http://activemq.apache.org/hermes-jms.html
Long time ago, I am using activeMQ, that is 15 years back, old days in Alibaba? Hudsun? Taobao? Alipay? China telecom? I can not remember, but that is really long time ago.
Today, I will try to use TypeScript under server less framework in AWS Lambda to connect to ActiveMQ as a producer. Yeah. Enjoy coding.
First of all, Set Up an ActiveMQ Server on Local
Old Old Home Page http://activemq.apache.org/
http://activemq.apache.org/web-console.html
I am using the Mac OS, so I will try the package http://apache.mirrors.pair.com//activemq/5.15.7/apache-activemq-5.15.7-bin.tar.gz
Unzip and move the file to the working directory
> sudo ln -s /Users/hluo/tool/apache-activemq-5.15.7 /opt/apache-activemq-5.15.7
> sudo ln -s /opt/apache-activemq-5.15.7 /opt/activemq
http://activemq.apache.org/getting-started.html
Start the service in the foreground
> cd /opt/activemq
> bin/activemq console
ActiveMQ WebConsole available at http://0.0.0.0:8161/
ActiveMQ Jolokia REST API available at http://0.0.0.0:8161/api/jolokia/
We can also start the activeMQ on the background
> bin/activemq start
Visit the web console here http://127.0.0.1:8161/admin/
We can easily create a queue and test message sending.
Command to stop the service
> bin/activemq stop
Connect to ActiveMQ with NodeJS
STOMP protocol - Streaming Text Orientated Message Protocol: SEND, SUBSCRIBE, UNSUBSCRIBE, BEGIN, COMMIT, ABORT, ACK, DISCONNECT.
On the official website, there is one I can try https://github.com/gdaws/node-stomp
API document is here http://gdaws.github.io/node-stomp/api/
Ports information http://activemq.apache.org/nms/stomp-uri-configuration.html
Default Port is 61616, JAVA Client is connecting as follow:
package com.sillycat.feeds2g;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
public class ActiveMQApp {
public static void main(String[] args) throws JMSException {
Connection connection;
Session session;
MessageProducer producer;
String url = "failover:(tcp://localhost:61616)";
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(session.createQueue("dwh_datawarehouse" + "," + "dwh_datawarehouse-raw"));
Message msg = session.createTextMessage("test connection to the server");
producer.send(msg);
producer.close();
session.close();
connection.close();
}
}
Package dependency is as follow:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.15.7</version>
</dependency>
STOMP in nodeJS is doing as follow:
var stompit = require('stompit');
var connectOptions = {
'host': 'localhost',
'port': 61613,
'timeout': 6000,
'connectHeaders':{
'host': '/',
//'login': 'username',
//'passcode': 'password',
'heart-beat': '5000,5000'
}
};
stompit.connect(connectOptions, function(error, client) {
if (error) {
console.log('connect error ' + error.message);
return;
}
var sendHeaders = {
'destination': '/queue/dwh_datawarehouse',
'content-type': 'text/plain'
};
var frame = client.send(sendHeaders);
frame.write('hello from nodejs' + new Date());
frame.end();
client.disconnect();
});
Here is the package dependency
"stompit": "0.26.0"
There are maybe more things need to care about, but we can check the documents here http://gdaws.github.io/node-stomp/api/
References:
http://activemq.apache.org/cross-language-clients.html
https://blog.csdn.net/qq_37398530/article/details/78140371
https://medium.com/@mackplevine/using-activemq-with-node-js-stomp-and-http-b251ce8d995
https://simplesassim.wordpress.com/2016/03/13/how-to-send-a-message-to-an-apache-activemq-queue-with-node-js/
STOMP
https://blog.csdn.net/chszs/article/details/5200554
Monitor tool
http://activemq.apache.org/how-can-i-monitor-activemq.html
100 years ago
http://sillycat.iteye.com/blog/563655
http://sillycat.iteye.com/blog/562675
http://sillycat.iteye.com/blog/1028467
https://www.soapui.org/documentation/jms/config.html
http://activemq.apache.org/hermes-jms.html
发表评论
-
Stop Update Here
2020-04-28 09:00 310I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 465NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 361Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 363Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 328Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 419Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 364Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 444VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 376Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 464NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 413Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 330Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 242GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 443GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 320GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 306Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 284Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 302Serverless with NodeJS and Tenc ...
相关推荐
这个"NodeJS packages with basic modules"的压缩包可能包含了NodeJS的基础模块,使得初学者或者开发者能够快速搭建一个具备基本功能的开发环境。 **npm(Node Package Manager)**是NodeJS的包管理器,它允许...
一个用NodeJS实现的Ftp Servce
nodejs老版本,10.24.1
nodejs14.9.0
# node -v v10.24.1 # npm -v 6.14.12
speech-to-text-nodejs, IBM Watson语音到文本服务的样例 node.js 应用程序 向文本浏览器应用程序添加语音 在文本转换中使用了ibm的语音识别功能来将多种语言中的语音转换成文本,从而实现文本的转换。 传入音频的...
nodejs老版本,10.24.1x86
主要介绍了如何让Nodejs支持H5 History模式(connect-history-api-fallback源码分析),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
nodejs_basic
nodejs初级教程
由于使用最新版本的nodejs安装,然后再HBuilderX安装npm install时出现,提示如下: npm ERR! gyp ERR! node -v v16.14.2 npmERR! gyp ERR! node-gyp -v v3.8.0 npm ERR! gyp ERR! not ok 原因:由于项目和版本...
用于Express / Connect的CAS客户端中间件的完整实现,支持CAS 2.0+协议。 CAS(中央身份验证服务)是Web的单点登录/单点退出协议。 我们假设您已经熟悉CAS协议,如果不熟悉,请在使用前阅读本。 安装 npm install...
节点js NodeJS示例项目
1. NPM(Node Package Manager):NodeJS的包管理器,用于安装、管理和共享第三方模块,是NodeJS生态的重要组成部分。 2. Express框架:简化了Web应用开发,提供了路由、中间件等功能,是NodeJS最流行的Web框架之一...
首先,`NodeJS第1天笔记.docx`很可能是对NodeJS基础概念的介绍,包括但不限于以下几点: 1. **事件驱动模型**:NodeJS的核心特性之一是其事件驱动非阻塞I/O模型,这使得NodeJS在处理大量并发连接时表现优秀。 2. **...
1. 安装与环境配置:NodeJS的安装过程相对简单,可以在官网下载对应操作系统的安装包,按照指引进行安装。安装完成后,可以使用`node -v`命令检查版本,`npm -v`检查npm(Node Package Manager)版本。 2. 第一个...