NewGlobalRef on a Queue object

Hi,
I have a multi-threaded application. On the Java side I have a thread that creates a Queue object and then periodically pulls an item from the queue, processes the item, and removes the item from the queue.
Over in the C side, I use JNI to set up a Global Reference to the Queue and then over time, add items to the queue. When I am all done I call the DeleteGlobalReference on the queue object.
This works fine when I have a small amount of data to work on. However when I have a lot of data, JVM crashes with an out of memory error. I suspect that items aren't really being removed from the queue.
The question here then is If I use JNI to setup a Global Reference on a Queue or Container, do the items of the container actually get deleted during the lifetime of the container, or are they only deleted when I call the DeleteGlobalReference?
I posted a similar question in the Java Programming forum and then later saw this forum, so my apologies for posting a similar question in two places.
Thanks
David

Seems like your object isn't being garbage collected. Try to test your code on a small set of data and then test it on a large set of data and see the difference between memory usage. (You can get that by calling Runtime.totalMemory()-Runtime.freeMemory() ). You should also call Runtime.gc() periodically while you are testing.
Garbage collector works in this way: Everytime you have a reference to an object, i.e., declare a local variable to point to the object, add the object to a Container (Hashtable, Vector, etc), the reference count for that object increases by one. When the local variable goes out of scope or the object is removed from the container, the reference count is decreased by one. If the reference count for that object is 0, then that object can be safely garbage collected.
When you call NewGlobalRef on the object to be put on the Queue, you must also call RemoveGlobalRef after you are done (not with the object, but with the reference you have just created). So, make sure that if you execute NewGlobalRef on the object 3 times, you must also execute RemoveGlobalRef 3 times. Else it'll never be garbage collected.
There is another reason why it may not be garbage collected: circular reference. Typically, a circular reference do not happen in Java, and when it does, Java is smart enough to know and garbage collect correctly. However, in your JNI code, you may have unknowingly created a circular reference which Java garbage collector do not know about. i.e, you have ObjectA containing a reference to ObjectB, and ObjectB also contain a reference to ObjectA. Then the reference count for either object will never be 0.
Good luck

Similar Messages

  • Queue object not in JAVA apis

    Hi,
    I just want to know if anybody know if the "queue" object is found within Java.. If you don'T know what is a queue, it's like a stack, but instead of begin Last In first out, it's First in First Out.
    If it doesn't exist, does anybody have it already code, it would just speed things a bit.

    Hi,
    I just want to know if anybody know if the "queue"
    e" object is found within Java.. If you don'T know
    what is a queue, it's like a stack, but instead of
    begin Last In first out, it's First in First Out.
    If it doesn't exist, does anybody have it already
    code, it would just speed things a bit.You can use LinkedList from the collections framework. There are add last and remove first methods available.

  • Cannot drop queue objects - invalid username/password

    Folks - I'm having an issue where I cannot drop the user that owns my AQ/streams objects from an 11g database.
    SYS@bwapepd1> drop user streams cascade;
    drop user streams cascade
    ERROR at line 1:
    ORA-24008: queue table STREAMS.LB_SUBS_SOURCE_QT must be dropped first
    So then I try to drop the queue -
    SYS@bwapepd1> execute dbms_aqadm.drop_queue('STREAMS.LB_SUBS_SOURCE_Q');
    BEGIN dbms_aqadm.drop_queue('STREAMS.LB_SUBS_SOURCE_Q'); END;
    ERROR at line 1:
    ORA-01017: invalid username/password; logon denied
    ORA-06512: at "SYS.DBMS_AQADM_SYS", line 3472
    ORA-06512: at "SYS.DBMS_AQADM", line 167
    ORA-06512: at line 1
    So, next I tried to drop the queue table with a force -
    SYS@bwapepd1> BEGIN
    dbms_aqadm.drop_queue_table(
    queue_table => 'STREAMS.LB_SUBS_SOURCE_QT',
    force => TRUE);
    END;
    BEGIN
    ERROR at line 1:
    ORA-01017: invalid username/password; logon denied
    ORA-06512: at "SYS.DBMS_AQADM_SYS", line 4215
    ORA-06512: at "SYS.DBMS_AQADM", line 197
    ORA-06512: at line 2
    I've tried as both SYS and the STREAMS owner and both get the same invalid username/password error.
    Any help is much appreciated.
    Thx!
    rb

    There is insufficient information here to help you but my recommendation would be:
    1. Stop the queue
    2. Drop the queue
    3. Drop the queue table
    4. Drop the user with cascade
    If you are getting an insufficient privs message when logged on as SYS then you need to make sure that you are where you think you are: You are not. Perhaps you have a remote connection, for example.
    PS: Is this Windows and are you using the joke that is remote desktop? That is one example of not being where you think you are.

  • Problem with Queue and linked list

    Hi... i've got an assignment it start like this.
    You are required to write a complete console program in java includin main() to demonstrate the following:
    Data Structure: Queue, Priority Queue
    Object Involved: Linked-List, PrintJob
    Operations Involved:
    1. insert
    2. remove
    3. reset
    4. search
    Dats all... I've been given this much information... Can any1 try to help me please... How to make a start??? And wat does the print job means???
    Can any1 tell me wat am supposed to do...

    Hi,
    Why don't you start your demo like this?
    import java.io.IOException;
    public class Demo {
         public Demo() {
         public void startDemo() throws IOException {
              do {
                   System.out.println("String Console Demo ");
                   System.out.println("\t" + "1. Queue Demo");
                   System.out.println("\t" + "2. PriorityQueue Demo");
                   System.out.println("\t" + "3. LinkedList Demo");
                   System.out.println("\t" + "4. PrintJob Demo");
                   System.out.println("Please choose one option");
                   choice = (char) System.in.read();
                   showDemo(choice);
              } while (choice < '1' || choice > '4');
         public void showDemo(char ch) {
              switch (ch) {
              case '1':
                   System.out.println("You have chosen Queue Demo ");
                   showOperations();
                   break;
              case '2':
                   System.out.println("You have chosen Priority Queue Demo ");
                   showOperations();
                   break;
              case '3':
                   System.out.println("You have chosen LinkedList Demo ");
                   showOperations();
                   break;
              case '4':
                   System.out.println("You have chosen Print Job Demo ");
                   showOperations();
                   break;
         private void showOperations() {
              System.out.println("Please choose any operations ");
              System.out.println("\t" + "1. Insert ");
              System.out.println("\t" + "2. Remove ");
              System.out.println("\t" + "3. Reset ");
              System.out.println("\t" + "4. search ");
         public static void main(String[] args) throws IOException {
              Demo demo = new Demo();
              demo.startDemo();
         private char choice;
    Write a separate classes for the data structures show the initial elements and call the methods based on the operations then show the result.
    Thanks

  • 11.5.10.2 to R12.1.1 upgrade: jtfpfstart.sql : PLS-00905: object APPS.JTF_PF_CONV_PKG is invalid

    Hello,
    EBS version : 11.5.10.2
    DB version : 11.2.0.3
    OS version : AIX 6.1
    As a part of 11.5.10.2 to R12.1.1 upgrade, while applying merged 12.1.1 upgrade driver(u6678700.drv), we got below error :
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ATTENTION: All workers either have failed or are waiting:
               FAILED: file jtfpfstart.sql on worker  1.
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Worker LOG :
    Start time for file is: Wed Aug 07 2013 14:53:36
    sqlplus -s APPS/***** @/fmstop/r12apps/apps/apps_st/appl/jtf/12.0.0/patch/115/sql/jtfpfstart.sql &un_apps &un_jtf
                dbms_aqadm.drop_queue_table(queue_table=>JTF_PF_CONV_PKG.QTABLENAME, force=>true);
    ERROR at line 23:
    ORA-06550: line 23, column 47:
    PLS-00905: object APPS.JTF_PF_CONV_PKG is invalid
    ORA-06550: line 23, column 6:
    PL/SQL: Statement ignored
    ORA-06550: line 27, column 45:
    PLS-00905: object APPS.JTF_PF_CONV_PKG is invalid
    ORA-06550: line 27, column 2:
    PL/SQL: Statement ignored
    ORA-06550: line 28, column 38:
    PLS-00905: object APPS.JTF_PF_CONV_PKG is invalid
    ORA-06550: line 28, column 2:
    PL/SQL: Statement ignored
    ORA-06550: line 29, column 39:
    PLS-00905: object APPS.JTF_PF_CONV_PKG is invalid
    ORA-06550: line 29, column 2:
    PL/SQL: Statement ignored
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    So far I have done below :
    SQL> ALTER PACKAGE APPS.JTF_PF_CONV_PKG compile;
    Warning: Package altered with compilation errors.
    SQL> show error
    Errors for PACKAGE APPS.JTF_PF_CONV_PKG:
    LINE/COL ERROR
    30/3     PL/SQL: Declaration ignored
    30/39    PLS-00201: identifier 'JTF_PF_PAGE_OBJECT_TABLE' must be declared
    66/3     PL/SQL: Declaration ignored
    66/33    PLS-00201: identifier 'JTF_PF_TABLETYPE' must be declared
    SQL> ALTER PACKAGE APPS.JTF_PF_CONV_PKG compile body;
    Warning: Package Body altered with compilation errors.
    Found Upgrade 11i to R12.1.3 worker fails on jtfpfstart.sql PLS-00905: object APPS.JTF_PF_CONV_PKG is invalid (Doc ID 1463373.1) which has fixed JTF_PF_TABLETYPE.
    drix10:/fmstop/r12apps/apps/apps_st/appl/admin/FMSTEST/log>cd $JTF_TOP/patch/115/xdf
    drix10:/fmstop/r12apps/apps/apps_st/appl/jtf/12.0.0/patch/115/xdf>tnsping $TWO_TASK
    TNS Ping Utility for IBM/AIX RISC System/6000: Version 10.1.0.5.0 - Production on 07-AUG-2013 15:03:59
    Copyright (c) 1997, 2003, Oracle.  All rights reserved.
    Used parameter files:
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=drix10)(PORT=1541)) (CONNECT_DATA=(SID=FMSTEST)))
    OK (0 msec)
    drix10:/fmstop/r12apps/apps/apps_st/appl/jtf/12.0.0/patch/115/xdf>
    drix10:/fmstop/r12apps/apps/apps_st/appl/jtf/12.0.0/patch/115/xdf>adjava -mx512m -nojit oracle.apps.fnd.odf2.FndXdfCmp apps apps \
    > apps apps thin drix10:1541:FMSTEST type \
    > jtf_pf_tabletype.xdf $FND_TOP/patch/115/xdf/xsl
                         Copyright (c) 2002 Oracle Corporation
                            Redwood Shores, California, USA
                                        AD Java
                                     Version 12.0.0
    NOTE: You may not use this utility for custom development
          unless you have written permission from Oracle Corporation.
    Reading product information from file...
    Reading language and territory information from file...
    Reading language information from applUS.txt ...
      Temporarily resetting CLASSPATH to:
      "/fmstop/r12apps/apps/apps_st/appl/ad/12.0.0/java/adjava.zip:/fmstop/r12apps/apps/tech_st/10.1.3/appsutil/jdk/lib/dt.jar:/fmstop/r12apps/apps/tech_st/10.1.3/appsutil/jdk/lib/tools.jar:/fmstop/r12apps/apps/tech_st/10.1.3/appsutil/jdk/jre/lib/rt.jar:/fmstop/r12apps/apps/apps_st/comn/java/lib/appsborg.zip:/fmstop/r12apps/apps/tech_st/10.1.2/forms/java:/fmstop/r12apps/apps/tech_st/10.1.2/forms/java/frmall.jar:/fmstop/r12apps/apps/tech_st/10.1.2/jlib/ewt3.jar:/fmstop/r12apps/apps/tech_st/10.1.2/j2ee/OC4J_BI_Forms/applications/formsapp/formsweb/WEB-INF/lib/frmsrv.jar:/fmstop/r12apps/apps/apps_st/comn/java/classes"
      Calling /fmstop/r12apps/apps/tech_st/10.1.3/appsutil/jdk/jre/bin/java ...
    XDF file application started. Current time is: Wed Aug 07 15:04:40 CDT 2013
    ================================================================================
    Applying XDF file : jtf_pf_tabletype.xdf
    ================================================================================
                  Copyright (c) 2003 Oracle Corporation
                     Redwood Shores, California, USA
             XDF(XML Object Description File) Comparison Utility
                            Version 1
    NOTE: You may not use this utility for custom development
          unless you have written permission from Oracle Corporation.
    Type JTF_PF_TABLETYPE does not exist in APPS
    Creating Type
          CREATE OR REPLACE TYPE "APPS"."JTF_PF_TABLETYPE" as table of varchar2(2000);
    Start time for statement above is Wed Aug 07 15:04:40 CDT 2013
    End time for statement above is Wed Aug 07 15:04:41 CDT 2013
    SQL> ALTER PACKAGE APPS.JTF_PF_CONV_PKG compile;
    Warning: Package altered with compilation errors.
    SQL> show error
    Errors for PACKAGE APPS.JTF_PF_CONV_PKG:
    LINE/COL ERROR
    30/3     PL/SQL: Declaration ignored
    30/39    PLS-00201: identifier 'JTF_PF_PAGE_OBJECT_TABLE' must be declared
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    I could not see any doc on metalink or google talking about JTF_PF_PAGE_OBJECT_TABLE.
    Please help.

    Please try the following:
    1. Drop the following objects (take a backup of the tables first) using:
    SQL> create table JTF.JTF_PF_REPOSITORY_TMP_BKP as select * from JTF.JTF_PF_REPOSITORY_TMP;
    SQL> create table JTF.JTF_PF_REPOSITORY_BKP as select * from JTF.JTF_PF_REPOSITORY;
    SQL> drop table JTF.JTF_PF_REPOSITORY_TMP;
    SQL> drop table JTF.JTF_PF_REPOSITORY;
    SQL> drop synonym APPS.JTF_PF_REPOSITORY_TMP;
    SQL> drop synonym APPS.JTF_PF_REPOSITORY;
    2. Run the jtfpfcreate command:
    $ sqlplus -s apps/<apps_pws> @$JTF_TOP/patch/115/sql/jtfpfcreate.sql APPS JTF
    3. Recreate the missing objects:
    $ adjava -mx512m -nojit oracle.apps.fnd.odf2.FndXdfCmp apps apps apps apps thin "<hostname>:<port>:<SID>" all $JTF_TOP/patch/115/xdf/jtf_pf_tabletype.xdf $FND_TOP/patch/115/xdf/xsl
    $ adjava -mx512m -nojit oracle.apps.fnd.odf2.FndXdfCmp apps apps apps apps thin "<hostname>:<port>:<SID>" all $JTF_TOP/patch/115/xdf/jtf_pf_page_object_table.xdf $FND_TOP/patch/115/xdf/xsl
    $ adjava -mx512m -nojit oracle.apps.fnd.odf2.FndXdfCmp apps apps apps apps thin "<hostname>:<port>:<SID>" all $JTF_TOP/patch/115/xdf/jtf_pf_techstack_table.xdf $FND_TOP/patch/115/xdf/xsl
    $ adjava -mx512m -nojit oracle.apps.fnd.odf2.FndXdfCmp apps apps apps apps thin "<hostname>:<port>:<SID>" all $JTF_TOP/patch/115/xdf/jtf_pf_trackpurpose_table.xdf $FND_TOP/patch/115/xdf/xsl
    4. Drop unused queue objects:
    begin
    DBMS_AQADM.DROP_QUEUE_TABLE (queue_table => 'JTF_PF_LOGGING_TABLE', force => TRUE);
    end;
    5. Restart the failed worker using adctrl
    Regards,
    Hussein

  • Configure Monitoring of a MSMQ private queue Messages in Queue counter

    Hi
    I have a workgroup server that is not part of my local domain.
    I have contented the server to my local SCOM 2012 R2 server and it is working fine.
    My SCOM server has MSMQ 6.0 & 6.3  MP's installed.
    On the remote servers I have some MSMQ 6.0 private queues.
    When I am trying to monitor one counter in 1 queue , when the threshold is reached I am getting error message on al the queues.
    On the performance counter tab I have :
    Object: MSMQ Queue
    Counter : Messages In Queue
    Instance :[server name'\private$\error
    There were 1207 messages in this queue .
    I Got about 30 messages and error on all queues.
    What did I do wrong ?
    Itamar
    Itamar

    Hi
    This is the alert email I got :
    Alert: Notification Queue
    Source: maasw1\private$\maas.backend.scheduler.timeoutsdispatcher
    Path: MAASW1.xxx.com
    Last modified by: System
    Last modified time: 2/18/2014 2:45:49 PM Alert description: Instance Computer Queues
    Object MSMQ Queue
    Counter Messages in Queue
    Has a value 19
    At time 2014-02-18T14:45:35.0000000+02:00
    I did not place a monitor on this queue but on 2 other queues.
    one with threshold of 500 and on with 1 .
    I have made some change in the monitor and will test it now.
    Thanks
    Itamar 
    Itamar

  • Local Queue in a cluster

              Hi
              Is there any way to programmatically determine whether a queue is local to a server
              in a cluster. Like for example there are 3 server in a cluster and I have pinned
              the Queue to a server say server#3. Now I want to start some processes in that
              server which hosts the Queue - and not in any other server - like a polling program.
              So somehow that has to detect that the Queue is local to that server though the
              JNDI name is replicated in the cluster ie all members in the cluster should be
              able to see the Queue.
              thanks
              Anamitra
              

              You can look up the queue using createQueue() with the syntax
              "./queue-name". This looks for queue's running on the same
              server as the client's host connecton. (A client running
              on a server will host its connection on the same server
              provided the client's connection-factory contains the server
              in its target list...). This syntax is supported by 7.0,
              6.1SP3 or later, and 6.1SP2 with patch CR072612.
              You can turn off JNDI name replication for the destination.
              This feature is not exposed on the console until 8.1, but you can
              set it in the destinations config.xml via:
              JNDINameReplicated="true"
              This may not work on all versions, if this doesn't work (eg it
              generates a syntax error), contact customer support. There
              are enhancement patches...
              In WebLogic 8.1 you can query the queue object to determine
              the related mbean. Then get the parent's parent
              to determine the server-name. (see weblogic.jms.extensions.JMSHelper)
              You other versions you can get the mbeans as well. If you
              use the "local" mbean-home, it restricts the view to
              runtime mbeans that are running on the same server as
              the supplied context:
              if (useLocalMBeanHome)
              mbh = (MBeanHome)ctx.lookup(MBeanHome.LOCAL_JNDI_NAME);
              else
              mbh = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
              Tom
              Anamitra wrote:
              > Hi
              > Is there any way to programmatically determine whether a queue is
              local to a server
              > in a cluster. Like for example there are 3 server in a cluster and I
              have pinned
              > the Queue to a server say server#3. Now I want to start some
              processes in that
              > server which hosts the Queue - and not in any other server - like a
              polling program.
              > So somehow that has to detect that the Queue is local to that server
              though the
              > JNDI name is replicated in the cluster ie all members in the cluster
              should be
              > able to see the Queue.
              >
              > thanks
              > Anamitra
              

  • Fetching and inserting back to JMS queue

    hai,
    I want to check which all queues are active......So whenever a queue comes i am putting that in active queue list........so if any case the message cannot be sent then that queue will be active.....so i want to find the number of attempts made by the queue......i have set one variable in the queue object......so whenever one attempt is made i have to fetch the object from the queue, increment the variable and put it back to the queue......So how can i do that.......Is there any other alternate way to find the number of attempts made by a queue....Please help
    Sreenivasan

    As far as I know, your only options is to do as the exception you cut-and-pasted below
              states:
              "To force this participation, set the enableTwoPhaseCommit property on the corresponding
              JDBCTxDataSourceproperty, to true. Pool = ejbPool"
              The "enableTwoPhaseCommit" property has definite drawbacks
              see the javadoc and/or documentation for configuring
              a "JDBCTxDataSource".
              This problem is specific to non-XA resources in general, not JMS (which is an XA resource),
              you may wish to get more info by posting to the transaction newsgroup.
              Tom
              Manoj Bansal wrote:
              > using a container managed transactions can we achieve sending a message to the JMS
              > queue and updating DB as part of single transaction with the data base driver not
              > supporting XA. If yes what all configurations setting I need to do. I tried to achieve
              > this using 2PC but I am getting the error that "javax.transaction.xa.XAException:
              > JDBC driver does not support XA, hence cannot be a participant in two-phase commit.
              > To force this participation, set the enableTwoPhaseCommit property on the corresponding
              > JDBCTxDataSourceproperty, to true. Pool = ejbPool".
              

  • Temporary queue - what am I doing wrong?

    I have two different apps - one server and many clients, both are working with OpenMQ 4.2 on SP1 Vista x86.
    Conception is:
    1. Server has an one permanent queue to whom clients send auth requests.
    2. Each time client prepares authorization request it creates temporary queue, where response from server should arrive - one queue per each client.
    3. Name of this temporary queue is attached to authorization request.
    But it doesn't work =((((((((
    Piece of code on client dedicated to temp queue:
    dataQueue = session.createTemporaryQueue();
    dataQueueName = dataQueue.getQueueName();then DataQueueName is being sent to server as simple String message (something like temporary_destination://queue/***.***.***.***/61253/1 )property where it tries to use this queue:
    // processing received message...
    dataQueue = new com.sun.messaging.Queue(receivedString);But it doesn't work, Connection not created exception occurs.
    What am I doing wrong?
    Thanks to everybody for your future answers.

    thanks for your answer!
    I've tried to work with autocreated queues as you wrote and it works, great =)
    but I have a problem when adopting your example
    Queue tmp = m.getJMSReplyTo();
    there is type mismatch here, tmp is an +com.sun.messaging.Queue+ object, but method +getJMSReplyTo()+ returns +javax.jms.Destination+ =(
    Edited by: GlebHappy on 17.11.2008 0:11                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • In a Multiconsumer queue when I use listen() I get error ORA-00600

    I created a queue table
    SYS.DBMS_AQADM.CREATE_QUEUE_TABLE
    QUEUE_TABLE => 'TEST_QUEUE_TAB'
    ,QUEUE_PAYLOAD_TYPE => 'TEST_TYPE'
    ,COMPATIBLE => '8.1'
    ,SORT_LIST => 'ENQ_TIME'
    ,*MULTIPLE_CONSUMERS => TRUE*
    ,MESSAGE_GROUPING => 0
    End;
    This is my C# code that I am using to dequeue message synchronously in a mutli consumer queue using ODP. I am getting Oracle exception ORA-00600 in the OracleAQQueue.Listen() method. Any help I would greatly appreciate it.
    try
    string connString = "Data Source=XXX;User Id=XXX; Password=XXX";
    OracleConnection connObj = new OracleConnection(connString);
    connObj.Open();
    //create a new queue object
    OracleAQQueue queueObj = new OracleAQQueue("TEST_QUEUE", connObj);
    queueObj.MessageType = OracleAQMessageType.Udt;
    queueObj.UdtTypeName = "TEST_TYPE";
    queueObj.NotificationConsumers = new string[1] { "OPTEST" };
    queueObj.DequeueOptions.Visibility = OracleAQVisibilityMode.OnCommit;
    queueObj.DequeueOptions.ConsumerName = "OPTEST";
    queueObj.NotificationConsumers = new string[]{ "OPTEST" };
    queueObj.DequeueOptions.Wait = 100;
    string[] listenConsumers = new string[1] { "OPTEST" };
    queueObj.Listen(listenConsumers);
    catch(Exception ex)
    MessageBox.Show(ex.ToString());
    }

    ORA-00600, by definition, is an unhandled error in the Oracle database's internal code.
    Open a Support Request (SR) with Oracle or, if you do not have access, have your DBA or a senior developer do it for you.
    It is Oracle's responsibility to fix this ... not yours.

  • A suitable Queue

    Hi all,
    First, sorry for the long messages, but I want to describe my problems in details :)
    I am building an application that read messages from a UDP socket. The server that provide those messages is very fast. if my application is slower than the server, then message will be lost (due to limited size for UDP socket buffer).
    I can't use threads to read from the server or in process received messages because messages have to be handled in the sending sequence sequential (each message depends on the previous one).
    as a solution for this I decided to use a queue and create two threads; one to read messages and insert them in queue, and the other one to read messages from the queue and process them. in this case I guarantee that I receive all messages, and process messages sequentially. (I used LinkedBlockingQueue)
    Now I faced another problem, the queue size increased dramatically, I noticed that the reading thread is very fast compared with the processing thread; so you can find that the reading thread insert many messages while the processing thread process one and the BIG problem is the processing thread finish its work but can't get a new messages from the queue. I think because the reading thread is blocking the queue object, and when release it after insertion, the processing thread can't get access because the other thread is too fast and will block it again !!!
    thanks for your time.
    regards,

    LinkedBlockingQueue has a takeLock and a putLock. i.e there is a different lock for read as writing. So one shouldn't block waiting for the other.
    If your processing thread cannot keep up with your reading thread you have a serious problem. The queue length should reach some maximum size or you will run out of memory.
    It worth noting that just having a fast reader just removes one source of packet loss. You still need a means of requesting packet from the sender. (Note: they can arrive out of order too)
    You could use ArrayBlockingQueue which is faster but has a limited size. If this fills up you will need to get the packets again.

  • Purge queue

    is there a way to purge a queue or topic of all messages from the command line? In other words, is there a way to delete all the existing messages already in an existing queue or topic?

    From the command line, I am sure there is a command within the runmqsc command. But I am not sure what it is..
    Through a program you could just do destructive reads with a receiver that does a "GetWait" on the queue.
    //Start session and etc....
              QueueReceiver queueReciever = session.createReceiver(Queue object);
              boolean messagefound = true;
         //Start connection
              connection.start();
              while (messagefound) {
    Message m = queueReciever.receive(1000);
    if (m != null) {
    messagesCleared++;
    }else {
    messagefound = false;
    //Close session and connection once all messages have been read off.
         session.close();
         connection.close();

  • Multiple Queues -- HELP!!!

    I have to do a program using data structures, queues to implement a supermarket with 3 counters.
    Therefore I will need 3 queues;
    Do i use array to implement the queues?
    I can save all customer details into a single queue but can't save it into either 1 of an array of queues.
    Queue[] q = new Queue[3];
    q[0].enqueue(new Customer(name));
    For my Queue class, how to cater for arrays??
    Is the above correct???

    You can use an array to implement queues, although I wouldn't. I think you should use a java.util.LinkedList.
    Once you have an implementation of a queue, you can have an array of queue objects. That's what the code snippets you posted seem to suggest.

  • Creating a destination queue programatically

    Is there any way to create a Destination Queue for a Connection Factory through my Java program, if I do not want to do it through the Admin console?
    Specifically, is there an API to create a JMS queue?
    Thanks.

    What do you mean by creating Queue for ConnectionFactory? ConnectionFactory is to create connection to the JMS server.
    JMS provides methods like createTopic and createQueue but they are for converting provider specific name into Topic or Queue object for destinations already existing. One can not create physical destinations through these methods. Exception is for temporary destinations. Methods are createTemporaryQueue and createTemporaryTopic. Their life period is that of the connection. They will be garbage collected when the connection is closed.
    Sagar
    http://www.sun.com/software/products/message_queue/

  • JMS Queue problem

    Can I create multiple QueueReceiver object using createReceiver(queueObj) over same QueueConnection and QueueSession ?
    Like :
    -------QueueConnectionFactory qConnFactory=null;
    QueueConnection qConn =null;
    QueueSession qSession=null;
    QueueReceiver receiver_1=null;
    QueueReceiver receiver_2=null;Multiple Queue Object
    Queue queueObjOne=null;
    Queue queueObjTwo=null;
    qConnFactory= getQueueConnectionFactory();
    qConn = (QueueConnection)qConnFactory.createConnection();
    qSession=qConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);start the Queue Connection
    qConn.start();Create Receiver One
    receiver_1 = qSession.createReceiver(queueObjOne,);Create receiver Two
    receiver_2 = qSession.createReceiver(queueObjTwo,);Can any bosy please help whether the approach is Ok or some better way?

    I don't know about other JMS providers but with SUN MQ, yes, you can have multiple receivers on the same session.
    Tom

Maybe you are looking for

  • Error while creating contract wrt pr

    hi i am creating a pr for cotract, via me51n..selecting outline agr req..then creating pr for a raw material... i m releasing this pr in 54n...now i go to 31k...i select wrt pr....now when i give my pr no. i get this error message "Requisition doc. t

  • Automatic Lens Correction in the Camera Raw Correction Panel not showing

    I have just migrated my CS5 to another computer. However to my surprise II could not see automatic Lens Correction option in my Lens Correction Panel of Camera Raw as in then past. All i got was option for Chromatic Aberration etc. How do I get the s

  • I dont know what happens to my ipod

    i have a ipod video of 30G and it was working well untill a few days ago that i start having problems with it....i was putting music on my ipod and after my ipod finish updating in itunes y see the screen of my ipod and the apple logo was there as if

  • Where the Login Module should reside

    Hi All, We have a client which is swing application and we are trying to authenticate an user using the weblogic specfic Login module and authenticate method of the hepler class Authenticate. Right now the Login Module and policy file reside in the c

  • USB Port On The Back Of FIOS Router

    I just got FIOS and was checking out the wireless router when I noticed it had USB. What is the USB for? Can I plug a Harddrive into it or printer?