自从我的服务以来,我想推送数据(消息)。
@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;
}
有了这个实现,无所事事......客户端什么也没收到。
那么,我如何从这样的服务推送数据呢?有可能吗?
非常感谢你的帮助,
安东尼
答案 0 :(得分:0)
这很容易。类似的东西:
@AutoWired
MessageTemplate template;
...
template.send("MyAdapterPushData", "coucou");
详细信息:
http://static.springsource.org/spring-flex/docs/1.0.x/reference/html/ch05s06.html
答案 1 :(得分:0)
詹姆斯
好的,你的解决方案非常好:-)但是,我有一点问题:
在我的bean文件配置中,我必须写这个以获得良好的行为:
<flex:message-destination id="MyAdapterPushData"/>
但是,如果在我的messaging-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客户收到任何东西: - (
感谢您的帮助
安东尼