I have 2 EJB app, A and B. A has a stateless session that send a message to app B (Message driven bean). App B send a message back to app A.
Now, I have the value I want in the message listener in the stateless session bean in A. But I need to show it from Main. I tried declaring a variable and store the value in it. But when I call it from Main, the value is lost.
@Stateful
public class AManagerBean implements ejb.AManagerRemote {
@Resource(mappedName = "jms/QueueConnectionFactory")
private ConnectionFactory queueConnectionFactory;
@Resource(mappedName = "jms/Queue")
private Queue queue;
private static int fineAmt;
......
static class AListener implements MessageListener{
public void onMessage(Message message){
.....
fineAmt = msg.getInt("fineAmt");
// I NEED FINEAMT TO SHOW IN MAIN CLASS
.....
}
}
public int returnFine(){
return fineAmt;
}
In the main class...
public class Main {
@EJB
public static AManagerRemote amr;
public static void main(String[] args) {
......
System.out.println(amr.returnFine());
// ALWAYS RETURN 0
I need fineamt to show in main class. But it always return null.
How should I do it?
onMessage
is invoked? – Mercie