use of org.oasis_open.docs.wsn.bw_2.UnableToGetMessagesFault in project cxf by apache.
the class JmsPullPoint method getMessages.
@Override
protected List<NotificationMessageHolderType> getMessages(int max) throws ResourceUnknownFault, UnableToGetMessagesFault {
try {
if (max == 0) {
max = 256;
}
initSession();
List<NotificationMessageHolderType> messages = new ArrayList<>();
for (int i = 0; i < max; i++) {
Message msg = null;
synchronized (consumerSession) {
msg = consumer.receiveNoWait();
}
if (msg == null) {
break;
}
TextMessage txtMsg = (TextMessage) msg;
StringReader reader = new StringReader(txtMsg.getText());
XMLStreamReader xreader = StaxUtils.createXMLStreamReader(reader);
Notify notify = (Notify) jaxbContext.createUnmarshaller().unmarshal(xreader);
try {
xreader.close();
} catch (XMLStreamException e) {
// ignoreable
}
messages.addAll(notify.getNotificationMessage());
}
return messages;
} catch (JMSException e) {
LOGGER.log(Level.INFO, "Error retrieving messages", e);
closeSession();
UnableToGetMessagesFaultType fault = new UnableToGetMessagesFaultType();
throw new UnableToGetMessagesFault("Unable to retrieve messages", fault, e);
} catch (JAXBException e) {
LOGGER.log(Level.INFO, "Error retrieving messages", e);
UnableToGetMessagesFaultType fault = new UnableToGetMessagesFaultType();
throw new UnableToGetMessagesFault("Unable to retrieve messages", fault, e);
}
}
Aggregations