繁体   English   中英

BlazeDS-Spring-消息传递-如何将数据从服务推送到Flex客户端?

[英]BlazeDS - Spring - Messaging - How to push data from service to Flex clients?

自服务以来,我想推送数据(消息传递)。

@Service
@RemotingDestination
public class LoginService implements ILoginService
{
    // ...

    @Autowired
    private MessageBroker msgBroker;

    // ...

    @Transactional
    public final Boolean MyServiceFct(String data)
    {
     // ...

            // ... compute some result informations (with database informations, with current user session informations, etc.); 
            // this result must be after send to all clients ...

     // creating a new async message and setting the result informations as content.
     String clientID = UUIDUtils.createUUID();   
     AsyncMessage msg =new AsyncMessage(); // setting the destination for this message. 
     msg.setDestination("MyAdapterPushData");
     msg.setClientId(clientID);
     msg.setMessageId(UUIDUtils.createUUID());
     msg.setBody("coucou");
     msgBroker.routeMessageToService(msg,null);

     return true;
}

使用此实现,无需执行任何操作...客户什么也没收到。

那么,如何从这样的服务中推送数据? 可能吗 ?

非常感谢您的帮助,

安东尼

很简单 就像是:

@AutoWired
MessageTemplate template;

...

template.send("MyAdapterPushData", "coucou");

详细信息在这里:
http://static.springsource.org/spring-flex/docs/1.0.x/reference/html/ch05s06.html

詹姆士,

好的,您的解决方案非常好:-)但是,我有一个小问题:

在我的bean文件配置中,我必须编写以下代码才能具有良好的行为:

<flex:message-destination id="MyAdapterPushData"/>

但是,如果在我的messages-config.xml文件中添加以下内容:

<service id="message-service" class="flex.messaging.services.MessageService">
<adapters> 
    <adapter-definition id="MyAdapter" class="com.xxx.MyAdapterClass"/> 
</adapters>
<destination id="MyAdapterPushData"> 
    <channels> 
        <channel ref="my-streaming-amf"/>
    </channels>
    <adapter ref="MyAdapter"/>
</destination>

并评论这一行:

<!--flex:message-destination id="MyAdapterPushData"/--> 

我的flex客户收到任何东西:-(

谢谢你的帮助

安东尼

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM