MessageDriven Bean problem.Working but the queues r not getting cleared

I have written a simple message driven bean.It just sends a message to an another queue myadapterqueue
on getting a message .
It is working. But the problem is if I restart my application server then it again reads the messages which had been sent to it earlier.Also the queue size is
not getting to 0 bytes after it has consumed messages.
My application server is JBOSS2.4.3
I think I have to specify some attributes in the
descriptor files.But how??????????????
Here is my code
import java.util.*;
import javax.ejb.*;
import javax.jms.*;
import javax.naming.*;
public class MyMessageBean implements javax.ejb.MessageDrivenBean,javax.jms.MessageListener
     private QueueConnection connect=null;
     private QueueSession session=null;
     private QueueSender sender =null;
private Queue sendQueue=null;
private MessageDrivenContext ctx = null;
     public void setMessageDrivenContext(MessageDrivenContext mdc){
          System.out.println ("In setMessageDrivenContext--------------");
          this.ctx=mdc;
     public void ejbCreate(){
          try{
               System.out.println ("Message bean Created--------------");
               InitialContext jndi=new InitialContext();
               QueueConnectionFactory queueFactory=(QueueConnectionFactory) jndi.lookup("ConnectionFactory");
               connect=queueFactory.createQueueConnection();
               session=connect.createQueueSession (true,Session.AUTO_ACKNOWLEDGE);
               System.out.println ("After session creation--------------");
               sendQueue=(Queue)jndi.lookup("queue/myadapterqueue");
               System.out.println("************ queue/myadapterqueue");
          sender=session.createSender (sendQueue);
          System.out.println ("Before Connection start--------------");
          connect.start();
          }catch(javax.jms.JMSException jmse){
               System.out.println ("In ejbcreate exception-------------------");
               throw new javax.ejb.EJBException();
          }catch(javax.naming.NamingException jne){
               System.out.println ("In ejbcreate exception-------------------");
               throw new javax.ejb.EJBException();
     public void ejbRemove(){
          try{
          System.out.println("ejbRemove done");
          connect.close ();
               this.ctx=null;
          }catch (javax.jms.JMSException jmse){
               System.out.println ("In ejbremove exception-------------------");
               System.out.println("ejbRemove excetion");
               throw new javax.ejb.EJBException();
     public void onMessage(Message msg){
          try{
          this.sender.send (msg);
          this.session.commit();
          System.out.println(" Message");
     }catch(javax.jms.JMSException jmse ){
          jmse.printStackTrace();
here are my descriptors
ejb-jar.xml
<?xml version="1.0"?>
<!DOCTYPE ejb-jar>
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>MyMessageBean</ejb-name>
<ejb-class>MyMessageBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
</message-driven>
</enterprise-beans>
</ejb-jar>
and the correspong xml file for the application server here is jboss.xml
?xml version="1.0" encoding="UTF-8"?>
<jboss>
<enterprise-beans>
     <message-driven>
          <ejb-name>MyMessageBean</ejb-name>
          <configuration-name>Standard Message Driven Bean</configuration-name>
          <destination-jndi-name>queue/MyMessageBeanQ</destination-jndi-name>
     </message-driven>
</enterprise-beans>
</jboss>

it is unclear whether you are commiting on the first queue or second one.
but it appears like you have created a transactional problem across the two queues. although you commit on the first queue, this commit is not extended to the second queue.
things will be fine unless you get an exception of shutdown.
if you shut your message provider down first then you cannot send the message to the second queue. (assuming that queue 2 is also on the same server)
if you shut your MB app server down then you may be in the middle of accepting a onMessage callback from the first queue.
do you have another MB that registers this one as a listener, or are you infact sending a message back onto the same queue...
public void onMessage(Message msg){
try{
     this.sender.send (msg);
     //your server may shutdown here and leave messages on the first queue. and send extra messages on the second.
        this.session.commit();
        System.out.println(" Message");
} catch(javax.jms.JMSException jmse ){
        jmse.printStackTrace();
}

Similar Messages

  • Hi, I m using an iPhone 4 and my yahoo push email was working just fine but for the last few days I am experiencing some problem that is the emails are not getting pushed , I have to manually fetch the mails. So what could be the reason for this....

    Hi, I m using an iPhone 4 and my yahoo push email was working just fine but for the last few days I am experiencing some problem that is the emails are not getting pushed , I have to manually fetch the mails. So what could be the reason for this.....I have set the email setting to "push" mode. Moreover I can't edit the mail server address ....current it's on Yahoo SMTP server

    Will it get rectified and restored...if so after how long. What could be the reason for such outage kindly share,  as I am facing real problem because of this...

  • I dropped my phone in a toilet, the sound and vibrate are working but the screen will not turn on, what should I do?

    I dropped my phone in a toilet, the sound and vibrate are working but the screen will not turn on, what should I do? do I just need a new screen or what? I'm freaking out here

    Don't freak out, just get over it. It's probably done.
    What should I do if I drop my phone in the toilet?
    Apple may offer you an refurbished iPhone in exchange for yours, for about half the cost of a new one.
    I wouldn't be too specific about just how it got wet

  • I replaced the screen of my ipod touch 4 gen the screen is working but the touch is not working what do you think that i break please help

    i just replaced the screen of my ipod touch 4 gen and is working but the touch is not working i took it to a placed call you break it i fix it they told that is was a part that they cant change is a board or something like please help me cant i found that part or is another part like the ribbon cable ?

    Apple really does not repair your iPod except for battery replacments.They exchange your iPod for a refurbished on of the same model. For a 4G, the price is $99, $149, or $199 depending upon the capacity.
    Apple - Support - iPod - Repair pricing
    A third-party place like the following may be less expensive. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
    Regarding why, we are only users in this forum.  You are not addressing Apple here.

  • HT2736 I have purchased a gift certificate but the person did not get it

    I sent  GIFT CERTIFICATE, BUT THE PERSON DID NOT GET IT. HOW DO I TRACE IF IT WAS SENT AND I WAS CHARGED?

    When I send them they arrive in seconds.
    Ask the recipient to check Mail rules and filtering, the verification mail may be going to a junk folder or even being deleted altogether.
    Also see if you are able to resend the email by following these steps.
    If the problem persists, select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History using your computer.

  • I have created my apple id.Now when I m downloading any app it is asking my credit card details again forget that I hv made multiple payments while trying to download the app but the app is not getting downloaded.It is sowing the msg cant connect to itune

    I have created my apple Id.Now when i m downloading any app it is asking my credit card details.I have made multiple payments while trying to download the app.But the app is not getting downloaded,it is showing the message cannot connect to the i tune store.What should i do to download the applications.

    Ok, first of all don't keep purchasing the application, and if you've purchased it multiple times, contact iTunes billing department immediately.  They SHOULD only send one actual confirmation in and the rest of the "pending" charges will drop off (how long that takes is up to your credit card company, not iTunes), but you should be sure.
    Second, sometimes when they are uploading a lot of new stuff at certain times it can cause the store to screw up, or any number of other reasons could be a factor why you can't connect to the iTunes store, be it on their end or on your end even.  Wait a little bit and try again via "Check for available downloads" or via your "Purchased" option on the iTunes store main page.
    IF the app you purchased isn't there and you are sure your credit card was charged, then you will need to contact iTunes to find out why you can't download the app.

  • What should I do if I spill liquid on my macbook? The machine is working, but the keyboard is not.

    My grandmother spilled coffee on the trackpad and it reached the first row of keys. The power didn't go out, but the keyboard is not working. Any suggestions?

    Spill Cleaning
    Some liquid has just spilled into your Mac. What should you do?
    Do
    Immediately shut down the computer and unplug the power cord.
    Remove the computer's battery (if you can)
    Disconnect any peripherals (printers, iPods, scanners, cameras, etc.)
    Lay the computer upside down on paper towels to get as much liquid as possible to drip out.
    Note what was spilled on your Mac.
    Bring the computer into an Apple store or AASP as soon as possible.
    Don't
    Don't try to turn it back on. Liquids can help electrical current move about the components of your Mac in destructive ways.
    Don't shake the computer (this will only spread the liquid around).
    Don't use a hair dryer on it (even at a low setting a hair dryer will damage sensitive components).

  • Laptop works BUT the screen will not turn on

    I have a Macbook Pro 15'' intel from 2007. Two days ago I closed the top and when I re-opened it a minute or two later the screen was black. Thinking it was just asleep I mashed on the keys - nothing. Yesterday I feared it was a issue with the computer. Thankfully though I have successfully log in (blindly) and was able to use a hot key to open iTunes and start playing music, proving that the computer itself was alright, but the screen was busted.
    Does anybody have an idea of what I can do to get the screen back on? Could it possible be a problem with the activation switch that turns the moniter on and off? (is this problem covered in my Apple Care warrenty?)

    Hi Hank,
    Does the NVIDIA issue sound about right?

  • Build exe is working but the program is not

    i have build an exe, everything went fine. I opened the exe and want to start the program via "Übernehmen". Then I get the attached error message. It's an old Labview Version (2009) which I converted in 2014. Do I miss sth I should add to get a successfull program via exe?
    Solved!
    Go to Solution.
    Attachments:
    items.png ‏28 KB
    items.png ‏28 KB
    buildexe.png ‏74 KB

    Sam_Sharp wrote:
    Does the application run fine in the development environment?
    Does the old version of the application work on the same PC?
    What happens when you run the .exe - does anything come up on the screen? Do you get any error messages?
    I don't speak german so I don't understand the message that appears - but it seems to be saying something related to the 'program not installed'? Was there previously an installer that did custom actions (e.g. running other installers or putting files/registry keys in certain locations)?
    1. yes, it is running fine in the development environment. There are no errors when I start the main.vi. I can open the program and work with it etc.
    2. yes, the old version is working. It's 2009, I installed 2009 Runtime and I can open the .exe and work with it.
    3. concerning 2009 .exe see my answer at 2. When I start .exe which is converted AND build in 2014, the first screen is working. Then I press the "Übernehmen" Button and I got the attached error. Yes, it says "the program is not working".
    I don't know if there were custom actions. I got this project from a former colleague... :/

  • HT201302 my pictures and videos are not in camera roll.  The camera works but the pictures on not on camera roll.

    My Iphone takes pictures and video but then they do not show up on the camera roll.  It says there are no pictures or video.  How can I fix this problem.  I have tried reset and synching.
    Thanks

    Rozbrin wrote:
    My Iphone takes pictures and video but then they do not show up on the camera roll...
    If your pictures and video are not on the camera roll, I do not think your iPhone is taking pictures and video.
    You have already tried resetting and restarting your device.   Next, check whether your camera has been disabled in Settings > General > Restrictions > Camera.  If not, ask your Apple Authorized Service provider to check your device or contact Apple Support for help: http://www.apple.com/support/iphone/contact/
    Message was edited by: EZ Jim
    Mac OSX 10.7.4

  • Backlight Works But the display is not

    I recently changed my logic board with a used due to a hardware problem.After the installation the MB works fine except that my display is not working (the backlight is working. I connect to an external Display and it works fine. Please Help!!!!i Double check the data cable for screen. Is there anyway to check my hardware for a problem. Unfortunately here in Greece the support is not so very quick and it is very expensive

    You might want to try your homeowner's insurance or see if your credit card offers some protection (that is if you used one to buy it).

  • Itunes comes up an the store works but the library does not

    tried to update itunes that failed,, have uninstalled an reinstalled,, itunes wont come up,, when i use a restore point to go to an older version itunes comes up,, but,,, the store works,, when i try to go to my library it is stuck on my movies,, if i try to change to something else it shuts down,, i searxh my music on the toolbar but when i click on my music itunesshuts down,, afraid to plug my phone into it so not sure how that will work
    am running windows 7
    latest version of itunes untill this last update an everythin went to heck
    also when tried to reinstall it tells me moblile device not found,, so ihave to ignore that to install...

    Gave it a look, tried all the troubleshooting. My IP addresses are the same, so now I really don't understand. I'm just super confused. If it hadn't ever worked, I would just write it off as my university network being too strict... but now that it has worked once and really... nothing changed... I am just very confused.

  • HT4864 I use Outlook 2011 for Mac. My @me works but the @ mac does not.

    I use Outlook 2011 for Mac on a 2011 MacBook Pro. My @me mail works but my @mac mail does not.

    I'm not familiar with your Bose but perhaps the phone is muting the music so you can hear the call.

  • Why are my email attachments showing as being attached but the recipient does not get an attachment?

    I currently use the Mail program on my MacBook Pro and am having issues with email attachments. I have read through a few forums and I seem to be doing everything correctly but I am still having problems. I have 3 different email accounts that I have set up through Mail and all 3 are having problems. The steps I take when attaching any document is to compose to a new email, click the paperclip icon or go through the File drop down menu and select Attach Files. With either option, I can see my document inside of my message but when I send the email the recipient only receives the text portion of th email, not any attachment. When I go to my Sent mailbox and find the email I sent, I can see the document within the message but there is not a paperclip icon next to the recipients name indicating that there was an attachment sent.
    I have made sure that 'Always send windows-friendly attachments' is selected, and I have tried sending them with 'Always attach at end of message' selected and with it unselected but there has been no difference. I have only noticed this within the last 2 months. Anyone have any advice?

    The issue with not seeing the paper clip in your Sent mailbox seems to be totally removed from anything related to recipients, and is something to perhaps yet be addresses in a future update.
    To the issue with recipients, I would guess the recipient is using Outlook or Outlook Express, and the message is being sent in Rich Text (a form of HTML) and the recipient either cannot open the attachment, or they have an over zealous anti-virus filter that is removing the attachment out of fear caused by the presence of HTML.
    More info about the recipient's platform, please.
    Ernie

  • I have been dealing with crashing and freezing issues on my iMac for 6 months.  A supervisor has been assisting me but the issue is not getting fixed.  The computer was under when the issues started.  He wants to get us a new computer but is not allowed.

    Our iMac was under warranty when it began freezing and or crashing.  I have spent several hours on the phone with a supervisor and had the machine in 2x.  We have also had a repair done in our home.  The problems persist.  We feel apple owes us a new computer.   Help!!!

    Do you have a written record of your attempts to get it repaired?  When you took the machine "in" for repairs, did you take it to an Apple Store or to an Apple Authorized Reseller or Repair Facility, and do you have copies of invoices or statements showing what repairs were made?  If the answers are yes, you need to be persistent in attempting to get a new computer.  Ask to talk to the supervisor's supervisor to "escalate" the complaint to a higher level.  Get copies of all your repair information and send a letter to the Apple Customer Service people in California and ask them for help.
    If your iMac was under warranty when the problems started and the problems have not been resolved, your position should be that the problems should still be fixed or the computer replaced even though the warranty may have expired in the interim.  Do you live in the US?  If yes, your home state has a Consumer Protection agency.  File a complaint with them and ask for their assistance in mediating and/or resolving the matter.

Maybe you are looking for