# Java Service to Get Outstanding Events Count from UM Channel (Applicable for Publishable DocType only)

**URL:** <https://techcommunity.softwareag.com/t/java-service-to-get-outstanding-events-count-from-um-channel-applicable-for-publishable-doctype-only/237243>\
**Category:** Knowledge base\
**Tags:** universal-messaging\
**Created:** [June 5, 2019, 11:52am UTC](https://techcommunity.softwareag.com/t/java-service-to-get-outstanding-events-count-from-um-channel-applicable-for-publishable-doctype-only/237243 "2019-06-05T11:52:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahesh\_K\_Sreenivas](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/mahesh_k_sreenivas/32/299_2.png) [@Mahesh\_K\_Sreenivas](https://techcommunity.softwareag.com/u/Mahesh_K_Sreenivas)\
**Post date:** [June 5, 2019, 11:52am UTC](https://techcommunity.softwareag.com/t/java-service-to-get-outstanding-events-count-from-um-channel-applicable-for-publishable-doctype-only/237243/1 "2019-06-05T11:52:04Z")

</div>

This is a simple Java Service to get the outstanding events count from the UM Channel (Publishable Doc Type) and the same can be enhanced to get the outstanding events count for queue/topic. Make sure to import the below jars into your java project for compilation.

\UniversalMessaging\lib\nAdminAPI.jar

\UniversalMessaging\lib\nClient.jar

**Input:**

realmURL (eg.,&nbsp;nsp://localhost:9001)  
channelName (eg.,&nbsp;Default:pubDoc)

==================================================================================================================

**Output:**

outstandingEvents

==================================================================================================================

import com.wm.data.\*;  
import com.wm.util.Values;  
import com.wm.app.b2b.server.Service;  
import com.wm.app.b2b.server.ServiceException;  
import com.pcbsys.nirvana.client.nIllegalArgumentException;  
import com.pcbsys.nirvana.client.nSessionAttributes;  
import com.pcbsys.nirvana.nAdminAPI.nAdminIllegalArgumentException;  
import com.pcbsys.nirvana.nAdminAPI.nBaseAdminException;  
import com.pcbsys.nirvana.nAdminAPI.nLeafNode;  
import com.pcbsys.nirvana.nAdminAPI.nNode;  
import com.pcbsys.nirvana.nAdminAPI.nRealmNode;

public static final void getOEvents(IData pipeline) throws ServiceException {

// pipeline

IDataCursor pipelineCursor = pipeline.getCursor();

String realmURL = IDataUtil.getString( pipelineCursor, "realmURL" );

String channelName = IDataUtil.getString( pipelineCursor, "channelName" );

channelName=channelName.replace(":", "/");

String channelNS = "wm/is/" + channelName;

String outstandingEvents="";

&nbsp;

&nbsp;

nSessionAttributes nsa = null;

try {

nsa = new nSessionAttributes(realmURL);

} catch (nIllegalArgumentException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

// get the root realm node from the realm admin

nRealmNode realmNode = null;

try {

realmNode = new nRealmNode(nsa);

} catch (nBaseAdminException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

&nbsp;

&nbsp;

&nbsp; &nbsp; &nbsp; realmNode.waitForEntireNameSpace();

&nbsp; &nbsp; &nbsp;&nbsp;

&nbsp; &nbsp; &nbsp; try {

&nbsp; nLeafNode leafNode = (nLeafNode) realmNode.findNode(channelNS);

&nbsp; try {

Thread.sleep(2000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

&nbsp; &nbsp; &nbsp; long osEvents=leafNode.getCurrentNumberOfEvents();

&nbsp; &nbsp; &nbsp; &nbsp;outstandingEvents = Long.toString(osEvents);

&nbsp;

} catch (nAdminIllegalArgumentException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

&nbsp;

IDataUtil.put( pipelineCursor, "outstandingEvents", outstandingEvents );

pipelineCursor.destroy();

&nbsp;

}

&nbsp;

==================================================================================================================

Let me know if you have any questions.
