QueueConnection cnn = null;
QueueSender sender = null;
QueueSession session = null;
Queue queue = (Queue) getInitialContext().lookup("queue/mdbsessionpoolclearQueue");
QueueConnectionFactory factory = getQueueConnectionFactory();
cnn = factory.createQueueConnection();
session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
TextMessage msg = session.createTextMessage("Hello World " + new Date());
sender = session.createSender(queue);
sender.send(msg);
session.close();
cnn.close();
Thread.sleep(5 * 1000);
assertEquals(1, status.queueFired());
MBeanServerConnection server = getServer();
ObjectName provider = null;
ObjectName providerQuery = new ObjectName("jboss.j2ee:service=EJB,*");
Iterator mbeans = server.queryMBeans(providerQuery, null).iterator();
while (provider == null)
{
ObjectInstance providerInstance = (ObjectInstance)mbeans.next();
String name = providerInstance.getObjectName().toString();
if (name.contains("Mdb") && !name.contains("plugin"))
provider = providerInstance.getObjectName();
}
Object[] params = {};
String[] sig = {};
Object success = server.invoke(provider, "stop", params, sig);
ObjectName jmsContainerInvokerQuery = new ObjectName("jboss.j2ee:binding=my-message-driven-bean,*");
Set mbeansSet = server.queryMBeans(jmsContainerInvokerQuery, null);
assertEquals(1, mbeansSet.size());
ObjectInstance jmsContainerInvokerInstance = (ObjectInstance)mbeansSet.iterator().next();
ObjectName jmsContainerInvoker = jmsContainerInvokerInstance.getObjectName();
// int numActiveSessions = (Integer)server.getAttribute(jmsContainerInvoker, "NumActiveSessions");
// assertEquals(1, numActiveSessions);
/*boolean forceClear = (Boolean)server.getAttribute(jmsContainerInvoker, "ForceClearOnShutdown");
assertFalse(forceClear);
int forceClearAttempts = (Integer)server.getAttribute(jmsContainerInvoker, "ForceClearAttempts");
assertEquals(5, forceClearAttempts);
long forceClearOnShutdownInterval = (Long)server.getAttribute(jmsContainerInvoker, "ForceClearOnShutdownInterval");
assertEquals(30000, forceClearOnShutdownInterval); */
Thread.sleep(2 * 1000);
success = server.invoke(provider, "start", params, sig);
Thread.sleep(60 * 1000);
// numActiveSessions = (Integer)server.getAttribute(jmsContainerInvoker, "NumActiveSessions");
// assertEquals(1, numActiveSessions);
cnn = factory.createQueueConnection();
session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
msg = session.createTextMessage("Hello World " + new Date());
sender = session.createSender(queue);