JMS1.1入门教程:Java企业应用消息系统详解

需积分: 31 1 下载量 118 浏览量 更新于2024-09-19 收藏 711KB PDF 举报
"《JMS简明教程》是一份由卫建军翻译的中文版技术资料,针对Java Message Service (JMS) 1.1规范进行了详细的讲解。JMS是Java 2 Enterprise Edition (J2EE) 架构中的一个重要组成部分,主要用于在分布式环境中实现可靠的消息传递。该教程的翻译旨在帮助J2EE爱好者克服英文文档的阅读障碍,深入理解和学习JMS,特别是对于那些想了解JMS的起源、功能边界、与其他Java API(如JDBC、JavaBean、EJB、JTA、JNDI等)的集成,以及JMS在J2EE平台中的角色。 教程内容涵盖了JMS的基本概念,如引言部分介绍了JMS的目标(支持异步通信、可靠的消息传递等)、不包含的功能(如邮件系统),以及JMS的主要要求(如与平台无关、支持多种消息风格等)。作者还解释了JMS与JDBC、JavaBean、EJB等其他API之间的关系,强调了JMS与EJB组件集成的重要性。 章节2讨论了JMS的应用架构,包括JMS应用的定义、管理和安全机制。开发者如何通过JMS接口开发客户端程序,以及触发式客户端和请求/回复模式的使用方法都被详细阐述。此外,JMS的消息模型也是核心内容,包括背景、目标和具体的消息类型定义。 该教程的翻译质量虽然受限于作者的英语水平,但仍提供了丰富的学习资源,对于想要深入了解JMS并应用于实际项目中的开发者来说,是一份非常有价值的参考资料。"

详细说一下一下代码:package com.mcloud.market.mq; import com.mcloud.common.constant.Constants; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.command.ActiveMQQueue; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jms.config.JmsListenerContainerFactory; import org.springframework.jms.config.SimpleJmsListenerContainerFactory; import org.springframework.jms.core.JmsMessagingTemplate; import javax.jms.ConnectionFactory; import javax.jms.Queue; @Configuration public class ActiveMQConfig { @Value("${spring.activemq.broker-url}") private String brokerUrl; @Value("${spring.activemq.user}") private String username; @Value("${spring.activemq.password}") private String password; @Bean public Queue queue() { return new ActiveMQQueue(Constants.PREFIX + ".amount"); } @Bean(name = "messageQueue") public Queue amountQueue() { return new ActiveMQQueue(Constants.PREFIX + ".message"); } // 在Queue模式中,对消息的监听需要对containerFactory进行配置 @Bean("queueListener") public JmsListenerContainerFactory<?> queueJmsListenerContainerFactory(ConnectionFactory connectionFactory) { SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory(); factory.setConnectionFactory(connectionFactory); factory.setPubSubDomain(false); return factory; } @Bean public ConnectionFactory connectionFactory() { return new ActiveMQConnectionFactory(username, password, brokerUrl); } @Bean public JmsMessagingTemplate jmsMessageTemplate() { return new JmsMessagingTemplate(connectionFactory()); } }

193 浏览量

WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dtoMapper': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demandResponseEventMapper': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demandResponseEventService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demandResponseEventPublisher': Unsatisfied dependency expressed through field 'jmsTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'l' defined in class path resource [com/avob/openadr/server/common/vtn/VtnConfigRabbitmqBroker.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jms.core.JmsTemplate]: Factory method 'externalJmsTemplate' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalConnectionFactory' defined in class path resource [com/avob/openadr/server/common/vtn/VtnConfigRabbitmqBroker.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.jms.ConnectionFactory]: Factory method 'externalConnectionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: com/rabbitmq/jms/admin/RMQConnectionFactory

305 浏览量