[JBoss Messaging] - Re: How do I empty a JBoss queue?
by asaur
oops. I forgot to put the client code... here it goes (I have cut out the package and import sections, just for brevity):
=======================
public class PPMessageConsumer implements ServletContextListener {
private static final int NUMBER_OF_LISTENERS = 5;
AppListenerThread[] consumer = new AppListenerThread[NUMBER_OF_LISTENERS];
Properties context = new Properties();
private static final Logger log = Logger.getLogger("messaging");
private static final String[] QUEUE_APPS = new String[] {
"/queue/messageIdQueueApp1",
"/queue/messageIdQueueApp2",
"/queue/messageIdQueueApp3",
"/queue/messageIdQueueApp4",
"/queue/messageIdQueueApp5"
};
public void contextDestroyed(ServletContextEvent sce) {
for (int i = 0; i < NUMBER_OF_LISTENERS; i++) {
consumer.should_die = true;
consumer.interrupt();
}
}
public void contextInitialized(ServletContextEvent sce) {
InetAddress addr;
BufferedInputStream fs = new BufferedInputStream(this.getClass().getResourceAsStream("/parperfeito/service/locator/jndi.properties"));
int app = 0;
try {
context.load(fs);
addr = InetAddress.getLocalHost();
log.debug("Host addr = " + addr.getHostAddress());
log.debug("Host name = " + addr.getHostName());
if (addr != null) {
String name = addr.getHostName();
//String name = "pp5.parperfeito.com.br";
int pos = name.indexOf(".");
name = name.substring(pos -1 , pos);
app = Integer.parseInt(name) - 1;
}
for (int i = 0; i < NUMBER_OF_LISTENERS; i++) {
consumer = new AppListenerThread(QUEUE_APPS[app]);
consumer.start();
}
} catch (UnknownHostException ex) {
log.error(ex);
} catch (IOException ex) {
log.error(ex);
} catch (NumberFormatException ex) {
log.error(ex);
} finally {
if (fs != null) {
try {
fs.close();
} catch (IOException ex) {}
}
}
}
public void testHost() {
InetAddress addr;
try {
addr = InetAddress.getLocalHost();
System.out.println("Host addr = " + addr.getHostAddress());
System.out.println("Host name = " + addr.getHostName());
for (int i = 0; i < NUMBER_OF_LISTENERS; i++) {
consumer = new AppListenerThread(QUEUE_APPS[0]);
consumer.start();
}
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
private class AppListenerThread extends Thread implements ExceptionListener {
private static final String CONNECTION_FACTORY_NAME = "/ConnectionFactory";
public boolean should_die = false;
private boolean recycle = false;
private boolean initialised = false;
private String queue_name = null;
public AppListenerThread(String app_queue) {
queue_name = app_queue;
}
public void run() {
InitialContext ic = null;
ConnectionFactory factory = null;
Connection connection = null;
Queue message_queue = null;
Session session = null;
MessageConsumer consumer = null;
log.info("[Message Consumer] Destination queue is " + queue_name);
if (queue_name != null) {
while (!should_die) {
if (!initialised) {
// finding factory to create a connection and the queue to listen to
try {
ic = new InitialContext(context);
factory = (ConnectionFactory) ic.lookup(CONNECTION_FACTORY_NAME);
message_queue = (Queue) ic.lookup(queue_name);
} catch (NamingException e) {
log.error(e);
} finally {
if (ic != null) {
try {
ic.close();
} catch (NamingException e) { }
}
}
// setting listener up
try {
if (message_queue != null) {
connection = factory.createConnection();
connection.setExceptionListener(this);
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(message_queue);
// this must be asynchronous, so we need to implement a message listener
consumer.setMessageListener(new PPMessageListener());
connection.start();
initialised = true;
}
} catch (JMSException e) {
log.error(e);
recycle = true;
}
}
if (recycle) {
if (consumer != null) {
try {
consumer.setMessageListener(null);
consumer.close();
} catch (Exception ex) {}
}
if (session != null) {
try {
session.close();
} catch (Exception ex) {}
}
if (connection != null) {
try {
connection.close();
} catch (Exception ex) {}
}
consumer = null;
session = null;
connection = null;
factory = null;
message_queue = null;
initialised = false;
recycle = false;
}
log.debug("[Message Consumer] Consumer thread going to sleep at " + new java.util.Date());
try {
Thread.sleep(50000);
} catch (InterruptedException e) {
log.info("[Message Consumer] Oh my! Someone called!");
}
log.debug("[Message Consumer] Consumer thread woke up at " + new java.util.Date());
}
}
if (connection != null) {
try {
connection.close();
} catch (Exception ex) {}
}
log.info("[Message Consumer] Consumer thread finishing processing at " + new java.util.Date());
}
public void onException(JMSException ex) {
log.error(ex);
recycle = true;
}
}
}
=====================================
Hope this can someway share a light...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4168453#4168453
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4168453
17 years, 8 months
[JBoss Messaging] - Re: How do I empty a JBoss queue?
by asaur
"timfox" wrote : As previously mentioned, messages will get put back on the queue when the client gets timed out (not when another client reconnects).
|
| If you can produce a simple self contained test case that we can run that demonstrates otherwise we will be happy to investigate further.
Well, I'm really sorry about it but I don't think I have time right now to make a self contained test to ascertain what the problem is. :(
However, I can send you my client code for you to see, maybe my exception handling or my connection initialization is terribly wrong somewhere. The problem still persists, though. This weekend something happened (I really don't know why because the logs didn't report any exception at all) in all my clients and all of my server queues (I have 4 queues), because there were over 45000 messages in each. The few exceptions that were actually reported are recoverable ones in normal circumstances:
Cannot find object in dispatcher with id b7px3-yixlxejf-1-ut6qicjf-woegd9-100j3
Cannot find object in dispatcher with id d7px3-3jxlxejf-1-ut6qicjf-woegd9-100j3
...
There were 6 messages like that over the weekend but as soon as the client gets one of these, they report and reinitialize themselves. In normal circumstances, as you said, the queue would receive all the messages back and the new client would them consume them in proper time. Unfortunately, that's not what happened.
I also thought of updating jboss' remote library to the latest version (I was using jboss-remoting.jar version 2.2.2.SP4 - brewbuilder), but I'm not sure it was a good move - as soon as I started using version 2.4.0.GA a warning was reported in both the server's and client's log:
WARN [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] numberOfRetries is no longer used
Well, I'm sorry to take up your time guys, I'll try to make a test sometime in the near future for you to use.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4168448#4168448
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4168448
17 years, 8 months
[Installation, Configuration & DEPLOYMENT] - Re: newbie: jboss installation question
by reaverbrook
Thank you for replying me post.
anonymous wrote : Which version of JBoss? Where did you download it from?
The version is jboss-4.2.3.GA, and I download from jboss.org, i was redirected to souceforge.org.
anonymous wrote : Is this a typo? The run.sh is in JBOSS_HOME/bin and not the lib folder.
Yes, it is a typo. I am sorry I am a beginner.
anonymous wrote : Please post the entire exception stacktrace. Also post the logs that you see on the console.
reaverbrook@linux-nsfe:~/jboss-4.2.3.GA/bin> ./run.sh
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /home/reaverbrook/jboss-4.2.3.GA
JAVA: /usr/java/jdk1.5.0_16/bin/java
JAVA_OPTS: -Dprogram.name=run.sh -server -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true
CLASSPATH: /home/reaverbrook/jboss-4.2.3.GA/bin/run.jar:/usr/java/jdk1.5.0_16/lib/tools.jar
=========================================================================
08:04:38,171 INFO [Server] Starting JBoss (MX MicroKernel)...
08:04:38,213 INFO [Server] Release ID: JBoss [Trinity] 4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)
08:04:38,214 INFO [Server] Home Dir: /home/reaverbrook/jboss-4.2.3.GA
08:04:38,214 INFO [Server] Home URL: file:/home/reaverbrook/jboss-4.2.3.GA/
08:04:38,215 INFO [Server] Patch URL: null
08:04:38,215 INFO [Server] Server Name: default
08:04:38,215 INFO [Server] Server Home Dir: /home/reaverbrook/jboss-4.2.3.GA/server/default
08:04:38,216 INFO [Server] Server Home URL: file:/home/reaverbrook/jboss-4.2.3.GA/server/default/
08:04:38,216 INFO [Server] Server Log Dir: /home/reaverbrook/jboss-4.2.3.GA/server/default/log
08:04:38,216 INFO [Server] Server Temp Dir: /home/reaverbrook/jboss-4.2.3.GA/server/default/tmp
08:04:38,216 INFO [Server] Root Deployment Filename: jboss-service.xml
08:04:38,889 INFO [ServerInfo] Java version: 1.5.0_16,Sun Microsystems Inc.
08:04:38,889 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_16-b02,Sun Microsystems Inc.
08:04:38,889 INFO [ServerInfo] OS-System: Linux 2.6.22.5-31-default,i386
08:04:39,757 INFO [Server] Core system initialized
08:04:41,776 ERROR [MainDeployer] Could not create deployment: file:/home/reaverbrook/jboss-4.2.3.GA/server/default/conf/jboss-service.xml
org.jboss.deployment.DeploymentException: No ClassLoaders found for: org.jboss.logging.Log4jService; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.logging.Log4jService)
at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:196)
at org.jboss.system.ServiceController.install(ServiceController.java:226)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy4.install(Unknown Source)
at org.jboss.deployment.SARDeployer.create(SARDeployer.java:251)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy5.deploy(Unknown Source)
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
at org.jboss.Main.boot(Main.java:200)
at org.jboss.Main$1.run(Main.java:508)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.logging.Log4jService
at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:1204)
at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:286)
at org.jboss.system.ServiceCreator.install(ServiceCreator.java:193)
at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:451)
at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:171)
... 36 more
Failed to boot JBoss:
org.jboss.deployment.DeploymentException: No ClassLoaders found for: org.jboss.logging.Log4jService; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.logging.Log4jService)
at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:196)
at org.jboss.system.ServiceController.install(ServiceController.java:226)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy4.install(Unknown Source)
at org.jboss.deployment.SARDeployer.create(SARDeployer.java:251)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy5.deploy(Unknown Source)
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
at org.jboss.Main.boot(Main.java:200)
at org.jboss.Main$1.run(Main.java:508)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.logging.Log4jService
at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:1204)
at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:286)
at org.jboss.system.ServiceCreator.install(ServiceCreator.java:193)
at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:451)
at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:171)
... 36 more
08:04:41,803 INFO [Server] Runtime shutdown hook called, forceHalt: true
08:04:41,803 INFO [Server] JBoss SHUTDOWN: Undeploying all packages
08:04:41,857 INFO [Server] Shutdown complete
Shutdown complete
Halting VM
reaverbrook@linux-nsfe:~/jboss-4.2.3.GA/bin>
anonymous wrote : Which version and vendor of Java do you use?
reaverbrook@linux-nsfe:~/jboss-4.2.3.GA/bin> java -version
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing)
Thank you very much, boss!!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4168437#4168437
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4168437
17 years, 8 months