activemq

Priority with activemq

≯℡__Kan透↙ 提交于 2019-12-05 08:07:38
We're currentyly developping an application using JMS and activemq (5.5.1). We would like to define a higher priority for some messages, which would make them consumed first. After setting the producer and the consumer (through spring (3.1) JMSTemplate), the priority does not fully work. Indeed, when we "turn off" the consumer, and send some messages, the priority is respected, but when we add messages while the consumer is on, the messages are received in the same order they were sent. The configuration is quite simple: Priority was activated in the activemq config file: <policyEntries>

Properly Shutting Down ActiveMQ and Spring DefaultMessageListenerContainer

半腔热情 提交于 2019-12-05 08:00:44
Our system will not shutdown when a "Stop" command is issued from the Tomcat Manager. I have determined that it is related to ActiveMQ/Spring. I have even figured out how to get it to shutdown, however my solution is a hack (at least I hope this isn't the "correct" way to do it). I would like to know the proper way to shutdown ActiveMQ so that I can remove my hack. I inherited this component and I have no information about why certain architectural decisions were made, after a lot of digging I think I understand his thoughts, but I could be missing something. In other words, the real problem

ActiveMQ传输文件的几种方式原理与优劣

廉价感情. 提交于 2019-12-05 06:20:13
本文讨论ActiveMQ传输文件的几种方法的原理及其利弊,作为消息发送、直接传输文件、使用ftp或http中转。最后介绍扩展ActiveMQ实现自定义文件传输方式,讨论如何实现高效的文件传输。by kimmking 作为消息发送 按照JMS规范,为了保证可靠性,所有的消息都应该是发送到broker,然后交由broker来投递的。也即是说其实JMS是不建议或不支持传输文件的。 对于比较小的文件,简单的处理方式是先读取所有的文件成byte[],然后使用ByteMessage,把文件数据发送到broker,像正常的message一样处理。对于大文件,例如1GB以上的文件,这么搞直接把client或是broker给oom掉了。 这种方式仅仅适用于小文件的传输。特别是如果broker端使用数据库作为存储,message序列化以后存放于blob字段,文件传输频繁或是稍微有点大,写入效率极低。 直接传输文件 为了解决传输大文件的问题,ActiveMQ在jms规范之外引入了jms streams的概念。PTP模式下,连到同一个destination的两端,可以通过broker中转来传输大文件。 发送端使用connection.createOutputStream打开一个输出流,往流里写文件。 OutputStream out =connection.createOutputStream

java分布式事务处理--最终事务一致性

喜你入骨 提交于 2019-12-05 06:05:53
在大型系统架构时我们会进行分库设计,比如用户库、订单库。如果采用了dubbo会产生服务,如果目前有两个服务,用户服务和订单服务。 实际业务中,用户下单支付成功后,并改变用户的状态或增加用户的积分。这样过程中就会产生事务问题。这里我们采用最终事务一致性。 大致实现思路,把分布式事务切割成小事务,用消息队列消除分布式事务。实现方式如下: 订单功能的小事务如下: 首先:订单服务。 jmsTemplate.setSessionTransacted(true); transactionTemplate.execute(new TransactionCallback<String>() { @Override public String doInTransaction(TransactionStatus status) { // TODO Auto-generated method stub Connection connection = null; Session session = null; try { String orderId = System.currentTimeMillis() + ""; String sql = "insert into order (order_id,user_id) values (?,?)"; jdbcTemplate.update(sql, new

Can't get ActiveMQ to resend my messages

做~自己de王妃 提交于 2019-12-05 05:34:20
I have a single threaded ActiveMQ consumer written in Java. All I'm trying to do is receive() a messsage from the queue, attempt to send it to a web service, and if it succeeds acknowledge() it. If the web service call fails, I want the message to stay on the queue and be resent after some timeout. It's more or less working, except for the resending part: each time I restart my consumer, it gets one message for each that's still on the queue, but after failing to send them, the messages are never resent. My code looks like: public boolean init() throws JMSException, FileNotFoundException,

Springboot 2.2.1 与activeMq 集成2 queue 消息

风格不统一 提交于 2019-12-05 04:49:40
生产者代码 package com.active.mq.service; import javax.jms.Destination; /** * 消息生产 * * @author kql * */ public interface ProducerService { /** * 使用指定消息队列发送 * * @param destination * @param message */ void sendMsg(Destination destination, final String message); /** * 使用已经配置好的消息队列发送消息 就是启动类配置的队列 * @param message */ void sendMessage(final String message); } package com.active.mq.service.impl; import com.active.mq.service.ProducerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.core.JmsMessagingTemplate; import org.springframework.stereotype.Service;

How can I pull messages from Activemq Asynchronously

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 02:59:30
问题 I want to write code for pulling messages from Activemq .I don't want to pull all the messages from Activemq at a time,because my requirement is whenever my Java Application receives 1 message from Activemq ,based on message body I will find corresponding HTTP Link and forward to that Link. For this entire logic I wrote 2 .java files names are MessageConsumer.java MyListener.java MessageConsumer.java file only for connection establishing.The corresponding code is in below. package PackageName

A fatal error has been detected by the Java Runtime Environment. EXCEPTION_ACCESS_VIOLATION

南楼画角 提交于 2019-12-05 01:32:20
I have java 1.6, maven 2, activeMQ 5.5 and functional tests with testng. When I launch it in Idea then OK, but when I try to launch them with maven from console then process suspends after trying to send message via activeMQ and after some time crashes with the following error in log: # # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006d92f7a6, pid=5716, tid=7000 # # JRE version: 6.0_27-b07 # Java VM: Java HotSpot(TM) 64-Bit Server VM (20.2-b06 mixed mode windows-amd64 compressed oops) # Problematic frame: # V [jvm

activemq 的使用

大城市里の小女人 提交于 2019-12-05 00:52:06
1:   queue与topic两种魔术。queue是“该队列所有的监听者总共消费1次”;topic是“该所有的订阅者都会消费1次” //连接配置 private String userName = "admin"; private String password = "admin"; private String url = "tcp://192.168.8.65:61616"; private String queueName = "Qtest_queue"; private String topicName = "Ttest_topic";    1.1 queue队列消息     1.1.1 生产者 /** * 队列模式:生产者 */ @Test public void queueProduce() throws JMSException { // #1 创建连接工厂 ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(userName, password, url); // #2 从工厂获得连接connectino Connection connection = factory.createConnection(); // #3 启动访问 connection.start(); // #4

JMS consumer with ActiveMQ network of brokers

自闭症网瘾萝莉.ら 提交于 2019-12-04 23:43:25
问题 I have a JMS topic on an ActiveMQ network of brokers cluster (aka distributed topic). I have an external JMS consumer (Weblogic portal) that needs to subscribe to this topic and get all the messages sent to it (across all brokers). If the consumer subscribes to the topic on one of the brokers, it will only get the subset of the messages that the broker receives, correct? I guess I could create a consumer for each broker and aggregate the messages together, but then I'm also on the hook for