- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Forgot to say. I am able to send message to all clients within following code:
public void sendMessageToAllClients(Object msgBody) {
log.debug("send message to all clients: " + msgBody);
AcknowledgeMessage acknowledgeMessage = MessageBroker.getMessageBroker(null).routeMessageToService(createMessage(msgBody),
null);
log.debug("result: " + acknowledgeMessage);
}
In this case all currently subscribed users receiving message.
here is method which creates AsyncMessage
private AsyncMessage createMessage(Object msgBody) {
AsyncMessage msg = new AsyncMessage();
msg.setClientId(getServerId());
msg.setTimestamp(System.currentTimeMillis());
msg.setMessageId(UUIDUtils.createUUID(true));
msg.setDestination(destination);
msg.setBody(msgBody);
return msg;
}
And by the way I have my own custom adapter here is code:
public class MessagingAdapterImpl extends MessagingAdapter {
private static final Log log = LogFactory.getLog(MessagingAdapterImpl.class);
@Override
public Object invoke(Message message) {
log.debug("sending message " + ToStringBuilder.reflectionToString(message, ToStringStyle.SHORT_PREFIX_STYLE));
MessageService msgService = (MessageService) getDestination().getService();
msgService.pushMessageToClients(message, true);
msgService.sendPushMessageFromPeer(message, true);
return null;
}
@Override
public Object manage(CommandMessage commandMessage) {
if (CommandMessage.SUBSCRIBE_OPERATION == commandMessage.getOperation()) {
log.debug("subsriber is registered [" + commandMessage.getClientId() + "]");
}
if (CommandMessage.UNSUBSCRIBE_OPERATION == commandMessage.getOperation()) {
log.debug("subsriber is unregistered [" + commandMessage.getClientId() + "]");
}
return null;
}
@Override
public boolean handlesSubscriptions() {
return true;
}
}
Views
Replies
Total Likes