BlazeDS client architecture

BlazeDS client architecture

BlazeDS clients use a message-based framework provided by BlazeDS to interact with the server. On the client side of the message-based framework are channels that encapsulate the connection behavior between the Flex client and the BlazeDS server. Channels are grouped together into channel sets that are responsible for channel hunting and channel failover. For information about client class APIs, see the ActionScript 3.0 Language Reference .

The following illustration shows the BlazeDS client architecture:

The LiveCycle Data Services ESBlazeDS client architecture

Flex components

The following Flex components interact with a BlazeDS server:

  • RemoteObject
  • HTTPService
  • WebService
  • Producer
  • Consumer

All of these components are included in the Flex SDK in the rpc.swc component library.

Although the RemoteObject, Producer, and Consumer components are included with the Flex SDK, they require a server that can interpret the messages that they send. The BlazeDS and LiveCycle Data Services ES servers are two examples of such servers. A Flex application can also make direct HTTP service or web service calls to remote servers without BlazeDS in the middle tier. However, going through the BlazeDS Proxy Service is beneficial for several reasons; for more information, see Using HTTP and web services .

Client-side components communicate with services on the BlazeDS server by sending and receiving messages of the correct type. For more information about messages, see Messages .

Channels and channel sets

A Flex component uses a channel to communicate with a BlazeDS server. A channel set contains channels; its primary function is to provide connectivity between the Flex client and the BlazeDS server. A channel set contains channels ordered by preference. The Flex component tries to connect to the first channel in the channel set and in the case where a connection cannot be established falls back to the next channel in the list. The Flex component continues to go through the list of channels in the order in which they are specified until a connection can be established over one of the channels or the list of channels is exhausted.

Channels encapsulate the connection behavior between the Flex components and the BlazeDS server. Conceptually, channels are a level below the Flex components and they handle the communication between the Flex client and the BlazeDS server. They communicate with their corresponding endpoints on the BlazeDS server; for more information about endpoints, see Endpoints .

Flex clients can use different channel types such as the AMFChannel and HTTPChannel. Channel selection depends on a number of factors, including the type of application you are building. If non-binary data transfer is required, you would use the HTTPChannel, which uses a non-binary format called AMFX (AMF in XML). For more information about channels, see Channels and endpoints .

Messages

All communication between Flex client components and BlazeDS is performed with messages. Flex components use several message types to communicate with their corresponding services in BlazeDS. All messages have client-side (ActionScript) implementations and server-side (Java) implementations because the messages are serialized and deserialized on both the client and the server. You can also create messages directly in Java and have those messages delivered to clients using the server push API.

Some message types, such as AcknowledgeMessage and CommandMessage, are used across different Flex components and BlazeDS services. Other message types are used by specific Flex components and BlazeDSservices. For example, to have a Producer component send a message to subscribed Consumer components, you create a message of type AsyncMessage and pass it to the send() method of the Producer component.

In other situations, you do not write code for constructing and sending messages. For example, you simply use a RemoteObject component to call the remote method from the Flex application. The RemoteObject component creates a RemotingMessage to encapsulate the RemoteObject call. In response it receives an AcknowledgeMessage from the server. The AcknowledgeMessage is encapsulated in a ResultEvent in the Flex application.

Sometimes you must create a message to send to the server. For example, you could send a message by creating an AsyncMessage and passing it to a Producer.

BlazeDS uses two patterns for sending and receiving messages: the request/reply pattern and the publish/subscribe pattern. RemoteObject, HTTPService, and WebService components use the request/reply message pattern, in which the Flex component makes a request and receives a reply to that request. Producer and Consumer components use the publish/subscribe message pattern. In this pattern, the Producer publishes a message to a destination defined on the BlazeDS server. All Consumers subscribed to that destination receive the message.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值