jms消息模式和区别_JMS管理对象和JMS消息

jms消息模式和区别

Before reading this post, please go through my previous at “JMS Messaging Models” to understand some JMS Basic concepts.

在阅读本文之前,请仔细阅读我以前在“ JMS消息传递模型”上的内容,以了解一些JMS Basic概念。

In this post we are going to discuss about JMS Administered Objects and JMS Message in detail.

在这篇文章中,我们将详细讨论JMS管理对象和JMS消息。

发表简短的目录: (Post Brief TOC:)

  • JMS Administered Objects

    JMS管理的对象
  • JMS Message

    JMS消息
  • Message Header

    邮件标题
  • Message Properties

    讯息属性
  • Message Body

    邮件正文

JMS管理的对象 (JMS Administered Objects)

JMS API provides two kinds of Administered Objects to the JMS Clients.

JMS API为JMS客户端提供了两种管理对象。

  • Connection Factory

    连接工厂
  • Destination

    目的地

JMS System Administrator creates these two Administered objects in JMS Provider (Message Broker) by using Application Server (AS) admin console. These two objects are stored in AS JNDI Directory or JNDI Registry.

JMS系统管理员通过使用Application Server(AS)管理控制台在JMS提供程序(消息代理)中创建这两个受管理对象。 这两个对象存储在AS JNDI目录或JNDI注册表中。

Destination
Destination object is used to exchange messages between JMS Clients. JMS API provides two kinds of Destinations:

目的地
目标对象用于在JMS客户端之间交换消息。 JMS API提供了两种目的地:

  • Queue

    队列
  • Topic

    话题

Connection Factory
Connection Factory object is used to create connection between JMS Provider and JMS Client. When JMS Client (JMS Sender or JMS Receiver) lookups this object from JNDI Registry, then JMS Client receives one Connection object that is nothing but a physical connection between JMS Provider and JMS Client. By using this connection, JMS Client can communicate with Destination object to send or receive messages into Queue or Topic.

连接工厂
连接工厂对象用于在JMS Provider和JMS Client之间创建连接。 当JMS客户端(JMS发送器或JMS接收器)从JNDI注册表中查找该对象时,JMS客户端会收到一个Connection对象,该对象只是JMS Provider和JMS Client之间的物理连接。 通过使用此连接,JMS Client可以与Destination对象进行通信,以将消息发送或接收到Queue或Topic中。

While creating these two objects, we need to provide three things

在创建这两个对象时,我们需要提供三件事

  • Name :- Name of the object. We can provide any valid name

    名称:-对象的名称。 我们可以提供任何有效的名称
  • JNDI Name:- This is JNDI name which is used to register this object in JNDI Directory. JMS Clients uses this name to lookup these objects from JNDI Registry and use them in their applications to send or receive messages from JMS Provider.

    JNDI名称:-这是JNDI名称,用于在JNDI目录中注册此对象。 JMS客户端使用此名称从JNDI注册表中查找这些对象,并在其应用程序中使用它们来发送或接收来自JMS Provider的消息。
  • Resource Type:- We need to specify the resource type here.

    资源类型:-我们需要在此处指定资源类型。
S.No.Administered ObjectsResource Type
1.ConnectionFactoryjavax.jms.ConnectionFactory
2.Queuejavax.jms.Queue
3.Topicjavax.jms.Topic
序号 管理对象 资源类型
1。 连接工厂 javax.jms.ConnectionFactory
2。 队列 javax.jms.Queue
3。 话题 javax.jms.Topic

Example:-

例:-

To create a Queue Object in Oracle GlassFish Application Server

在Oracle GlassFish Application Server中创建队列对象

Here I’ve provided Destination Name = TPQueue , JNDI Name = jms/TPQueue and Resource Type as javax.jms.Queue. JMS Clients can lookup this object by using the following code snippet:

在这里,我提供了Destination Name = TPQueue,JNDI Name = jms / TPQueue和Resource Type作为javax.jms.Queue。 JMS客户端可以使用以下代码片段查找此对象:

Queue queue = (Queue) context.lookup("jms/TPQueue");

JMS消息 (JMS Message)

JMS Messages are used by JMS clients to exchange information between systems. This JMS Message is of type javax.jms.Message.

JMS客户端使用JMS消息在系统之间交换信息。 此JMS消息的类型为javax.jms.Message。

This JMS Message is divided into 3 parts:

此JMS消息分为3部分:

  • Message Header

    邮件标题
  • Message Properties

    讯息属性
  • Message Body

    邮件正文

邮件标题 (Message Header)

This section is mandatory. It contains predefined name-value pairs used by JMS Clients and JMS Providers to identify and route messages.

本部分是强制性的。 它包含JMS客户端和JMS提供程序用来标识和路由消息的预定义名称/值对。

Predefined Headers:

预定义的标题:

  • JMSDestination

    JMS目的地
  • JMSDeliveryMode

    JMSDeliveryMode
  • JMSMessageID

    JMSMessageID
  • JMSTimestamp

    JMS时间戳
  • JMSCorrelationID

    JMSCorrelationID
  • JMSReplyTo

    JMSReplyTo
  • JMSRedelivered

    JMS已交付
  • JMSType

    JMSType
  • JMSExpiration

    JMS到期
  • JMSPriority

    JMS优先级

讯息属性 (Message Properties)

This section is optional. These properties are custom name-value pairs set or read by applications. These are useful for supporting filtering messages. We will discuss it in detail in Messaging Filtering Advanced JMS Concepts section.

本部分是可选的。 这些属性是应用程序设置或读取的自定义名称/值对。 这些对于支持过滤消息很有用。 我们将在“邮件过滤高级JMS概念”部分中详细讨论它。

邮件正文 (Message Body)

This section is optional. It contains actual message sent from JMS Sender to JMS Receiver.

本部分是可选的。 它包含从JMS发送器发送到JMS接收器的实际消息。

It supports the following message formats:

它支持以下消息格式:

  • TextMessage

    文字讯息
  • ObjectMessage

    对象消息
  • BytesMessage

    字节消息
  • StreamMessage

    流消息
  • MapMessage

    MapMessage

These JMS message types are described in the following table:

下表描述了这些JMS消息类型:

That’s it all about JMS Administered Objects and JMS Message. We will discuss some more JMS Concepts in my coming posts.

这就是关于“ JMS管理对象”和“ JMS消息”的全部内容。 我们将在我的后续文章中讨论更多的JMS概念。

Please drop me a comment if you like my post or have any issues/suggestions.

如果您喜欢我的帖子或有任何问题/建议,请给我评论。

翻译自: https://www.journaldev.com/9760/jms-admin-objects-and-jms-message

jms消息模式和区别

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值