Multhreading in Java

Posted by Vijay Selvaraj on Stack Overflow See other posts from Stack Overflow or by Vijay Selvaraj
Published on 2010-05-11T10:54:23Z Indexed on 2010/05/11 11:54 UTC
Read the original article Hit count: 366

Filed under:
|
|

I'm working with core java and IBM Websphere MQ 6.0. We have a standalone module say DBcomponent that hits the database and fetches a resultset based on the runtime query. The query is passed to the application via MQ messaging medium. We have a trigger configured for the queue which invokes the DBComponent whenever a message is available in the queue. The DBComponent consumes the message, constructs the query and returns the resultset to another queue. In this overall process we use log4j to log statements on a log file for auditing.

The connection is pooled to the database using Apache pool. I am trying to check whether the log messages are logged correctly using a sample program. The program places the input message to the queue and checks for the logs in the log file. Its expected for the trigger method invocation to complete before i try to check for the message in log file, but every time my program to check for log message gets executed first leading my check to failure.

Even if i introduce a Thread.sleep(time) doesn't solves the case. How can i make it to keep my method execution waiting until the trigger operation completes?

Any suggestion will be helpful.

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading