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

发布于 2024-10-07 12:19:05 字数 1044 浏览 5 评论 0原文

由于我的服务,我想推送数据(消息传递)。

@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;
}

通过此实现,无需执行任何操作...客户端不会收到任何信息。

那么,我如何从这样的服务推送数据呢?是否可以 ?

非常感谢你的帮助,

安东尼

Since my service, I would like to push data (messaging).

@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;
}

With this implementation, nothing to do ... clients receiveid nothing.

So, how I push data from a service like that ? Is it possible ?

Thank you very much for your help,

Anthony

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

有木有妳兜一样 2024-10-14 12:19:06

James,

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

在我的 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"/--> 

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

感谢您的帮助

安东尼

James,

Ok, your solution is very good :-) But, I have a little problem:

in my bean file configuration, I must write this to have a good behavior:

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

But, if in my messaging-config.xml file add this :

<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>

and comment this line :

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

my flex clients receive anything :-(

Thanks for your help

Anthony

还如梦归 2024-10-14 12:19:05

这很容易。类似:

@AutoWired
MessageTemplate template;

...

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

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

It's very easy. Something like:

@AutoWired
MessageTemplate template;

...

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

Details here:
http://static.springsource.org/spring-flex/docs/1.0.x/reference/html/ch05s06.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文