JMS Overview

JMS Overview

The Java Message Service (JMS) is a Java API that allows applications to create, send, receive, and read messages.JMS enables distributed communication that is loosely coupled, reliable, and asynchronous.Messages can be sent in two ways—PTP(Queue) and Pub/Sub(Topic)

 

Figure 1 illustrates the way these parts interact. Administrative tools allow you to bind destinations and connection factories into a Java Naming and Directory InterfaceTM (JNDI) API namespace. A JMS client can then look up the administered objects in the namespace and then establish a logical connection to the same objects through the JMS provider.


Figure 1   JMS API Architecture

 

 

Figure 2   Point-to-Point Messaging

 

 

Figure 3   Publish/Subscribe Messaging


 

Figure 4  The JMS API Programming Model

 

Table 1 Relationship of PTP and Pub/Sub interfaces

JMS Parent

PTP Domain

Pub/Sub Domain

ConnectionFactory

QueueConnectionFactory

TopicConnectionFactory

Connection

QueueConnection

TopicConnection

Destination

Queue

Topic

Session

QueueSession

TopicSession

MessageProducer

QueueSender

TopicPublisher

MessageConsumer

QueueReciever, QueueBrowser

TopicSubscriber

 

Developing a JMS Client

1.     Use JNDI to find a ConnectionFactory object.

2.     Use JNDI to find one or more Destination objects.

3.     Use the ConnectionFactory to create a JMS Connection.

4.     Use the Connection to create one or more JMS Sessions.

5.     Use a Session and the Destinations to create the MessageProducers and MessageConsumers needed.

6.     Tell the Connection to start delivery of messages.

 

Multi-Threading

Table 2 JMS objects that support concurrent use

JMS Object

Supports Concurrent Use

Destionation

Yes

ConnectionFactory

Yes

Connection

Yes

Session

No

MessageProducer

No

MessageConsumer

No

 

Table 3 Message Header Field Value Sent

Header Fields

Set By

JMSDestination

Send Method

JMSDeliveryMode

Send Method

JMSExpiration

Send Method

JMSPriority

Send Method

JMSMessageID

Send Method

JMSTimestamp

Send Method

JMSCorrelationID

Client

JMSReplyTo

Client

JMSType

Client

JMSRedelivered

Provider

 

 

JMS Message Body

StreamMessage

MapMessage                    

TextMessage

ObjectMessage

BytesMessage

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值