About channels and endpoints
channels
是客户端的对象用来封装消息以同LCDS服务器的endpoint通信

基本概念
通道类型:(Channel)
- RTMP(Real Time Messaging Protocal,实时消息协议)通道
- 加密的RTMP通道
- AMF通道(Action Message Format)
- HTTP通道(AMFX通道)
普通轮询:
客户端能够以一定时间间隔向服务器反复发送请求。每一次请求时,如果没有响应则宣告结束。直到某次请求收到响应时,即关闭连接。
长轮询:
客户端向服务器发出请求,服务器如果还没准备好数据就不返回请求,知道数据准备好或者超时才返回请求,无需等待客户端发起新的请求再返回响应,因为降低了服务器响应的延迟时间。
端点:(Endpoint)
- 基于Servlet
的端点:运行于Web容器内,使用Servlet来处理HTTP会话和网络I/O。
- 基于NIO
技术的端点:使用基于NIO的Socket服务器,具有更好的性能和扩展性。
Configuring channels and endpoints
<channel-definition id="my-nio-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:2880/nioamf" class="flex.messaging.endpoints.NIOAMFEndpoint"/>
<server ref="my-nio-server"/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>
- id
和type标识
出Flex客户端用来连接服务器的channel
-
endpoint
标签包含服务器端的endpoint的URL
和type
- properties标签包含channel
和endpoint
的属性
- 当使用NIO-based
的channel的时候使用server
标签
- endpoint的URL
就是连接MessageBrokerServlet的endpoint的网络地址
How channels are assigned to a Flex component
如果在MXML编译器设置(compiler option)里设置了“-services”,那么channels会自动通过配置文件来设置
;否则的话需要在MXML里手动添加
channels。

-services "E:/task/ProducerTest/WebContent/WEB-INF/flex/services-config.xml"
<RemoteObject id="ro" destination="Dest">
<mx:channelSet>
<mx:ChannelSet>
<mx:channels>
<mx:AMFChannel id="myAmf" uri="http://myserver:2000/myapp/messagebroker/amf"/>
</mx:channels>
</mx:ChannelSet>
</mx:channelSet>
</RemoteObject>
<mx:AMFChannel id="myamf" uri="/ptp/messagebroker/amf"/>
<mx:ChannelSet id="channelSet" channels="{[myamf]}"/>
<mx:RemoteObject id="recordSrv" destination="recordService"
channelSet="{channelSet}" showBusyCursor="true">
</mx:RemoteObject>
Assigning channels and endpoints to a destination
application-level
的缺省channels设置
<services-config ...>
...
<default-channels>
<channel ref="my-http"/>
<channel ref="my-amf"/>
</default-channels>
...
service
的缺省channels设置
<service ...>
...
<default-channels>
<channel ref="my-http"/>
<channel ref="my-amf"/>
</default-channels>
...
destination
的channels设置
<destination id="sampleVerbose">
<channels>
<channel ref="my-secure-amf"/>
</channels>
...
</destination>
Fallback and failover behavior
为什么要提供一个channels的集合呢?这样可以在缺省第一个channel通信不成功的时候自动启用第二个channel。
Choosing an endpoint
LCDS提供了两种endpoint,一个是servlet-based
的endpoints和NIO-based
的使用Java New I/O APIs的endpoints。当对于实时连接(real-time connection)要求高的时候应该选用后者。
Servlet-based channel and endpoint combinations
- AMFChannel/AMFEndpoint(AMF
format)
- HTTPChannel/HTTPEndpoint(AMFX
format)
- StreamingAMFChannel/StreamingAMFEndpoint(real-time
with AMF
format)
- StreamingHTTPChannel/StreamingHTTPEndpoint(real-time
with AMFX
format)
NIO-based channel and endpoint combinations
- RTMPChannel/RTMPEndpoint
- AMFChannel/NIOAMFEndpoint
- StreamingAMFChannel/ NIOStreamingAMFEndpoint
- HTTPChannel/NIOHTTPEndpoint
- StreamingHTTPChannel/StreamingNIOHTTPEndpoint
Choosing a channel
-
Non-polling
AMF and HTTP channels:一般是remoting service调用、proxied HTTP service调用和web service请求。
-
Piggybacking
on AMF and HTTP channels:Piggybackin的特性就是允许消息队列的传播,并对一个消息队列进行一次反馈,减小服务器系统开销。
-
Polling
AMF and HTTP channels:客户端可以一直在一个时间间隔中请求服务器的消息。
-
Long polling
AMF and HTTP channels:通过设置polling-enabled、polling-interval-millis、wait-interval-millis和client-wait-interval-millis来实现。
-
Streaming
channels:RTMP channels, streaming AMF 或者 HTTP channels。
小结
- AMFChannel -> (NIO)AMFEndpoint:regular, piggybacking, polling, long-polling
- StreamingAMFChannel -> (NIO)StreamingAMFEndpoint
- HTTPChannel -> (NIO)HTTPEndpoint:regular, piggybacking, polling, long-polling
- StreamingHTTPChannel -> (NIO)StreamingHTTPEnpoint
- RTMPChannel -> RTMPEndpoint:duplex socket
(双向套接字),这是真正的real-time
通信
HTTP piggybacking

HTTP polling

HTTP long-polling

HTTP streaming

Configuring channels with servlet-based endpoints
polling-enabled:默认是false。
polling-interval-millis:默认是3000。该值表示客户端给服务器发送请求消息的间隔时间。如果设置为0后,客户端在收到服务器的消息后立刻执行相关操作
wait-interval-millis:默认是0。该值表示服务器端等待客户端新消息的时间,需要设置max-waiting-poll-requests为非空值才能生效。0表示不等待客户端的新消息到来而像往常一样发送一个空消息回去;-1表示没有客户端的新消息的到来就不发送消息。
client-wait-interval-millis:默认是0,表示使用polling-interval-millis。1表示没有任何延迟。该值可覆盖polling-interval-millis。
max-waiting-poll-requests:endpoint的属性。默认是0。服务器端可等待响应的线程的最大数目。如果超过这个限制,wait-interval-millis会变为0。
piggybacking-enabled:
login-after-disconnect:channel属性。默认是false。设为true的意思是客户端会在消息发送失败的时候自动尝试重新验证登陆服务器端。
connect-timeout-seconds:客户端连接超时时间。
Configuring channels with NIO-based endpoints
暂时没有学习的需要
Channel and endpoint recommendations
Using LiveCycle Data Services clients and servers behind a firewall

- 大小: 10.3 KB

- 大小: 23 KB

- 大小: 26.8 KB

- 大小: 29.7 KB

- 大小: 31.9 KB

- 大小: 9.8 KB
分享到:
相关推荐
5. **Channels and endpoints**:通道和端点是BlazeDS数据传输的核心。通道定义了消息在网络上的传输方式,包括消息格式、协议、解析和目标。端点则指定了数据传输的网络地址。 在开发BlazeDS应用程序时,开发者...
5. Channels and Endpoints:通道和端点是BlazeDS中数据传输的关键。通道定义了数据在网络上传输的方式,包括消息格式、网络协议、解析策略和目标。通过设置不同的通道和端点,BlazeDS能够适应不同的网络环境和通信...
##### Channels and Endpoints(通道和端点) 通道负责封装消息格式、网络协议、解析策略及应用代码,确保消息在网络上传输的有序性和一致性。端点则在服务器端解析消息,实现与Java服务的有效交互。 综上所述,...
首先,理解Flex RemoteObject的核心概念是必要的。RemoteObject是Adobe Flex框架的一部分,它提供了透明的AMF(Action Message Format)通信,这是一种高效的数据序列化格式,用于在Flex客户端和服务器之间传输数据...
- **Remoting服务**:通过定义通道(Channels)和目标(Endpoints),可以远程调用Java服务。常见的通道类型有HTTP和HTTP Streaming,分别适用于请求响应模式和长轮询推送。 - **Message Brokering**:BlazeDS支持...
配置BlazeDS时,你需要修改blazeds.war中的配置文件,例如flex-config.xml和services-config.xml,定义Remoting endpoints和MessageBroker channels。此外,你还需要在服务器端设置相应的数据源,并确保Java应用程序...
在网络层面上,BlazeDS使用通道(Channels)和端点(Endpoints)来管理客户端和服务端之间的数据传输。通道定义了消息的格式、网络协议和解析方式,确保了不同环境下的通信兼容性。 总的来说,BlazeDS是一个强大的...