开发者

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

开发者 https://www.devze.com 2023-01-30 07:53 出处:网络
Since my service, I would like to push data (messaging). @S开发者_如何学JAVAervice @RemotingDestination

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

@S开发者_如何学JAVAervice
@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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消