How to get the depth of a channel
I am using a pollable channel in my java code as follows:
ApplicationContext context = new ClassPathXmlApplicationContext("com.mydirectory/integration.xml");
channel = (PollableChannel) context.getBean("annotatorChannel");
Then in one of my methods, I do:
I want to check the depth of this channel before I execute the above line of code. Is there a way to do this?
My integration.xml file has the following lines which are relevant to this:
<int:channel id="annotatorChannel" datatype="com.mypackage.AuditEvent">
<int:queue capacity="1000" />
So is there a way in java code to see what depth ( or number of events) the queue has reached before I do:
as mentioned above.
So basically I want to check the lenght of the channel(queue) and if it has exceeded 1000, then I want to throw an excpetion. Maybe something like this:
if (channel.length >= 1000)
but I am not sure how to get the number of events currently in the channel queue.