use of nl.nn.adapterframework.core.HasPhysicalDestination in project iaf by ibissource.
the class ShowConfigurationStatus method mapAdapterPipes.
private ArrayList<Object> mapAdapterPipes(Adapter adapter) {
if (!adapter.configurationSucceeded())
return null;
PipeLine pipeline = adapter.getPipeLine();
int totalPipes = pipeline.getPipes().size();
ArrayList<Object> pipes = new ArrayList<Object>(totalPipes);
for (int i = 0; i < totalPipes; i++) {
Map<String, Object> pipesInfo = new HashMap<String, Object>();
IPipe pipe = pipeline.getPipe(i);
Map<String, PipeForward> pipeForwards = pipe.getForwards();
String pipename = pipe.getName();
Map<String, String> forwards = new HashMap<String, String>();
for (PipeForward fwrd : pipeForwards.values()) {
forwards.put(fwrd.getName(), fwrd.getPath());
}
pipesInfo.put("name", pipename);
pipesInfo.put("type", pipe.getType());
pipesInfo.put("forwards", forwards);
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
ISender sender = msp.getSender();
pipesInfo.put("sender", ClassUtils.nameOf(sender));
if (sender instanceof WebServiceSender) {
WebServiceSender s = (WebServiceSender) sender;
Map<String, Object> certInfo = addCertificateInfo(s);
if (certInfo != null)
pipesInfo.put("certificate", certInfo);
}
if (sender instanceof HttpSender) {
HttpSender s = (HttpSender) sender;
Map<String, Object> certInfo = addCertificateInfo(s);
if (certInfo != null)
pipesInfo.put("certificate", certInfo);
}
if (sender instanceof FtpSender) {
FtpSender s = (FtpSender) sender;
Map<String, Object> certInfo = addCertificateInfo(s);
if (certInfo != null)
pipesInfo.put("certificate", certInfo);
}
if (sender instanceof HasPhysicalDestination) {
pipesInfo.put("destination", ((HasPhysicalDestination) sender).getPhysicalDestinationName());
}
if (sender instanceof JdbcSenderBase) {
pipesInfo.put("isJdbcSender", true);
}
IListener listener = msp.getListener();
if (listener != null) {
pipesInfo.put("listenerName", listener.getName());
pipesInfo.put("listenerClass", ClassUtils.nameOf(listener));
if (listener instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) listener).getPhysicalDestinationName();
pipesInfo.put("listenerDestination", pd);
}
}
ITransactionalStorage messageLog = msp.getMessageLog();
if (messageLog != null) {
pipesInfo.put("hasMessageLog", true);
String messageLogCount;
try {
if (showCountMessageLog) {
messageLogCount = "" + messageLog.getMessageCount();
} else {
messageLogCount = "?";
}
} catch (Exception e) {
log.warn(e);
messageLogCount = "error";
}
pipesInfo.put("messageLogCount", messageLogCount);
Map<String, Object> message = new HashMap<String, Object>();
message.put("name", messageLog.getName());
message.put("type", "log");
message.put("slotId", messageLog.getSlotId());
message.put("count", messageLogCount);
pipesInfo.put("message", message);
}
}
pipes.add(pipesInfo);
}
return pipes;
}
use of nl.nn.adapterframework.core.HasPhysicalDestination in project iaf by ibissource.
the class ShowConfigurationStatus method toPipesXml.
private XmlBuilder toPipesXml(Adapter adapter) {
XmlBuilder pipesElem = new XmlBuilder("pipes");
PipeLine pipeline = adapter.getPipeLine();
for (int i = 0; i < pipeline.getPipes().size(); i++) {
IPipe pipe = pipeline.getPipe(i);
String pipename = pipe.getName();
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
XmlBuilder pipeElem = new XmlBuilder("pipe");
pipeElem.addAttribute("name", pipename);
pipesElem.addSubElement(pipeElem);
ISender sender = msp.getSender();
pipeElem.addAttribute("sender", ClassUtils.nameOf(sender));
if (sender instanceof HasPhysicalDestination) {
pipeElem.addAttribute("destination", ((HasPhysicalDestination) sender).getPhysicalDestinationName());
}
if (sender instanceof JdbcSenderBase) {
pipeElem.addAttribute("isJdbcSender", "true");
}
IListener listener = msp.getListener();
if (listener != null) {
pipeElem.addAttribute("listenerName", listener.getName());
pipeElem.addAttribute("listenerClass", ClassUtils.nameOf(listener));
if (listener instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) listener).getPhysicalDestinationName();
pipeElem.addAttribute("listenerDestination", pd);
}
}
ITransactionalStorage messageLog = msp.getMessageLog();
if (messageLog != null) {
pipeElem.addAttribute("hasMessageLog", "true");
String messageLogCount;
try {
if (SHOW_COUNT_MESSAGELOG) {
messageLogCount = "" + messageLog.getMessageCount();
} else {
messageLogCount = "?";
}
} catch (Exception e) {
log.warn(e);
messageLogCount = "error";
}
pipeElem.addAttribute("messageLogCount", messageLogCount);
XmlBuilder browserElem = new XmlBuilder("browser");
browserElem.addAttribute("name", messageLog.getName());
browserElem.addAttribute("type", "log");
browserElem.addAttribute("slotId", messageLog.getSlotId());
browserElem.addAttribute("count", messageLogCount);
pipeElem.addSubElement(browserElem);
}
}
}
return pipesElem;
}
use of nl.nn.adapterframework.core.HasPhysicalDestination in project iaf by ibissource.
the class MessageSendingPipe method configure.
/**
* Checks whether a sender is defined for this pipe.
*/
@Override
public void configure() throws ConfigurationException {
super.configure();
if (StringUtils.isNotEmpty(getStubFileName())) {
URL stubUrl;
try {
stubUrl = ClassUtils.getResourceURL(classLoader, getStubFileName());
} catch (Throwable e) {
throw new ConfigurationException(getLogPrefix(null) + "got exception finding resource for stubfile [" + getStubFileName() + "]", e);
}
if (stubUrl == null) {
throw new ConfigurationException(getLogPrefix(null) + "could not find resource for stubfile [" + getStubFileName() + "]");
}
try {
returnString = Misc.resourceToString(stubUrl, SystemUtils.LINE_SEPARATOR);
} catch (Throwable e) {
throw new ConfigurationException(getLogPrefix(null) + "got exception loading stubfile [" + getStubFileName() + "] from resource [" + stubUrl.toExternalForm() + "]", e);
}
} else {
propagateName();
if (getSender() == null) {
throw new ConfigurationException(getLogPrefix(null) + "no sender defined ");
}
try {
if (getSender() instanceof PipeAware) {
((PipeAware) getSender()).setPipe(this);
}
getSender().configure();
} catch (ConfigurationException e) {
throw new ConfigurationException(getLogPrefix(null) + "while configuring sender", e);
}
if (getSender() instanceof HasPhysicalDestination) {
log.info(getLogPrefix(null) + "has sender on " + ((HasPhysicalDestination) getSender()).getPhysicalDestinationName());
}
if (getListener() != null) {
if (getSender().isSynchronous()) {
throw new ConfigurationException(getLogPrefix(null) + "cannot have listener with synchronous sender");
}
try {
getListener().configure();
} catch (ConfigurationException e) {
throw new ConfigurationException(getLogPrefix(null) + "while configuring listener", e);
}
if (getListener() instanceof HasPhysicalDestination) {
log.info(getLogPrefix(null) + "has listener on " + ((HasPhysicalDestination) getListener()).getPhysicalDestinationName());
}
}
if (!(getLinkMethod().equalsIgnoreCase("MESSAGEID")) && (!(getLinkMethod().equalsIgnoreCase("CORRELATIONID")))) {
throw new ConfigurationException(getLogPrefix(null) + "Invalid argument for property LinkMethod [" + getLinkMethod() + "]. it should be either MESSAGEID or CORRELATIONID");
}
if (!(getHideMethod().equalsIgnoreCase("all")) && (!(getHideMethod().equalsIgnoreCase("firstHalf")))) {
throw new ConfigurationException(getLogPrefix(null) + "invalid value for hideMethod [" + getHideMethod() + "], must be 'all' or 'firstHalf'");
}
if (isCheckXmlWellFormed() || StringUtils.isNotEmpty(getCheckRootTag())) {
if (findForward(ILLEGAL_RESULT_FORWARD) == null)
throw new ConfigurationException(getLogPrefix(null) + "has no forward with name [illegalResult]");
}
if (!ConfigurationUtils.stubConfiguration()) {
if (StringUtils.isNotEmpty(getTimeOutOnResult())) {
throw new ConfigurationException(getLogPrefix(null) + "timeOutOnResult only allowed in stub mode");
}
if (StringUtils.isNotEmpty(getExceptionOnResult())) {
throw new ConfigurationException(getLogPrefix(null) + "exceptionOnResult only allowed in stub mode");
}
}
if (getMaxRetries() > 0) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
if (getRetryMinInterval() < MIN_RETRY_INTERVAL) {
String msg = "retryMinInterval [" + getRetryMinInterval() + "] should be greater than or equal to [" + MIN_RETRY_INTERVAL + "], assuming the lower limit";
configWarnings.add(log, msg);
setRetryMinInterval(MIN_RETRY_INTERVAL);
}
if (getRetryMaxInterval() > MAX_RETRY_INTERVAL) {
String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be less than or equal to [" + MAX_RETRY_INTERVAL + "], assuming the upper limit";
configWarnings.add(log, msg);
setRetryMaxInterval(MAX_RETRY_INTERVAL);
}
if (getRetryMaxInterval() < getRetryMinInterval()) {
String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be greater than or equal to [" + getRetryMinInterval() + "], assuming the lower limit";
configWarnings.add(log, msg);
setRetryMaxInterval(getRetryMinInterval());
}
}
}
ITransactionalStorage messageLog = getMessageLog();
if (checkMessageLog) {
if (!getSender().isSynchronous() && getListener() == null && !(getSender() instanceof nl.nn.adapterframework.senders.IbisLocalSender)) {
if (messageLog == null) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
String msg = "asynchronous sender [" + getSender().getName() + "] without sibling listener has no messageLog. Integrity check not possible";
configWarnings.add(log, msg);
}
}
}
if (messageLog != null) {
messageLog.configure();
if (messageLog instanceof HasPhysicalDestination) {
String msg = getLogPrefix(null) + "has messageLog in " + ((HasPhysicalDestination) messageLog).getPhysicalDestinationName();
log.info(msg);
if (getAdapter() != null)
getAdapter().getMessageKeeper().add(msg);
}
if (StringUtils.isNotEmpty(getAuditTrailXPath())) {
auditTrailTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getAuditTrailNamespaceDefs(), getAuditTrailXPath(), null, "text", false, null);
}
if (StringUtils.isNotEmpty(getCorrelationIDXPath()) || StringUtils.isNotEmpty(getCorrelationIDStyleSheet())) {
correlationIDTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getCorrelationIDNamespaceDefs(), getCorrelationIDXPath(), getCorrelationIDStyleSheet(), "text", false, null);
}
if (StringUtils.isNotEmpty(getLabelXPath()) || StringUtils.isNotEmpty(getLabelStyleSheet())) {
labelTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getLabelNamespaceDefs(), getLabelXPath(), getLabelStyleSheet(), "text", false, null);
}
}
if (StringUtils.isNotEmpty(getRetryXPath())) {
retryTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getRetryNamespaceDefs(), getRetryXPath(), null, "text", false, null);
}
IPipe inputValidator = getInputValidator();
IPipe outputValidator = getOutputValidator();
if (inputValidator != null && outputValidator == null && inputValidator instanceof IDualModeValidator) {
outputValidator = ((IDualModeValidator) inputValidator).getResponseValidator();
setOutputValidator(outputValidator);
}
if (inputValidator != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
inputValidator.registerForward(pf);
// inputValidator.configure(); // configure is handled in PipeLine.configure()
}
if (outputValidator != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
outputValidator.registerForward(pf);
// outputValidator.configure(); // configure is handled in PipeLine.configure()
}
if (getInputWrapper() != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
getInputWrapper().registerForward(pf);
if (getInputWrapper() instanceof EsbSoapWrapperPipe) {
EsbSoapWrapperPipe eswPipe = (EsbSoapWrapperPipe) getInputWrapper();
ISender sender = getSender();
eswPipe.retrievePhysicalDestinationFromSender(sender);
}
}
if (getOutputWrapper() != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
getOutputWrapper().registerForward(pf);
}
registerEvent(PIPE_TIMEOUT_MONITOR_EVENT);
registerEvent(PIPE_CLEAR_TIMEOUT_MONITOR_EVENT);
registerEvent(PIPE_EXCEPTION_MONITOR_EVENT);
}
use of nl.nn.adapterframework.core.HasPhysicalDestination in project iaf by ibissource.
the class ReceiverBase method configure.
public void configure() throws ConfigurationException {
configurationSucceeded = false;
try {
if (StringUtils.isEmpty(getName())) {
if (getListener() != null) {
setName(ClassUtils.nameOf(getListener()));
} else {
setName(ClassUtils.nameOf(this));
}
}
eventHandler = MonitorManager.getEventHandler();
registerEvent(RCV_CONFIGURED_MONITOR_EVENT);
registerEvent(RCV_CONFIGURATIONEXCEPTION_MONITOR_EVENT);
registerEvent(RCV_STARTED_RUNNING_MONITOR_EVENT);
registerEvent(RCV_SHUTDOWN_MONITOR_EVENT);
registerEvent(RCV_SUSPENDED_MONITOR_EVENT);
registerEvent(RCV_RESUMED_MONITOR_EVENT);
registerEvent(RCV_THREAD_EXIT_MONITOR_EVENT);
TXNEW_PROC = SpringTxManagerProxy.getTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW, getTransactionTimeout());
// to use direct member variables).
if (this.tmpInProcessStorage != null) {
if (this.errorSender == null && this.errorStorage == null) {
this.errorStorage = this.tmpInProcessStorage;
info(getLogPrefix() + "has errorStorage in inProcessStorage, setting inProcessStorage's type to 'errorStorage'. Please update the configuration to change the inProcessStorage element to an errorStorage element, since the inProcessStorage is no longer used.");
errorStorage.setType(JdbcTransactionalStorage.TYPE_ERRORSTORAGE);
} else {
info(getLogPrefix() + "has inProcessStorage defined but also has an errorStorage or errorSender. InProcessStorage is not used and can be removed from the configuration.");
}
// Set temporary in-process storage pointer to null
this.tmpInProcessStorage = null;
}
// Do propagate-name AFTER changing the errorStorage!
propagateName();
if (getListener() == null) {
throw new ConfigurationException(getLogPrefix() + "has no listener");
}
if (!StringUtils.isEmpty(getElementToMove()) && !StringUtils.isEmpty(getElementToMoveChain())) {
throw new ConfigurationException("cannot have both an elementToMove and an elementToMoveChain specified");
}
if (!(getHideMethod().equalsIgnoreCase("all")) && (!(getHideMethod().equalsIgnoreCase("firstHalf")))) {
throw new ConfigurationException(getLogPrefix() + "invalid value for hideMethod [" + getHideMethod() + "], must be 'all' or 'firstHalf'");
}
if (getListener() instanceof ReceiverAware) {
((ReceiverAware) getListener()).setReceiver(this);
}
if (getListener() instanceof IPushingListener) {
IPushingListener pl = (IPushingListener) getListener();
pl.setHandler(this);
pl.setExceptionListener(this);
}
if (getListener() instanceof IPortConnectedListener) {
IPortConnectedListener pcl = (IPortConnectedListener) getListener();
pcl.setReceiver(this);
}
if (getListener() instanceof IPullingListener) {
setListenerContainer(createListenerContainer());
}
if (getListener() instanceof JdbcFacade) {
((JdbcFacade) getListener()).setTransacted(isTransacted());
}
if (getListener() instanceof JMSFacade) {
((JMSFacade) getListener()).setTransacted(isTransacted());
}
getListener().configure();
if (getListener() instanceof HasPhysicalDestination) {
info(getLogPrefix() + "has listener on " + ((HasPhysicalDestination) getListener()).getPhysicalDestinationName());
}
if (getListener() instanceof HasSender) {
// only informational
ISender sender = ((HasSender) getListener()).getSender();
if (sender instanceof HasPhysicalDestination) {
info("Listener of receiver [" + getName() + "] has answer-sender on " + ((HasPhysicalDestination) sender).getPhysicalDestinationName());
}
}
if (getListener() instanceof ITransactionRequirements) {
ITransactionRequirements tr = (ITransactionRequirements) getListener();
if (tr.transactionalRequired() && !isTransacted()) {
String msg = getLogPrefix() + "listener type [" + ClassUtils.nameOf(getListener()) + "] requires transactional processing";
ConfigurationWarnings.getInstance().add(msg);
// throw new ConfigurationException(msg);
}
}
ISender sender = getSender();
if (sender != null) {
sender.configure();
if (sender instanceof HasPhysicalDestination) {
info(getLogPrefix() + "has answer-sender on " + ((HasPhysicalDestination) sender).getPhysicalDestinationName());
}
}
ISender errorSender = getErrorSender();
if (errorSender != null) {
errorSender.configure();
if (errorSender instanceof HasPhysicalDestination) {
info(getLogPrefix() + "has errorSender to " + ((HasPhysicalDestination) errorSender).getPhysicalDestinationName());
}
}
ITransactionalStorage errorStorage = getErrorStorage();
if (errorStorage != null) {
errorStorage.configure();
if (errorStorage instanceof HasPhysicalDestination) {
info(getLogPrefix() + "has errorStorage to " + ((HasPhysicalDestination) errorStorage).getPhysicalDestinationName());
}
registerEvent(RCV_MESSAGE_TO_ERRORSTORE_EVENT);
}
ITransactionalStorage messageLog = getMessageLog();
if (messageLog != null) {
messageLog.configure();
if (messageLog instanceof HasPhysicalDestination) {
info(getLogPrefix() + "has messageLog in " + ((HasPhysicalDestination) messageLog).getPhysicalDestinationName());
}
if (StringUtils.isNotEmpty(getLabelXPath()) || StringUtils.isNotEmpty(getLabelStyleSheet())) {
labelTp = TransformerPool.configureTransformer0(getLogPrefix(), classLoader, getLabelNamespaceDefs(), getLabelXPath(), getLabelStyleSheet(), "text", false, null, isXslt2());
}
}
if (isTransacted()) {
if (errorSender == null && errorStorage == null) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
String msg = getLogPrefix() + "sets transactionAttribute=" + getTransactionAttribute() + ", but has no errorSender or errorStorage. Messages processed with errors will be lost";
configWarnings.add(log, msg);
} else {
// if (errorSender!=null && !(errorSender instanceof IXAEnabled && ((IXAEnabled)errorSender).isTransacted())) {
// warn(getLogPrefix()+"sets transacted=true, but errorSender is not. Transactional integrity is not guaranteed");
// }
// if (errorStorage!=null && !(errorStorage instanceof IXAEnabled && ((IXAEnabled)errorStorage).isTransacted())) {
// warn(getLogPrefix()+"sets transacted=true, but errorStorage is not. Transactional integrity is not guaranteed");
// }
}
if (getTransactionTimeout() > 0) {
String systemTransactionTimeout = Misc.getSystemTransactionTimeout();
if (systemTransactionTimeout != null && StringUtils.isNumeric(systemTransactionTimeout)) {
int stt = Integer.parseInt(systemTransactionTimeout);
if (getTransactionTimeout() > stt) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
String msg = getLogPrefix() + "has a transaction timeout [" + getTransactionTimeout() + "] which exceeds the system transaction timeout [" + stt + "]";
configWarnings.add(log, msg);
}
}
}
}
if (StringUtils.isNotEmpty(getCorrelationIDXPath()) || StringUtils.isNotEmpty(getCorrelationIDStyleSheet())) {
correlationIDTp = TransformerPool.configureTransformer0(getLogPrefix(), classLoader, getCorrelationIDNamespaceDefs(), getCorrelationIDXPath(), getCorrelationIDStyleSheet(), "text", false, null, isXslt2());
}
if (adapter != null) {
adapter.getMessageKeeper().add(getLogPrefix() + "initialization complete");
}
throwEvent(RCV_CONFIGURED_MONITOR_EVENT);
configurationSucceeded = true;
} catch (Throwable t) {
ConfigurationException e = null;
if (t instanceof ConfigurationException) {
e = (ConfigurationException) t;
} else {
e = new ConfigurationException("Exception configuring receiver [" + getName() + "]", t);
}
throwEvent(RCV_CONFIGURATIONEXCEPTION_MONITOR_EVENT);
log.debug(getLogPrefix() + "Errors occured during configuration, setting runstate to ERROR");
runState.setRunState(RunStateEnum.ERROR);
throw e;
}
}
use of nl.nn.adapterframework.core.HasPhysicalDestination 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;
}
Aggregations