use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class IbisSoapServlet method listRestServices.
protected void listRestServices(HttpServletRequest req, Writer w) throws IOException {
w.write("<h2>Available REST services:</h2>");
w.write("<ol>");
int count = 0;
for (IAdapter a : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) a;
Iterator recIt = adapter.getReceiverIterator();
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
if (receiver instanceof ReceiverBase) {
ReceiverBase rb = (ReceiverBase) receiver;
IListener listener = rb.getListener();
if (listener instanceof RestListener) {
RestListener rl = (RestListener) listener;
if (rl.isView()) {
count++;
w.write("<li>");
w.write("<a href=../" + rl.getRestUriPattern() + ">" + rb.getName() + "</a>");
w.write("</li>");
}
}
}
}
}
w.write("</ol>");
if (count == 0) {
w.write("No rest listeners found");
}
}
use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class ShowConfigurationStatus method mapAdapterReceivers.
private ArrayList<Object> mapAdapterReceivers(Adapter adapter, boolean showPendingMsgCount) {
ArrayList<Object> receivers = new ArrayList<Object>();
Iterator<?> recIt = adapter.getReceiverIterator();
if (recIt.hasNext()) {
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
Map<String, Object> receiverInfo = new HashMap<String, Object>();
RunStateEnum receiverRunState = receiver.getRunState();
receiverInfo.put("started", receiverRunState.equals(RunStateEnum.STARTED));
receiverInfo.put("state", receiverRunState.toString().toLowerCase().replace("*", ""));
receiverInfo.put("name", receiver.getName());
receiverInfo.put("class", ClassUtils.nameOf(receiver));
Map<String, Object> messages = new HashMap<String, Object>(3);
messages.put("received", receiver.getMessagesReceived());
messages.put("retried", receiver.getMessagesRetried());
messages.put("rejected", receiver.getMessagesRejected());
receiverInfo.put("messages", messages);
ISender sender = null;
if (receiver instanceof ReceiverBase) {
ReceiverBase rb = (ReceiverBase) receiver;
IListener listener = rb.getListener();
receiverInfo.put("listenerClass", ClassUtils.nameOf(listener));
if (listener instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) rb.getListener()).getPhysicalDestinationName();
receiverInfo.put("listenerDestination", pd);
}
if (listener instanceof HasSender) {
sender = ((HasSender) listener).getSender();
}
// receiverInfo.put("hasInprocessStorage", ""+(rb.getInProcessStorage()!=null));
ITransactionalStorage ts;
ts = rb.getErrorStorage();
receiverInfo.put("hasErrorStorage", (ts != null));
if (ts != null) {
try {
if (showCountErrorStore) {
receiverInfo.put("errorStorageCount", ts.getMessageCount());
} else {
receiverInfo.put("errorStorageCount", "?");
}
} catch (Exception e) {
log.warn(e);
receiverInfo.put("errorStorageCount", "error");
}
}
ts = rb.getMessageLog();
receiverInfo.put("hasMessageLog", (ts != null));
if (ts != null) {
try {
if (showCountMessageLog) {
receiverInfo.put("messageLogCount", ts.getMessageCount());
} else {
receiverInfo.put("messageLogCount", "?");
}
} catch (Exception e) {
log.warn(e);
receiverInfo.put("messageLogCount", "error");
}
}
boolean isRestListener = (listener instanceof RestListener);
receiverInfo.put("isRestListener", isRestListener);
if (isRestListener) {
RestListener rl = (RestListener) listener;
receiverInfo.put("restUriPattern", rl.getRestUriPattern());
receiverInfo.put("isView", (rl.isView() == null ? false : rl.isView()));
}
if ((listener instanceof JmsListenerBase) && showPendingMsgCount) {
JmsListenerBase jlb = (JmsListenerBase) listener;
JmsMessageBrowser jmsBrowser;
if (StringUtils.isEmpty(jlb.getMessageSelector())) {
jmsBrowser = new JmsMessageBrowser();
} else {
jmsBrowser = new JmsMessageBrowser(jlb.getMessageSelector());
}
jmsBrowser.setName("MessageBrowser_" + jlb.getName());
jmsBrowser.setJmsRealm(jlb.getJmsRealName());
jmsBrowser.setDestinationName(jlb.getDestinationName());
jmsBrowser.setDestinationType(jlb.getDestinationType());
String numMsgs;
try {
int messageCount = jmsBrowser.getMessageCount();
numMsgs = String.valueOf(messageCount);
} catch (Throwable t) {
log.warn(t);
numMsgs = "?";
}
receiverInfo.put("pendingMessagesCount", numMsgs);
}
boolean isEsbJmsFFListener = false;
if (listener instanceof EsbJmsListener) {
EsbJmsListener ejl = (EsbJmsListener) listener;
if (ejl.getMessageProtocol().equalsIgnoreCase("FF")) {
isEsbJmsFFListener = true;
}
if (showPendingMsgCount) {
String esbNumMsgs = EsbUtils.getQueueMessageCount(ejl);
if (esbNumMsgs == null) {
esbNumMsgs = "?";
}
receiverInfo.put("esbPendingMessagesCount", esbNumMsgs);
}
}
receiverInfo.put("isEsbJmsFFListener", isEsbJmsFFListener);
}
if (receiver instanceof HasSender) {
ISender rsender = ((HasSender) receiver).getSender();
if (rsender != null) {
// this sender has preference, but avoid overwriting listeners sender with null
sender = rsender;
}
}
if (sender != null) {
receiverInfo.put("senderName", sender.getName());
receiverInfo.put("senderClass", ClassUtils.nameOf(sender));
if (sender instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) sender).getPhysicalDestinationName();
receiverInfo.put("senderDestination", pd);
}
}
if (receiver instanceof IThreadCountControllable) {
IThreadCountControllable tcc = (IThreadCountControllable) receiver;
if (tcc.isThreadCountReadable()) {
receiverInfo.put("threadCount", tcc.getCurrentThreadCount());
receiverInfo.put("maxThreadCount", tcc.getMaxThreadCount());
}
if (tcc.isThreadCountControllable()) {
receiverInfo.put("threadCountControllable", "true");
}
}
receivers.add(receiverInfo);
}
}
return receivers;
}
use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class ShowConfigurationStatus method toReceiversXml.
private XmlBuilder toReceiversXml(Configuration configurationSelected, Adapter adapter, ShowConfigurationStatusManager showConfigurationStatusManager, ShowConfigurationStatusAdapterManager showConfigurationStatusAdapterManager) {
Iterator recIt = adapter.getReceiverIterator();
if (!recIt.hasNext()) {
return null;
}
XmlBuilder receiversXML = new XmlBuilder("receivers");
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
XmlBuilder receiverXML = new XmlBuilder("receiver");
receiversXML.addSubElement(receiverXML);
RunStateEnum receiverRunState = receiver.getRunState();
receiverXML.addAttribute("isStarted", "" + (receiverRunState.equals(RunStateEnum.STARTED)));
receiverXML.addAttribute("state", receiverRunState.toString());
if (receiverRunState.equals(RunStateEnum.STARTING)) {
showConfigurationStatusManager.countReceiverStateStarting++;
} else if ((receiverRunState.equals(RunStateEnum.STARTED))) {
showConfigurationStatusManager.countReceiverStateStarted++;
} else if ((receiverRunState.equals(RunStateEnum.STOPPING))) {
showConfigurationStatusManager.countReceiverStateStopping++;
} else if ((receiverRunState.equals(RunStateEnum.STOPPED))) {
showConfigurationStatusManager.countReceiverStateStopped++;
} else if ((receiverRunState.equals(RunStateEnum.ERROR))) {
showConfigurationStatusManager.countReceiverStateError++;
}
if (!showConfigurationStatusAdapterManager.stateAlert && !(receiverRunState.equals(RunStateEnum.STARTED))) {
showConfigurationStatusAdapterManager.stateAlert = true;
}
receiverXML.addAttribute("name", receiver.getName());
receiverXML.addAttribute("class", ClassUtils.nameOf(receiver));
receiverXML.addAttribute("messagesReceived", "" + receiver.getMessagesReceived());
receiverXML.addAttribute("messagesRetried", "" + receiver.getMessagesRetried());
receiverXML.addAttribute("messagesRejected", "" + receiver.getMessagesRejected());
if (configurationSelected != null) {
ISender sender = null;
if (receiver instanceof ReceiverBase) {
ReceiverBase rb = (ReceiverBase) receiver;
IListener listener = rb.getListener();
receiverXML.addAttribute("listenerClass", ClassUtils.nameOf(listener));
if (listener instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) rb.getListener()).getPhysicalDestinationName();
receiverXML.addAttribute("listenerDestination", pd);
}
if (listener instanceof HasSender) {
sender = ((HasSender) listener).getSender();
}
ITransactionalStorage ts;
ts = rb.getErrorStorage();
receiverXML.addAttribute("hasErrorStorage", "" + (ts != null));
if (ts != null) {
try {
if (SHOW_COUNT_ERRORSTORE) {
receiverXML.addAttribute("errorStorageCount", ts.getMessageCount());
} else {
receiverXML.addAttribute("errorStorageCount", "?");
}
} catch (Exception e) {
log.warn(e);
receiverXML.addAttribute("errorStorageCount", "error");
}
}
ts = rb.getMessageLog();
receiverXML.addAttribute("hasMessageLog", "" + (ts != null));
if (ts != null) {
try {
if (SHOW_COUNT_MESSAGELOG) {
receiverXML.addAttribute("messageLogCount", ts.getMessageCount());
} else {
receiverXML.addAttribute("messageLogCount", "?");
}
} catch (Exception e) {
log.warn(e);
receiverXML.addAttribute("messageLogCount", "error");
}
}
boolean isRestListener = (listener instanceof RestListener);
receiverXML.addAttribute("isRestListener", isRestListener);
if (isRestListener) {
RestListener rl = (RestListener) listener;
receiverXML.addAttribute("restUriPattern", rl.getRestUriPattern());
receiverXML.addAttribute("isView", (rl.isView() == null ? false : rl.isView()));
String matchingPattern = RestServiceDispatcher.getInstance().findMatchingPattern("/" + rl.getUriPattern());
receiverXML.addAttribute("isAvailable", (matchingPattern == null ? false : true));
}
if (showConfigurationStatusManager.count) {
if (listener instanceof JmsListenerBase) {
JmsListenerBase jlb = (JmsListenerBase) listener;
JmsMessageBrowser jmsBrowser;
if (StringUtils.isEmpty(jlb.getMessageSelector())) {
jmsBrowser = new JmsMessageBrowser();
} else {
jmsBrowser = new JmsMessageBrowser(jlb.getMessageSelector());
}
jmsBrowser.setName("MessageBrowser_" + jlb.getName());
jmsBrowser.setJmsRealm(jlb.getJmsRealName());
jmsBrowser.setDestinationName(jlb.getDestinationName());
jmsBrowser.setDestinationType(jlb.getDestinationType());
String numMsgs;
try {
int messageCount = jmsBrowser.getMessageCount();
numMsgs = String.valueOf(messageCount);
} catch (Throwable t) {
log.warn(t);
numMsgs = "?";
}
receiverXML.addAttribute("pendingMessagesCount", numMsgs);
}
}
boolean isEsbJmsFFListener = false;
if (listener instanceof EsbJmsListener) {
EsbJmsListener ejl = (EsbJmsListener) listener;
if ("FF".equalsIgnoreCase(ejl.getMessageProtocol())) {
isEsbJmsFFListener = true;
}
if (showConfigurationStatusManager.count) {
String esbNumMsgs = EsbUtils.getQueueMessageCount(ejl);
if (esbNumMsgs == null) {
esbNumMsgs = "?";
}
receiverXML.addAttribute("esbPendingMessagesCount", esbNumMsgs);
}
}
receiverXML.addAttribute("isEsbJmsFFListener", isEsbJmsFFListener);
}
if (receiver instanceof HasSender) {
ISender rsender = ((HasSender) receiver).getSender();
if (rsender != null) {
// this sender has preference, but
// avoid overwriting listeners
// sender with null
sender = rsender;
}
}
if (sender != null) {
receiverXML.addAttribute("senderName", sender.getName());
receiverXML.addAttribute("senderClass", ClassUtils.nameOf(sender));
if (sender instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) sender).getPhysicalDestinationName();
receiverXML.addAttribute("senderDestination", pd);
}
}
if (receiver instanceof IThreadCountControllable) {
IThreadCountControllable tcc = (IThreadCountControllable) receiver;
if (tcc.isThreadCountReadable()) {
receiverXML.addAttribute("threadCount", tcc.getCurrentThreadCount() + "");
receiverXML.addAttribute("maxThreadCount", tcc.getMaxThreadCount() + "");
}
if (tcc.isThreadCountControllable()) {
receiverXML.addAttribute("threadCountControllable", "true");
}
}
}
}
return receiversXML;
}
use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class Webservices method list.
private String list(IbisManager ibisManager) {
XmlBuilder webservicesXML = new XmlBuilder("webservices");
// RestListeners
XmlBuilder restsXML = new XmlBuilder("rests");
for (IAdapter a : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) a;
Iterator recIt = adapter.getReceiverIterator();
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
if (receiver instanceof ReceiverBase) {
ReceiverBase rb = (ReceiverBase) receiver;
IListener listener = rb.getListener();
if (listener instanceof RestListener) {
RestListener rl = (RestListener) listener;
if (rl.isView()) {
XmlBuilder restXML = new XmlBuilder("rest");
restXML.addAttribute("name", rb.getName());
restXML.addAttribute("uriPattern", rl.getUriPattern());
restsXML.addSubElement(restXML);
}
}
}
}
}
webservicesXML.addSubElement(restsXML);
// WSDL's
XmlBuilder wsdlsXML = new XmlBuilder("wsdls");
for (IAdapter a : ibisManager.getRegisteredAdapters()) {
XmlBuilder wsdlXML = new XmlBuilder("wsdl");
try {
Adapter adapter = (Adapter) a;
Wsdl wsdl = new Wsdl(adapter.getPipeLine());
wsdlXML.addAttribute("name", wsdl.getName());
wsdlXML.addAttribute("extention", getWsdlExtention());
} catch (Exception e) {
wsdlXML.addAttribute("name", a.getName());
XmlBuilder errorXML = new XmlBuilder("error");
if (e.getMessage() != null) {
errorXML.setCdataValue(e.getMessage());
} else {
errorXML.setCdataValue(e.toString());
}
wsdlXML.addSubElement(errorXML);
}
wsdlsXML.addSubElement(wsdlXML);
}
webservicesXML.addSubElement(wsdlsXML);
// ApiListeners
XmlBuilder apiListenerXML = new XmlBuilder("apiListeners");
SortedMap<String, ApiDispatchConfig> patternClients = ApiServiceDispatcher.getInstance().getPatternClients();
for (Entry<String, ApiDispatchConfig> client : patternClients.entrySet()) {
XmlBuilder apiXML = new XmlBuilder("apiListener");
ApiDispatchConfig config = client.getValue();
Set<String> methods = config.getMethods();
for (String method : methods) {
ApiListener listener = config.getApiListener(method);
XmlBuilder methodXML = new XmlBuilder(method);
String name = listener.getName();
if (name.contains("listener of ["))
name = name.substring(13, name.length() - 1);
methodXML.addAttribute("name", name);
methodXML.addAttribute("updateEtag", listener.getUpdateEtag());
methodXML.addAttribute("isRunning", listener.isRunning());
apiXML.addSubElement(methodXML);
}
apiXML.addAttribute("uriPattern", config.getUriPattern());
apiListenerXML.addSubElement(apiXML);
}
webservicesXML.addSubElement(apiListenerXML);
return webservicesXML.toXML();
}
use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class ShowAdapterStatistics method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
String adapterName = request.getParameter("adapterName");
String deepString = request.getParameter("deep");
boolean deep = "true".equals(deepString);
Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(adapterName);
XmlBuilder adapterXML = new XmlBuilder("adapterStatistics");
adapterXML.addAttribute("name", adapter.getName());
adapterXML.addAttribute("state", adapter.getRunState().toString());
adapterXML.addAttribute("upSince", adapter.getStatsUpSince());
adapterXML.addAttribute("lastMessageDate", adapter.getLastMessageDate());
adapterXML.addAttribute("messagesInProcess", "" + adapter.getNumOfMessagesInProcess());
adapterXML.addAttribute("messagesProcessed", "" + adapter.getNumOfMessagesProcessed());
adapterXML.addAttribute("messagesInError", "" + adapter.getNumOfMessagesInError());
StatisticsKeeper st = adapter.getStatsMessageProcessingDuration();
adapterXML.addSubElement(statisticsKeeperToXmlBuilder(st, "messageProcessingDuration", deep));
XmlBuilder messagesReceivedByHour = new XmlBuilder("messagesStartProcessingByHour");
adapterXML.addSubElement(messagesReceivedByHour);
long[] numOfMessagesStartProcessingByHour = adapter.getNumOfMessagesStartProcessingByHour();
for (int i = 0; i < numOfMessagesStartProcessingByHour.length; i++) {
XmlBuilder item = new XmlBuilder("item");
messagesReceivedByHour.addSubElement(item);
String startTime;
if (i < 10) {
startTime = "0" + i + ":00";
} else {
startTime = i + ":00";
}
item.addAttribute("startTime", startTime);
item.addAttribute("count", numOfMessagesStartProcessingByHour[i]);
}
Iterator recIt = adapter.getReceiverIterator();
if (recIt.hasNext()) {
XmlBuilder receiversXML = new XmlBuilder("receivers");
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
XmlBuilder receiverXML = new XmlBuilder("receiver");
receiversXML.addSubElement(receiverXML);
receiverXML.addAttribute("name", receiver.getName());
receiverXML.addAttribute("class", receiver.getClass().getName());
receiverXML.addAttribute("messagesReceived", "" + receiver.getMessagesReceived());
receiverXML.addAttribute("messagesRetried", "" + receiver.getMessagesRetried());
/*
if (receiver instanceof HasSender) {
ISender sender = ((HasSender) receiver).getSender();
if (sender != null)
receiverXML.addAttribute("senderName", sender.getName());
}
*/
if (receiver instanceof IReceiverStatistics) {
IReceiverStatistics statReceiver = (IReceiverStatistics) receiver;
Iterator statsIter;
statsIter = statReceiver.getProcessStatisticsIterator();
if (statsIter != null) {
XmlBuilder procStatsXML = new XmlBuilder("procStats");
// procStatsXML.addSubElement(statisticsKeeperToXmlBuilder(statReceiver.getResponseSizeStatistics(), "stat"));
while (statsIter.hasNext()) {
StatisticsKeeper pstat = (StatisticsKeeper) statsIter.next();
procStatsXML.addSubElement(statisticsKeeperToXmlBuilder(pstat, "stat", deep));
}
receiverXML.addSubElement(procStatsXML);
}
statsIter = statReceiver.getIdleStatisticsIterator();
if (statsIter != null) {
XmlBuilder procStatsXML = new XmlBuilder("idleStats");
while (statsIter.hasNext()) {
StatisticsKeeper pstat = (StatisticsKeeper) statsIter.next();
procStatsXML.addSubElement(statisticsKeeperToXmlBuilder(pstat, "stat", deep));
}
receiverXML.addSubElement(procStatsXML);
}
}
}
adapterXML.addSubElement(receiversXML);
}
StatisticsKeeperToXml handler = new StatisticsKeeperToXml(adapterXML, deep);
handler.configure();
Object handle = handler.start(null, null, null);
try {
Object pipelineData = handler.openGroup(handle, null, "pipeline");
adapter.getPipeLine().iterateOverStatistics(handler, pipelineData, HasStatistics.STATISTICS_ACTION_FULL);
} catch (SenderException e) {
log.error(e);
} finally {
handler.end(handle);
}
if (log.isDebugEnabled()) {
log.debug("about to set adapterStatistics [" + adapterXML.toXML() + "]");
// XmlBuilder alt = new XmlBuilder("alt");
// StatisticsKeeperToXml hh = new StatisticsKeeperToXml(alt);
// adapter.forEachStatisticsKeeper(hh,HasStatistics.STATISTICS_ACTION_NONE);
// log.debug("alternative ["+alt.toXML()+"]");
}
request.setAttribute("adapterStatistics", adapterXML.toXML());
// Forward control to the specified success URI
log.debug("forward to success");
return (mapping.findForward("success"));
}
Aggregations