JMS消息内部结构学习笔记

The JMS message is the most important concept in the JMS specification. Every concept in the JMS spec is built around handling a JMS message because it’s how business data and events are transmitted.
摘要由CSDN通过智能技术生成

The JMS message is the most important concept in the JMS specification. Every concept in the JMS spec is built around handling a JMS message because it’s how business data and events are transmitted. A JMS message allows anything to be sent as part of the message, including text and binary data as well as information in the headers. As
depicted in figure 2.5, JMS messages contain two parts, including headers and a payload. The headers provide metadata about the message used by both clients and JMS providers. The payload is the actual body of the message and can hold both textual and binary data via the various message types. The JMS message is designed to be easy to understand and flexible. All the complexity of the JMS message resides in the headers.

JMS消息是JMS规范中最重要的概念。 每个在JMS规范中概念都是围绕处理一个JMS消息,因为它包含了业务数据和事件是怎么被传输的。 JMS消息允许任何内容作为其一部分发送消息,包括文本和二进制数据以及标题中的信息。 如下所示,JMS消息包含两部分,包括消息头部和消息载体(类似于我们常用的大部分协议,如http等)。消息头提供消息的接受端和发送端两个客户端和JMS规范的元数据。消息载体是消息的实际内容,并且可以保存文本和承载了各种各样数据的二进制数据(如图片,流等等)。JMS消息设计宗旨是在易于理解和可扩展。 所有的复杂的内容包含在JMS消息头中。

这里写图片描述

As mentioned previously, the complexity of a JMS message lies in the details provided by the headers. There are actually two types of headers, which are basically the same logical concept but differ semantically. Whereas a standard list of headers and methods to work with them are provided by the JMS spec, properties are designed to facilitate custom headers based on primitive Java types. Both are referred to generically as headers.

如前所述,JMS消息的复杂性位于标题提供的详细信息中。 那里实际上是两种类型的标题,基本上相同的逻辑概念,但语义上不同。JMS消息头的标准列表,是由JMS规范提供的。JMS消息头属性被设计为便于使用java类型来自定义JMS消息头。两者都被作为JMS消息头。

As shown in figure 2.5, JMS messages support a standard lists of headers and the JMS API provides methods for working with them. Many of the headers are automatically assigned. The following list describes each of these headers, and how they are assigned to the message.

如上图所示,标准的JMS消息头与JMS API提供的方法一起工作。大多数头信息是被自动分配的,接下来描述每个头的含义,以及如何被分配到消息中的

Headers set automatically by the client’s send() method:
消息头被自动设置,通过客户端掉用send方法:

JMSDestination—The destination to which the message is being sent. This is valuable for clients who consume messages from more than one destination.

JMSDeliveryMode—JMS supports two types of delivery modes for messages: persistent and nonpersistent. The default delivery mode is persistent. Each delivery mode incurs its own overhead and implies a particular level of reliability.

  • Persistent—Advises the JMS provider to persist the message so it’s not lost if the provider fails. A JMS provider must deliver a persistent message once and only once. In other words, if the JMS provider fails, the message won’t be lost and won’t be delivered more than once. Persistent messages incur more overhead due to the need to store the message, and value reliability over performance.
  • Nonpersistent—Instructs the JMS provider not to persist the message. A JMS provider must deliver a nonpersistent message at most once. In other words, if the JMS provider fails, the message may be lost, but it won’t be delivered twice. Nonpersistent messages incur less overhead and value performance over reliability. The delivery mode is set on the producer and is applied to all messages sent from that producer. But the delivery mode can be overridden for individual messages.

JMSDeliveryMode- JMS支持两种传递模式,持久和非持久。默认的传递模式是持久,每一个模式不仅会影响消息头而已还意味着消息的可靠性

Persistent—通知消息提供者去持久化消息。即使消息提供者挂掉,消息也不会丢失。在这个模式下,JMS提供者必须对消息进行持久化并且只进行一次。如果JMS提供者挂了,此时该JMS提供者的消息并不会丢失,但消息只能被消费者使用一次。
由于持久化消息提供了额外

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值