I want to send message to particular user via messaging (consumer/producer).
I have following code for this:
**********************************************************************
public void sendMessageToClient(Object msgBody, String clientId) {
MessageBroker.getMessageBroker(null).routeMessageToMessageClient(createMessage(msgBody), getMessageClient(clientId));
}
private MessageClient getMessageClient(String clientId) {
MessageBroker messageBroker = MessageBroker.getMessageBroker(null);
Object serviceId = messageBroker.getDestinationService().get("informer");
MessageService messageService = (MessageService) messageBroker.getServices().get(serviceId);
MessageDestination messageDestination = (MessageDestination) messageService.getDestination("informer");
MessageClient messageClient = messageDestination.getSubscriptionManager().getSubscriber(clientId);
return messageClient;
}
private AsyncMessage createMessage(Object msgBody) {
AsyncMessage msg = new AsyncMessage();
// msg.setClientId(UUIDUtils.createUUID(true));
msg.setTimestamp(System.currentTimeMillis());
msg.setMessageId(UUIDUtils.createUUID(true));
msg.setDestination("informer");
msg.setBody(msgBody);
// msg.setHeader("sender", "From the server");
return msg;
}
**********************************************************************
and corresponding configurations in messaging-config.xml :
**********************************************************************
<destination id="informer">
<properties>
<network>
<session-timeout>0</session-timeout>
</network>
<server>
<max-cache-size>1000</max-cache-size>
<message-time-to-live>0</message-time-to-live>
<durable>false</durable>
</server>
</properties>
<channels>
<channel ref="channel-rtmp" />
<channel ref="channel-amf" />
<channel ref="channel-polling-amf" />
</channels>
</destination>
**********************************************************************
but it throws NullPointerException at flex.messaging.MessageBroker.routeMessageToMessageClient(MessageBroker.java:1372)
any suggestions?