}
public Object call() throws Exception {
final ClientEndpoint endpoint = getEndpoint();
final ClientEngine clientEngine = getClientEngine();
final QueueService service = getService();
ItemListener listener = new ItemListener() {
public void itemAdded(ItemEvent item) {
send(item);
}
public void itemRemoved(ItemEvent item) {
send(item);
}
private void send(ItemEvent event){
if (endpoint.live()){
Data item = clientEngine.toData(event.getItem());
PortableItemEvent portableItemEvent = new PortableItemEvent(item, event.getEventType(), event.getMember().getUuid());
endpoint.sendEvent(portableItemEvent, getCallId());
}
}
};
String registrationId = service.addItemListener(name, listener, includeValue);
endpoint.setListenerRegistration(QueueService.SERVICE_NAME, name, registrationId);
return registrationId;
}