package com;
import javax.ejb.MessageDrivenBean;
import javax.jms.MessageListener;
import javax.jms.Message;
import weblogic.ejb.GenericMessageDrivenBean;
import weblogic.ejbgen.MessageDriven;
@MessageDriven(ejbName = "MyFirsMDB", destinationJndiName = "MyDefaultQueue", destinationType = "javax.jms.Queue")
public class MyFirsMDB extends GenericMessageDrivenBean implements
MessageDrivenBean, MessageListener {
private Long id = System.currentTimeMillis();
public void onMessage(Message msg) {
try {
Thread.sleep(1000);
System.out.println("->" + id.toString() + " :"+ msg.getStringProperty("msg"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
->1239798602084 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602147 :My AA String Message.
->1239798602147 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602084 :My AA String Message.
->1239798602147 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602147 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602147 :My AA String Message.
->1239798602084 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602147 :My AA String Message.
->1239798602084 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602147 :My AA String Message.
->1239798602084 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798795659 :My AA String Message.
->1239798602147 :My AA String Message.
->1239798602147 :My AA String Message.
->1239798795659 :My AA String Message.
->1239798602131 :My AA String Message.
->1239798602084 :My AA String Message.
Next attempt: two MDB on one Destination (queue)
Firs one:
package com;
import javax.ejb.MessageDrivenBean;
import javax.jms.MessageListener;
import javax.jms.Message;
import weblogic.ejb.GenericMessageDrivenBean;
import weblogic.ejbgen.MessageDriven;
@MessageDriven(ejbName = "MyFirsMDB", destinationJndiName = "MyDefaultQueue", destinationType = "javax.jms.Queue")
public class MyFirsMDB extends GenericMessageDrivenBean implements
MessageDrivenBean, MessageListener {
private String id = "A_" + new Long(System.currentTimeMillis()).toString();
public void onMessage(Message msg) {
try {
Thread.sleep(1000);
System.out.println(id +" : "+ msg.getStringProperty("msg"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
Second one:
package com;
import javax.ejb.MessageDrivenBean;
import javax.jms.MessageListener;
import javax.jms.Message;
import weblogic.ejb.GenericMessageDrivenBean;
import weblogic.ejbgen.MessageDriven;
@MessageDriven(ejbName = "MySecondMDB", destinationJndiName = "MyDefaultQueue", destinationType = "javax.jms.Queue")
public class MySecondMDB extends GenericMessageDrivenBean implements
MessageDrivenBean, MessageListener {
private String id = "B_" + new Long(System.currentTimeMillis()).toString();
public void onMessage(Message msg) {
try {
Thread.sleep(1000);
System.out.println(id +" : "+ msg.getStringProperty("msg"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
B_1239799361946 : My AA String Message.
B_1239799361946 : My AA String Message.
B_1239799366712 : My AA String Message.
B_1239799366993 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799366993 : My AA String Message.
B_1239799366712 : My AA String Message.
B_1239799361946 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799366993 : My AA String Message.
B_1239799366712 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799366712 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799366712 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799378290 : My AA String Message.
A_1239799378290 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799383931 : My AA String Message.
A_1239799384197 : My AA String Message.
A_1239799378290 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799378290 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799378290 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799378290 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799384197 : My AA String Message.
B_1239799366712 : My AA String Message.
B_1239799366712 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799366712 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799366712 : My AA String Message.
B_1239799366993 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799361946 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799361946 : My AA String Message.
B_1239799367274 : My AA String Message.
B_1239799366993 : My AA String Message.
B_1239799366993 : My AA String Message.
A_1239799384197 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799378290 : My AA String Message.
A_1239799384197 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799378290 : My AA String Message.
A_1239799384197 : My AA String Message.
A_1239799384197 : My AA String Message.
A_1239799378290 : My AA String Message.
A_1239799377978 : My AA String Message.
A_1239799383931 : My AA String Message.
A_1239799377978 : My AA String Message.