activemq

ActiveMQ使用示例之Topic

心不动则不痛 提交于 2020-01-16 23:03:57
非持久的Topic消息示例 对于非持久的Topic消息的发送 基本跟前面发送队列信息是一样的,只是把创建Destination的地方,由创 建队列替换成创建Topic,例如: Destination destination = session.createTopic("MyTopic"); 对于非持久的Topic消息的接收 1:必须要接收方在线,然后客户端再发送信息,接收方才能接收到消息 2:同样把创建Destination的地方,由创建队列替换成创建Topic,例如: Destination destination = session.createTopic("MyTopic"); 3:由于不知道客户端发送多少信息,因此改成while循环的方式了,例如: Message message = consumer.receive(); while(message!=null) {   TextMessage txtMsg = (TextMessage)message;   System.out.println("收到消 息:" + txtMsg.getText());   message = consumer.receive(1000L); } 生产者代码: public class NoPersistenceSender { //默认连接用户名 private static

ActiveMQ的安装

…衆ロ難τιáo~ 提交于 2020-01-16 23:00:56
https://yq.aliyun.com/articles/259278?spm=5176.100239.blogcont347819.32.6053cfd8sFudDo https://yq.aliyun.com/articles/346712?spm=5176.100239.blogcont259278.18.1f39f5f7FnyLkN 一、ActiveMQ介绍   1.ActiveMQ简介 MQ,即Message Queue,消息队列。    ActiveMQ,是Apache出品,最流行的,能力强劲的开源消息总线 。ActiveMQ 是一个完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现,尽管JMS规范出台已经是很久的事情了,但是JMS在当今的J2EE应用中间仍然扮演着特殊的地位。   2.JMS简介 JMS的全称是Java Message Service,即Java消息服务。 用于在两个应用程序之间,或分布式系统中发送消息,进行异步通信。 它主要用于在生产者和消费者之间进行消息传递,生产者负责产生消息,而消费者负责接收消息。把它应用到实际的业务需求中的话我们可以在特定的时候利用生产者生成一消息,并进行发送,对应的消费者在接收到对应的消息后去完成对应的业务逻辑。 对于消息的传递有两种类型: 一种是点对点的,即一个生产者和一个消费者一一对应;   

ActiveMQ简述

旧巷老猫 提交于 2020-01-16 22:58:58
概述 ActiveMQ是Apache所提供的一个开源的消息系统,全然採用Java来实现。因此。它能非常好地支持J2EE提出的JMS(Java Message Service,即Java消息服务)规范。 JMS是一组Java应用程序接口。它提供消息的创建、发送、读取等一系列服务。JMS提供了一组公共应用程序接口和响应的语法。相似于Java数据库的统一訪问接口JDBC,它是一种与厂商无关的API,使得Java程序能够与不同厂商的消息组件非常好地进行通信。 JMS支持两种消息发送和接收模型。一种称为P2P(Ponit to Point)模型。即採用点对点的方式发送消息。P2P模型是基于队列的,消息生产者发送消息到队列。消息消费者从队列中接收消息,队列的存在使得消息的异步传输称为可能,P2P模型在点对点的情况下进行消息传递时採用。 还有一种称为Pub/Sub(Publish/Subscribe,即公布-订阅)模型,公布-订阅模型定义了怎样向一个内容节点公布和订阅消息,这个内容节点称为topic(主题)。主题能够觉得是消息传递的中介,消息公布这将消息公布到某个主题,而消息订阅者则从主题订阅消息。主题使得消息的订阅者与消息的公布者互相保持独立。不须要进行接触就可以保证消息的传递,公布-订阅模型在消息的一对多广播时採用。 ActiveMQ的安装 下载最新的安装包apache-activemq-5

JMS【三】--ActiveMQ简单的HelloWorld实例

て烟熏妆下的殇ゞ 提交于 2020-01-16 22:49:26
第一篇博文 JMS【一】--JMS基本概念 ,我们介绍了JMS的两种消息模型:点对点和发布订阅模型,以及消息被消费的两个方式:同步和异步,JMS编程模型的对象,最后说了JMS的优点。 第二篇博文 JMS【二】--ActiveMQ简单介绍以及安装 ,我们介绍了消息中间件ActiveMQ,安装,启动,以及优缺点。 这篇博文,我们使用ActiveMQ为大家实现一种点对点的消息模型。如果你对点对点模型的认识较浅,可以看一下第一篇博文的介绍。 JMS其实并没有想象的那么高大上,看完这篇博文之后,你就知道什么叫简单,下面直接进入主题。 1、开发环境   我们使用的是ActiveMQ 5.11.1 Release的Windows版,官网最新版是ActiveMQ 5.12.0 Release,大家可以自行下载, 下载地址 。   需要注意的是,开发时候,要将apache-activemq-5.11.1-bin.zip解压缩后里面的activemq-all-5.11.1.jar包加入到classpath下面,这个包包含了所有jms接口api的实现。 2、搭建开发环境 建立项目 我们只需要建立一个java项目就可以了,导入jar包,项目截图:   点对点的消息模型,只需要一个消息生成者和消息消费者,下面我们编写代码。 编写生产者 1 package com.tgb.activemq; 2 3

Complete Async web service communication - sender and receiver are not available same time

China☆狼群 提交于 2020-01-16 08:59:17
问题 Two systems are talking to each other through integration(Using apache-camel). Let say system A needs to submit a request to System B which has exposed a web service to receive data and integration is transforming data as per system B web service. In above scenario A and B has to be available same time and A will have to wait for response from B. I need to remove this dependency by putting queue at integration layer and with Async communication. Ex: <camel:route id="AtoIntegration"> <camel

activemq常用配置

安稳与你 提交于 2020-01-15 17:03:03
所用版本为apache-activemq-5.15.4的版本 修改端口号 当端口号冲突时,可以修改这两个端口号。修改activemq.xml 修改里面的61616端口。修改jetty.xml,修改里面的8161端口。 两个配置文件均位于/usr/local/apache-activemq-5.15.4/conf文件夹下 activemq.xml jetty.xml 开启mq管理页面密码 修改jetty.xml中的 <property name="authenticate" value="true" /> 为true 控制台的登录用户名密码保存在conf/jetty-realm.properties文件中,内容如下: 用户名和密码的格式是 用户名 : 密码 ,角色名 来源: https://www.cnblogs.com/miye/p/9399501.html

JMS encoded message selector not matching when using special characters

对着背影说爱祢 提交于 2020-01-15 11:44:10
问题 I have 2 applications (client and server) using a request-reply pattern. The client sends a request to the server the message ID is set to something like this: ID=Hostname-52991-1357677886768-3:1:2:1:1 . Now the client has to listen to a message with a correlation ID set to the same value. Since the value contains special characters (:) I have to encode the value (using UTF-8). Sets the JMS Selector, which is an SQL 92 predicate that is used to filter messages within the broker. You may have

ActiveMQ get number of consumers listening to a topic from java

﹥>﹥吖頭↗ 提交于 2020-01-14 07:44:10
问题 I would like to be able to get the number of consumers listening to a topic from java for an embedded ActiveMQ (5.4.2) broker in the same JVM. Is JMX really the only option here? JMX seems like a bad option since it may be optionally disabled. This post shows how to use JMX to get a list of connections: ActiveMQ: Get list of connections through JMX? I would prefer a non-JMX based solution though due to it perhaps being disabled. I guess JMX would be ok if it was still usable from java when

ActiveMQ C++ Synchronous consumer

▼魔方 西西 提交于 2020-01-14 06:26:06
问题 There are some code samples for ActiveMQ C++ Client, which are asynchronous. What I am looking for is synchronous consumer. I just want to send and get messages. The code I have pointed out uses asynchronous and not sure how to make a synchronous class out of it. MessageConsumer class indicates that there is a synchronous call, ie: recieve(). When i call this on my object it fails as follows, how can i fix this? how can i just call a recieve from queue. ActiveMQConsumer.cc: In member function

Create durable topic and subscriber spring boot jms with ActiveMQ

落爺英雄遲暮 提交于 2020-01-13 18:18:08
问题 I need to create a topic and a durable subscriber for ActiveMQ, my problem is that I don't know where to specify that. I am able to create the topic and consume the messages, but when I turn off the subscriber then keep sending messages and turn on the subscriber again, it won't read them. This is what I have so far: Sending the message : JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class); jmsTemplate.setPubSubDomain(true); jmsTemplate.setDeliveryMode(DeliveryMode.PERSISTENT);