MDB cannot loads enitities if more than 10 concurrent messages are sent tog

Hello,
I have seen a weird behavior of the MDB in Jboss or perhaps in transaction management.
Here is a my scenario
I have a session bean sb, an entity bean e and a message driven bean mb
When a request comes to sb , it persists a new entity e and send a message (primary key) to mb
mb then loads e from the database using one of the findByXX method and does something else.
If 10 concurrent request comes to sb, 10 different entities are persisted and 10 different messages are sent to mb
mb are able to load 10 different e from the database
Everything works fine as long as there are 10 concurrent request. If there are 13 concurrent request, then one or two mb
cannot load e from the database. It seems that the session bean has persisted the entities but some of them are still unload able from mb. They have been persisted , (I saw in the logs), but mb cannot load them.
Initially I thought that a transaction mishap might be happening, so instead of persisting the entity and sending the message in one method in sb , I separated these two tasks in two methods a and b, in which both a and b uses RequiresNew transaction attribute. But the problem still remains. Please note if the number of parallel request are less than 10 then everything works fine. Is there something I am missing or is Jboss doing something buggy?
The above situation is reproducible .
Here is some more information about the problem along with some code snapshots. Note that the code is trimmed for clarity purposes.
Request is a simple entity (e as mentioned in the problem before) that is persisted in session bean . Here is a trimmed snapshot
Request.java
package gov.fnal.ms.dm.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
@Entity
@NamedQueries({@NamedQuery(name = "Request.findById", query = "SELECT r FROM Request r WHERE r.id = :id"),
@NamedQuery(name = "Request.findAll", query = "SELECT r FROM Request r"),
@Table(name = "cms_dbs_migration.Request")
@SequenceGenerator(name="seq", sequenceName="cms_dbs_migration.SEQ_REQUEST")
public class Request implements Serializable {
private String detail;
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator="seq")
@Column(nullable = false)
private Long id;
private String notify;
.....The session bean is MSSessionEJBBean.
MSSessionEJBBean.java
@Stateless(name="MSSessionEJB")
@WebService(endpointInterface = "gov.fnal.ms.dm.session.MSSessionEJBWS")
public class MSSessionEJBBean implements MSSessionEJB, MSSessionEJBLocal, MSSessionEJBWS {
@PersistenceContext(unitName="dm")
private EntityManager em;
.......    The methods that is called concurrently in this bean is
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Request addRequest(String srcUrl, String dstUrl, String path,
String dn, String withParents, String withForce, String notify) throws
Exception {
Request r = addRequestUnit(srcUrl, dstUrl, path, dn, withParents, withForce, notify);
if (r != null) sendToQueue(r.getId());
return r;
}    It first adds the request entity and then sends a message to the queue in separate methods each using TransactionAttributeType.REQUIRES_NEW (I don't think this TransactionAttributeType is needed . I was just playing to see if this resolves the problem)
Here is the method that actually persist the entity
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Request addRequestUnit(String srcUrl, String dstUrl, String path,
String dn, String withParents, String withForce, String notify) throws
Exception {
....// Does something before persisting
Request r = new Request();
r.setNotify(notify);
r.setPath(path);
r.setPerson(p);
r.setWithForce(withForce);
r.setWithParents(withParents);
r.setProgress(new Integer(0));
r.setStatus("Queued");
r.setDetail("Waiting to be Picked up");
em.persist(r);
System.out.println("Request Entity persisted");
System.out.println("ID is " + r.getId());
return r;
}I can see that the log files has messages
*{color:#800000}"Request Entity persisted" "ID is " 12 (or some other number){color}*
. So it is safe to assume that the request entity is persisted properly before the message is sent to the queue. Here is how the message is sent to the queue
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private void sendToQueue(long rId) throws Exception {
QueueSession session = null;
QueueConnection conn = null;
try {
conn = factory.createQueueConnection();
session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
MapMessage mapMsg = session.createMapMessage();
mapMsg.setLong("request", rId);
session.createSender(queueRequest).send(mapMsg);
} finally {
if (session != null) session.close();
if(conn != null) try {
conn.close();
}catch(Exception e) {e.printStackTrace();}
System.out.println("Message sent to queue");
}I can see the message
{color:#800000}*"Message sent to queue"*{color}
in the log file right after I see the
*{color:#800000}
"Request Entity persisted"{color}*
message. So it correct to assume that the message is infact sent to the queue.
Here is the md bean that gets the message from the queue and process it
@MessageDriven(activationConfig =
@ActivationConfigProperty(propertyName="destinationType",
propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination",
propertyValue="queue/requestmdb")
public class RequestMessageDrivenBean implements MessageListener {
@EJB
private MSSessionEJBLocal ejbObj;
public void onMessage(Message message) {
try{
System.out.println("Message recived ");
if(message instanceof MapMessage) {
System.out.println("This is a instance of MapMessage");
MapMessage mMsg = (MapMessage) message;
long rId = mMsg.getLong("request");
List<Request> rList = ejbObj.getRequestById(new Long(rId));
System.out.println("rList size is " +  rList.size());
for(Request r: rList) {
//Does something and print something in logs
System.out.println("Finsihed onMessage");
}catch(Exception e) {
System.out.println(e.getMessage());
}    One thing to note here is that getRequestById is another method in the same session bean MSSessionEJB. Can that be the reason for not loading the request from the database when many concurrent request are present? Here is what it does
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public List<Request> getRequestById(Long id) throws Exception {
System.out.println("Inside getRequestById id is " + id);
return em.createNamedQuery("Request.findById")
.setParameter("id", id)
.getResultList();
}    In the logs I do see
{color:#800000}*"This is a instance of MapMessage"*{color}
and I do see the correct Rid that was persisted before in the log
*{color:#800000}
"inside getRequestById id is 12"{color}*
. Finally I do see
*{color:#800000}
"Finsihed onMessage"{color}*
for all the request no matter how many are sent concurrently.
*{color:#ff0000}Here is where the problem is . rList size is 1 for most of the cases but it returns 0 when the number of concurrent message exceeds 10.*
*{color}*
So you see there is no exception per se, just that entity does not get loaded from the database. I would like to mention this again, it does work properly when the number of concurrent request are less than 10. All the invocation of onMessage in MB are able to load the entity properly in that case. Its only when the number of concurrent request increases more than 10, the onMessage is unable to load the entity and the rList is 0.
FYI I am using jboss-4.2.2.GA on RedHat enterprise linux 4 with jdk1.6.0_04
Please let me know if there is more information required on this.
Thank you

Hello,
I have seen a weird behavior of the MDB in Jboss or perhaps in transaction management.
Here is a my scenario
I have a session bean sb, an entity bean e and a message driven bean mb
When a request comes to sb , it persists a new entity e and send a message (primary key) to mb
mb then loads e from the database using one of the findByXX method and does something else.
If 10 concurrent request comes to sb, 10 different entities are persisted and 10 different messages are sent to mb
mb are able to load 10 different e from the database
Everything works fine as long as there are 10 concurrent request. If there are 13 concurrent request, then one or two mb
cannot load e from the database. It seems that the session bean has persisted the entities but some of them are still unload able from mb. They have been persisted , (I saw in the logs), but mb cannot load them.
Initially I thought that a transaction mishap might be happening, so instead of persisting the entity and sending the message in one method in sb , I separated these two tasks in two methods a and b, in which both a and b uses RequiresNew transaction attribute. But the problem still remains. Please note if the number of parallel request are less than 10 then everything works fine. Is there something I am missing or is Jboss doing something buggy?
The above situation is reproducible .
Here is some more information about the problem along with some code snapshots. Note that the code is trimmed for clarity purposes.
Request is a simple entity (e as mentioned in the problem before) that is persisted in session bean . Here is a trimmed snapshot
Request.java
package gov.fnal.ms.dm.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
@Entity
@NamedQueries({@NamedQuery(name = "Request.findById", query = "SELECT r FROM Request r WHERE r.id = :id"),
@NamedQuery(name = "Request.findAll", query = "SELECT r FROM Request r"),
@Table(name = "cms_dbs_migration.Request")
@SequenceGenerator(name="seq", sequenceName="cms_dbs_migration.SEQ_REQUEST")
public class Request implements Serializable {
private String detail;
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator="seq")
@Column(nullable = false)
private Long id;
private String notify;
.....The session bean is MSSessionEJBBean.
MSSessionEJBBean.java
@Stateless(name="MSSessionEJB")
@WebService(endpointInterface = "gov.fnal.ms.dm.session.MSSessionEJBWS")
public class MSSessionEJBBean implements MSSessionEJB, MSSessionEJBLocal, MSSessionEJBWS {
@PersistenceContext(unitName="dm")
private EntityManager em;
.......    The methods that is called concurrently in this bean is
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Request addRequest(String srcUrl, String dstUrl, String path,
String dn, String withParents, String withForce, String notify) throws
Exception {
Request r = addRequestUnit(srcUrl, dstUrl, path, dn, withParents, withForce, notify);
if (r != null) sendToQueue(r.getId());
return r;
}    It first adds the request entity and then sends a message to the queue in separate methods each using TransactionAttributeType.REQUIRES_NEW (I don't think this TransactionAttributeType is needed . I was just playing to see if this resolves the problem)
Here is the method that actually persist the entity
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Request addRequestUnit(String srcUrl, String dstUrl, String path,
String dn, String withParents, String withForce, String notify) throws
Exception {
....// Does something before persisting
Request r = new Request();
r.setNotify(notify);
r.setPath(path);
r.setPerson(p);
r.setWithForce(withForce);
r.setWithParents(withParents);
r.setProgress(new Integer(0));
r.setStatus("Queued");
r.setDetail("Waiting to be Picked up");
em.persist(r);
System.out.println("Request Entity persisted");
System.out.println("ID is " + r.getId());
return r;
}I can see that the log files has messages
*{color:#800000}"Request Entity persisted" "ID is " 12 (or some other number){color}*
. So it is safe to assume that the request entity is persisted properly before the message is sent to the queue. Here is how the message is sent to the queue
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private void sendToQueue(long rId) throws Exception {
QueueSession session = null;
QueueConnection conn = null;
try {
conn = factory.createQueueConnection();
session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
MapMessage mapMsg = session.createMapMessage();
mapMsg.setLong("request", rId);
session.createSender(queueRequest).send(mapMsg);
} finally {
if (session != null) session.close();
if(conn != null) try {
conn.close();
}catch(Exception e) {e.printStackTrace();}
System.out.println("Message sent to queue");
}I can see the message
{color:#800000}*"Message sent to queue"*{color}
in the log file right after I see the
*{color:#800000}
"Request Entity persisted"{color}*
message. So it correct to assume that the message is infact sent to the queue.
Here is the md bean that gets the message from the queue and process it
@MessageDriven(activationConfig =
@ActivationConfigProperty(propertyName="destinationType",
propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination",
propertyValue="queue/requestmdb")
public class RequestMessageDrivenBean implements MessageListener {
@EJB
private MSSessionEJBLocal ejbObj;
public void onMessage(Message message) {
try{
System.out.println("Message recived ");
if(message instanceof MapMessage) {
System.out.println("This is a instance of MapMessage");
MapMessage mMsg = (MapMessage) message;
long rId = mMsg.getLong("request");
List<Request> rList = ejbObj.getRequestById(new Long(rId));
System.out.println("rList size is " +  rList.size());
for(Request r: rList) {
//Does something and print something in logs
System.out.println("Finsihed onMessage");
}catch(Exception e) {
System.out.println(e.getMessage());
}    One thing to note here is that getRequestById is another method in the same session bean MSSessionEJB. Can that be the reason for not loading the request from the database when many concurrent request are present? Here is what it does
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public List<Request> getRequestById(Long id) throws Exception {
System.out.println("Inside getRequestById id is " + id);
return em.createNamedQuery("Request.findById")
.setParameter("id", id)
.getResultList();
}    In the logs I do see
{color:#800000}*"This is a instance of MapMessage"*{color}
and I do see the correct Rid that was persisted before in the log
*{color:#800000}
"inside getRequestById id is 12"{color}*
. Finally I do see
*{color:#800000}
"Finsihed onMessage"{color}*
for all the request no matter how many are sent concurrently.
*{color:#ff0000}Here is where the problem is . rList size is 1 for most of the cases but it returns 0 when the number of concurrent message exceeds 10.*
*{color}*
So you see there is no exception per se, just that entity does not get loaded from the database. I would like to mention this again, it does work properly when the number of concurrent request are less than 10. All the invocation of onMessage in MB are able to load the entity properly in that case. Its only when the number of concurrent request increases more than 10, the onMessage is unable to load the entity and the rList is 0.
FYI I am using jboss-4.2.2.GA on RedHat enterprise linux 4 with jdk1.6.0_04
Please let me know if there is more information required on this.
Thank you

Similar Messages

  • How to load and unload more than one external swf files in different frames?

    I do not have much experience on Adobe Flash or Action Script 3, but I know the basics.
    I am Arabic language teacher, and I design an application to teach Arabic, I just would like to learn how to load and unload more than one external swf files in different frames.
    Thanks

    Look into using the Loader class to load the swf files.  If you want to have it happen in different frames then you can put the code into the different frames.

  • HT6114 I cannot select more than one message at a time to delete from the trash. Any ideas will be appreciated

    I cannot select more than one message at a time to delete from the trash. I did not have this problem before I updated to Maverick. What am I doing wrong?

    This works in many different ways and in lots of apps.
    Hold down the command key and you can select from a list (leaving some not checked) to exclude them from the delete process.
    To empty all of the trash folder use command-a keys to "select all" and then the delete key to remove them.

  • I cannot sit outside for more than 45 minutes without my ipad shutting down due to heat. is there a way to fix this?

    i cannot sit outside for more than 45 minutes without my ipad shutting down due to heat. is there a way to fix this?

    What model iPad? What is the outside temperature?
    When outside what are you doing on the iPad - running a graphic intensive app?
    iPad operating ambient temperature: 0° to 35° C (32° to 95° F)
     Cheers, Tom

  • Cannot open firefox in more than one window

    I cannot open Firefox in more than one window. I deleted and reinstalled the latest version but this did not help. I was able to open Firefox in multiple windows prior to installing an update of Avast. Don't think it should have an effect on Firefox.
    Downloaded Seamonkey and have no problem with multiple windows.

    Anyone?

  • Cannot Add Invoices with more than one costing centers by SDK.

    Have no available DI Interface to access cost/profit center
    Cannot Add Invoices with more than one costing centers by SDK.

    Dear Srikanth,
    Thanks a lot for your reply.
    We want add a invoice with DI API, but the DI API provide only one costing center: CostingCode in Document_Lines Object. But we have two costing centers, one is department, the other is salesperson.
    This is my question.
    It will be appreciated highly if you give me a solution.
    Thanks!
    Xingjun Han

  • Is there any way to have more than 200 messages in your inbox?

    My iPhone 3gs only allows 200 messages in my inbox per email account. On the contrary, my girlfriends blackberry will hold 1500+ emails.
    Does anyone know how to change the settings to allow more messages to be kept in the inbox or if the new iPhone 4 will allow more messages to be kept in the inbox?
    Thanks for the help!

    What you see in regards to the Show Recent Messages settings is the only thing available.
    If a mailbox has more than 200 messages and you want to view more than the 200 most recent messages in the mailbox, there is a load more messages selection at the bottom of the mailbox or below the 200th most recent message.
    Don't know if iOS4 will have different options available for the show most recent messages setting for a mailbox. iOS4 for existing 3G and 3GS iPhone will be released on 6/21. iPhone 4 will have iOS4 pre-installed.

  • More than one text area on a slide master... how?

    Is it possible to define more than one text area on a master slide? If so how?
    I want to have a layout with two columns of text - a fairly common layout in presentation packs - but can't persuade Keynote to accept this as a layout for a template. I realise that there can only be one 'body' area, but any attempt to produce a 'fake' second body area fails - whether I put in a text box or a shape with text in.
    If I put it in as a text box, I can't put a limit on how big the box is.
    If I put it in as a shape with text in, when I try to enable the shape as a text placeholder, it forces the whole text in box to have same format as 'top level' outline.
    Any ideas?

    If you want two columns of text, why not set up the Body textbox with two columns? Select the Body textbox on the slide master, then in the Text Inspector, in the Columns tab, set however many columns you want.

  • After soak test update, I get error messages repeatedly. The majority are "unfortunately, messaging has stopped", but you can replace messaging with "android os", or any other process, as it happens with more than just messaging. I have had numerous peopl

    After soak test update, I get error messages repeatedly. The majority are "unfortunately, messaging has stopped", but you can replace messaging with "android os", or any other process, as it happens with more than just messaging. I have had numerous people call and ask why I didn't reply to their texts...and I look, but have not received any new texts. YES, I have restarted phone. I have cleared data as well as cache on all apps. I have downloaded the vzw messaging app, which seems silly, since it happens with several different processes and apps, but all to no avail. I am missing texts from my employer, from my family. This did happen, but rarely, before this "soak test". It is now Kitkat version 19.6.3.obake_verizon.en.US. THIS is when I started having problems...like 50 times a day kind of problems! I have seen hundreds of posts all over the internet over the past 3 days. Does no one know how to fix this??? Shouldn't there be a way to revert phone to a pre-update state? and no, hard reset did NOT work!!!! I have been with verizon for well over 15 years, but I have not upgraded my lines and will not in July either. This is ridiculous. It's not like my games aren't working, it is my messaging and "android os"...my lifeline at work!

    kristinaf333,
    Oh no, I am sorry to hear your messages are not working since the software update. I greatlly appreciate doing all that troubleshooting to try and get the messaging application back in business. I know how much I rely on my messages so I can understand the urgency to get this resolved. Have you had a resolution ticket opened since you started experiencing issues with your messages? Does this happen with all contacts or just some? Please provide additional information to ensure we get to the bottom of this for you.
    KarenC_VZW
    Follow us on Twitter @VZWSupport

  • Can I delete more than one message at a time

    Is it possible s to delete more than one message at a time and can I stop it putting them back on my phone once deleted??
    any help would be appreciated.
    thanks
    allisongs

    This question was answered here I think:
    https://discussions.apple.com/message/6799512#6799512

  • How do I select more than one message at a time for archiving

    I want to archive multiple messages into one archive folder. How do I select more than one message at a time?

    Really appreciate the help. Many thanks

  • How do I download more than 4 messages at a time?

    how do I download more than 4 messages at a time?

    In all probability you need to disable email scanning in your anti virus program.

  • How to handle more than one message coming from an async BPEL in a sync BPEL process?

    Here is the scenario,
    Sync process A is calling an Async process B and Async process B  is developed in such a way that it is returning more than one message to sync process A, how you will handle those messages in sync process A?

    As durga said, its a wrong design, you will have issues in real time. You wont get the response back most of the time. It can be otherway around, async is waiting for sync process.
    Change your design or provide what is your use case below, we can think of which design suits you.
    Thanks,
    Vijay

  • Using more than one Business area in the same report

    Hi,
    Is it possible / recommended to use more than one business area in the same report.
    For example, I have a sales (business area sales) report on one tab and a rebates(rebates business area) report on a second tab.
    Thanks

    Hello
    Possible: yes
    Recommended: no
    This can certainly be done and Discoverer will not prevent you from having reports that use different business areas as you describe.
    However, for management and security purposes it does not make for ease of use. As you know a user has the ability to share a workbook with another user. If they do this then ALL reports within that workbook are shared. If the receiving user does not have access to one or more of the business areas then some reports will run and some will not. This can be very confusing to an end user and a possible nightmare to administer.
    My recommendation would be to have a workbook per business area and not mix.
    If there is more than one business area per functional area, for example sales and returns, then so long as the users have access to both business areas then you could use a common workbook.
    Personally I would not even do this, so my strongest advice would be to have all reports in a workbook written against the same business area.
    Hope this helps
    Michael

  • I cant update ios7 to apple tv it load for a time than a message that it is not completed

    i cant update ios7 to apple tv it load for a time than a message that it is not completed

    Welcome to the Apple Community.
    If your problem persists get yourself a micro USB cable (sold separately), you can restore your Apple TV from iTunes:
    Remove ALL cables from Apple TV. (if you don't you will not see Apple TV in the iTunes Source list)
    Connect the micro USB cable to the Apple TV and to your computer.
    Reconnect the power cable (only for Apple TV 3)
    Open iTunes.
    Select your Apple TV in the Devices list, and then click Restore.
    (You may already have a micro USB cable if you have a camera or other digital device)

Maybe you are looking for