jms

消息中间件之ActiveMQ

旧街凉风 提交于 2020-01-08 13:51:42
什么是消息中间件? 消息中间件是利用高效可靠的消息传递机制进行平台无关的数据交流,并基于数据 通信来进行分布式系统的集成。通过提供消息传递和消息排队模型,可以在分布式架构下扩展进程之间的通信。 消息中间件能做什么? 消息中间件主要解决的就是分布式系统之间消息传递的问题,它能够屏蔽各种平台以及协议之间的特性,实现引用程序之间的协同。举个非常简单的例子,就拿一个电商平台的注册功能来简单分析下,用户注册这一个服务,不单单只是insert一条数据到数据库里面就完事了,还需要发送激活邮件、发送新人红包或者积分、发送营销短信等一系列操作。假如说这里面的每一个操作,都需要消耗1s,那么整个注册过程就需要耗时4s才能响应给用户。 但是我们从注册这个服务可以看到,每一个子操作都是相对独立的,同时,基于领域划分以后,发送激活邮件、发送营销短信、赠送积分及红包都属于不同的子域。所以我们可以对这些子操作进行来实现异步化执行,类似于多线程并行处理的概念。如何实现异步化呢?用多线程能实现吗?多线程当然可以实现,只是,消息的持久化、消息的重发这些条件,多线程并不能满足。所以需要借助一些开源中间件来解决。而分布式消息队列就是一个非常好的解决办法,引入分布式消息队列以后,架构图就变成这样了(下图是异步消息队列的场景)。通过引入分布式队列,就能够大大提升程序的处理效率,并且还解决了各个模块之间的耦合问题

Spring JMS Listener Container stop only half of listeners

泪湿孤枕 提交于 2020-01-07 03:34:12
问题 I have weired problem with a JMS Listener container. In case I disable the listener container, half of messages are delivered and processed by listener. Here is my Spring configuration: <bean id="ConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="JmsXA" /> </bean> <bean id="testQueue" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="queue/test" /> </bean> <bean id="listener" class="eu.cuptech.jms

How to improve MQ client create conncetion time?

天大地大妈咪最大 提交于 2020-01-07 02:40:28
问题 I have an app on Tomcat 7.05 that connects to a remote MQ manager, everything work fine, it just that creating a connection takes an insane amount of time ~ 13 seconds (if I put both java code and MQ server on one machine, it takes less then a second). How do I improve create connection time? My java code: import javax.jms.DeliveryMode; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Queue; import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory;

javax.naming.NamingException: unexpected exception [Root exception is java.lang.NullPointerException]; remaining name FactoryName

巧了我就是萌 提交于 2020-01-07 02:31:54
问题 I have a Spring JMS project managed with Maven. When I run the project via Eclipse everything goes well, but when I launch it from the executable jar file I got the following error : INFO - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12911b4f: defining beans [jmsBridgeServer,messageFrameStreamReader,outgoingMessageEventListener,serverLifecycleEventListener,jmsQueueConnectionFactory,jndiTemplate,jmsQueueTemplate,jmsDestinationResolver,jmsSender

javax.naming.NamingException: unexpected exception [Root exception is java.lang.NullPointerException]; remaining name FactoryName

空扰寡人 提交于 2020-01-07 02:31:05
问题 I have a Spring JMS project managed with Maven. When I run the project via Eclipse everything goes well, but when I launch it from the executable jar file I got the following error : INFO - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12911b4f: defining beans [jmsBridgeServer,messageFrameStreamReader,outgoingMessageEventListener,serverLifecycleEventListener,jmsQueueConnectionFactory,jndiTemplate,jmsQueueTemplate,jmsDestinationResolver,jmsSender

DMLC message consumption and acknowledgement

爷,独闯天下 提交于 2020-01-06 14:56:29
问题 This is a follow up question for Difference between AUTO_ACKNOWLEDGEMENT mode with and without Spring JMS. I am using DMLC and my concurrent consumers count is 1. The prefetch limit is > 1. I received a message and it is acknowledged before listener is executed. So, while the listener is executing, broker has more messages and it sends it to consumer as per prefetch settings. Since the listener is still executing, how will the consumption and acknowledgement works for subsequent messages?

Maven command to run activemq before intergation tests

青春壹個敷衍的年華 提交于 2020-01-06 07:27:21
问题 I need to run ActiveMQ in my maven clean install, so that it starts up activemq and then runs my tests. I have included the plugin in pom.xml and added the mq config file for configuring mq details. It runs successfully and all test pass when I run activeMq on one console and run maven clean install on others (2 separate commands on 2 separate consoles). But is there a way I can run activemq and clean install both with 1 command on the same console? Basically I wish that when I do mvn clean

How do I set a component parameter of type object to a route using Java DSL?

夙愿已清 提交于 2020-01-06 07:07:22
问题 My objective is to use Camel along with its JMS component. The route config looks like below- from("jms:queue:test").to(mybean) I would like to add the option of kind 'parameter' and type 'object' to this route -for example the option 'jmsMessageType'. I saw some other posts that talks about using setProperty() on route definition but I could not find a definite answer. Options of type 'string' and numbers can be appended to the URI but not objects. JMS has an option of taskExecutor but how

Synchronous Consumer with JMS Queue

…衆ロ難τιáo~ 提交于 2020-01-06 07:03:16
问题 I want to process all the messages from a JMS Queue in Glassfish 3 in a synchronous way so I have tried to change the property Maximum Active Consumers from -1 to 1 in JMS Physical Destination in Glassfish window. I think setting this I will have only one Consumer executing OnMessage() at the same time. The problem I have reached its that when I change that property I got this error: [I500]: Caught JVM Exception: org.xml.sax.SAXParseException: Content is not allowed in prolog. [I500]: Caught

Synchronous Consumer with JMS Queue

a 夏天 提交于 2020-01-06 07:01:40
问题 I want to process all the messages from a JMS Queue in Glassfish 3 in a synchronous way so I have tried to change the property Maximum Active Consumers from -1 to 1 in JMS Physical Destination in Glassfish window. I think setting this I will have only one Consumer executing OnMessage() at the same time. The problem I have reached its that when I change that property I got this error: [I500]: Caught JVM Exception: org.xml.sax.SAXParseException: Content is not allowed in prolog. [I500]: Caught