JMS1.1规范中文教程:深入理解企业级应用架构关键

需积分: 31 7 下载量 113 浏览量 更新于2024-09-24 收藏 711KB PDF 举报
"JMS简明教程.pdf"是一本关于Java Message Service (JMS)的中文版教程,作者卫建军在2007年11月22日翻译了部分内容,主要针对JMS 1.1规范,以及与之相关的EJB 3.0规范、J2EE 5.0规范等。JMS是Java企业版(J2EE)架构中的关键组件,用于实现分布式应用程序间的异步通信。 该教程旨在帮助读者克服对英文文档的恐惧,深入理解JMS的核心概念和规范,从而更好地利用JMS进行消息传递和处理。JMS的目标是提供一种标准化的方式来处理应用程序之间的消息,支持多种消息风格,如点对点(Point-to-Point)、发布/订阅(Publish/Subscribe)和请求/响应(Request/Reply)。JMS并不包含底层的网络传输,而是专注于消息的发送、接收和管理,它与Java的其他API如JDBC(Java Database Connectivity)、JavaBean、EJB(Enterprise JavaBeans)、JTA(Java Transaction API)、JTS(Java Transaction Service)、JNDI(Java Naming and Directory Interface)以及整个J2EE平台有着紧密的集成。 教程详细介绍了JMS的架构,包括其应用类型(如JMS客户端和服务端)、管理机制、消息风格(如触发式客户端和请求/回复模式)以及消息模型。此外,还讨论了JMS 1.1新引入的特性和功能,帮助读者了解如何在实际开发中利用这些特性构建健壮的分布式系统。 尽管作者承认自己的英语水平有限,可能会存在翻译上的错误和不流畅之处,但整体上这本教程对于想要掌握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()); } }

2023-06-06 上传

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

2023-06-10 上传