Circular Dynamic Queue

I was wondering how to make a dynamic queue circular. I thought that maybe I should keep track of how many Nodes there are (by adding 1 to an int variable tracker initially at zero each time a Node is added) and then when it reaches the limit (chosen by user) it would add no more Nodes. Then, I though that to make it circular, then I should check for when the tracker has reached that limit, and instead of making the next Node variable in the last Node null, it should be simply the first Node. I know that what I have written is extremely confusing, but if you understand the concept of Nodes, queues, and what the heck I'm talking about, then at least explain what a circular queue should look like. Thanks.

I was wondering how to make a dynamic queue circular.Why make it circular if it's dynamic? What you probably want is a FIFO (first-in-first-out) queue. One common implementations is to use a linked list. You add nodes at the end and remove them from the front. LinkedList even have methods for that.
The other common implementation is a circular buffer. You use a static array with a fixed length. You keep two indexes. One is pointing at the first free position. It's where you add a node and increment the index. The other is pointing at the last element. It's where you remove a node and increment the index. When an index becomes larger than the array size it "wraps" to zero. That's why it's called circular.
I've posted an implementation here,
http://forum.java.sun.com/thread.jspa?forumID=256&threadID=477885

Similar Messages

  • How to create and use dynamic queue in JMS

    Plz tell me how to create and use a dynamic queue in jms and can reciever file lookup it as it lookup any server configurred queue(written in the server).

    Hi,
    We can use Azure File services to do this, for more information, please have a look at this article:
    http://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/12/introducing-microsoft-azure-file-service.aspx. The Azure File service exposes file shares using the standard SMB 2.1 protocol. Applications running in Azure can now easily share files between
    VMs using standard and familiar file system APIs like ReadFile and WriteFile.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Dynamic queue name with JMS Queue XML?

    Hi,
    Is it possible to use dynamic queue name with JMS Queue XML?
    I tried using a variable in the JNDI URL, and supply the value in a package. I specified the following in the JNDI URL in the Topology:
    e.g.
    <JMS_RESOURCE>?d=<DTD_FILE>&s=<SCHEMA>&JMS_DESTINATION=#PROJECT_NAME.dest_var
    I declared and set the variable in a package, then tried to load data from the above data server to database. But executing this package gave me the following error:
    7000 : null : java.sql.SQLException: javax.jms.JMSException: Cannot find the target in JNDI (#PROJECT_NAME.dest_var)
    java.sql.SQLException: javax.jms.JMSException: Cannot find the target in JNDI (#PROJECT_NAME.dest_var)
         at com.sunopsis.jdbc.driver.bg.executeQuery(bg.java)
         at com.sunopsis.jdbc.driver.bh.executeQuery(bh.java)
         at com.sunopsis.jdbc.driver.l.f(l.java)
         at com.sunopsis.jdbc.driver.l.executeUpdate(l.java)
         at com.sunopsis.sql.SnpsQuery.executeUpdate(SnpsQuery.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execSrcOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandScenario.treatCommand(DwgCommandScenario.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    Am I doing it wrongly?
    Thanks!

    hi,
    as it's not in Adapter-Specific Message Properties
    http://help.sap.com/saphelp_nw04/helpdata/en/10/b1b4c8575a6e47954ad63438d303e4/content.htm
    looks like you cannot do it with jms adapter in standard
    use proxy or your own adapter instead
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Help on Dynamic queue name in JMS Adapter

    Hi Experts,
      Could you please explain how to configure dynamic queue name in JMS Adapter.
    My requirement is i would have to add the date and time to JMS Queue Name in receiver JMS Adapter.
    Thanks in Advance
    Chilla

    hi,
    as it's not in Adapter-Specific Message Properties
    http://help.sap.com/saphelp_nw04/helpdata/en/10/b1b4c8575a6e47954ad63438d303e4/content.htm
    looks like you cannot do it with jms adapter in standard
    use proxy or your own adapter instead
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • JMS dynamic queue time out

    I need to create a JMS dynamic queue and wait to listen in that queue for say 5 secs. Can anyone explain how this works. i.e I want to know what will happen after 5 secs. Will I receive a JMS Message object which is null or it will throw some exception. How do I know that it has timed out.I need to implement some logic based on the fact that the message has timed out.

    Why can't use a timer whereby onTimeOut simply compare the present time and the time the listener starts listening to the dynamic queue. If this is above 5seconds then do what soever you intend doing
    Ivo

  • Reg: Dynamic  Queue name

    Hello Experts,
    Although I am not  a PI expert i would like to ask ,
    Can I have Dynamic Queue name generation on the basis of the payload which i am receiving
    Quality of service my be any EO or EOIO .
    For example My pay load stream my contain  Data for Purchase Req. Creation   / and change its a known fact that Creation payload should come first and then change so my Question is can i have my queue name on basis of the Document which i am processing ?

    I dont thnik this is possible in PI for generating queue names based on payload. As Queue should be utilized proper way and based on the PI resources like work processes,.
    But for your scenario, you can use EOIO and specify queue name accordingly for both scenarios.
    And you can do Queue prioritization to assure the creation payload followed by change payload.
    --Divyesh

  • Dynamic Queue names at JMS receiver

    HI All,
                I have a scenario where sender is an RFC and receiver is via JMS  and also get a reply back . JMS is asynchonous but as suggested in other threads it is possible to capture the response by setting some Adapter specific parameters.
                But my problem is the queue name for the response is not constant and it varies from request to request for the response. I have no clue how to achieve this , I tried searching some threads but couldn't come to a conclusion.
                Possibility of dynamic MQ queue selection in one receiver JMS channel
                help on Dynamic queue name in JMS Adapter
    Has anyone come across such a situation ? Please suggest.
    Also In one of threads it was suggested to use Java Proxy?  Please suggest a way forward in this approach too
    Regards,
    Mohan.

    > please refer the link what you provided in section 2.8 mentioned JMS Receiver communication channel will give response back,but i never tried.
    Yest because this document is applicabe for a scenario where request msg will come form sender JMS to XI and then Response will be sent back again to JMS by using receiver JMS adapter. So senario is JMS request --- R3 (via XI) --- R3 response to JMS.
    But here case is different. e.g. RFC --> PI --> JMS  and reply will get back from JMS  to RFC.  So definetly in this case response will come from sender JMS and not from receiver JMS.
    Read sec 2.8 throughly, you will come to know how to set the queue names dynamically for RECEIVER JMS Adapter.
    Regards,
    Sarvesh

  • Issues in TIME OUT for Dynamic Queues- Using  IBM MQ Client

    Hi
    I have an issue with Dynamic queues. I am using IBM websphere as my Mesaging server and IBM MQ client. I need to send a request to a static queue and then wait for a response for a specified duration(in my case it is 100 millisecs) in the corresponding dynamic queue.But what I found out that in some cases, I got response even after 100 ms !!!! Here's my code. Is there anything wrong going on somewhere???
    com.ibm.mq.jms.MQTemporaryQueue replyToQueue = com.ibm.mq.jms.MQTemporaryQueue)queueSession.createTemporaryQueue();
    replyToQueue.setTargetClient(JMSC.MQJMS_CLIENT_JMS_COMPLIANT);
    requestMsg.setJMSReplyTo(replyToQueue);
    long t1 = System.currentTimeMillis();
    queueSender.send(requestMsg);
    queueReceiver = queueSession.createReceiver(replyToQueue);
    queueConnection.start();
    m = queueReceiver.receive(100);
    long t2 = System.currentTimeMillis();
    if(m != null){
    System.out.println("Response Time: " + (t2 - t1) + " ms");}
    I have left out the queueSession and queueSender piece of code here.
    Anyways, I found 1 response in 122 ms and another in 128 ms. Can anyone throw some light as to why and how this is happening?

    Don't run from the client ... run from the server
    or
    if running from a client use the built-in DBMS_DATAPUMP package's API.
    http://www.morganslibrary.org/reference/pkgs/dbms_datapump.html

  • JMS adapter settings for response to dynamic queue

    Hello,
    We are sending a message through JMS to SAP in a synchronous manner (client waiting for the reply after sending the request). The SAP is receiving and processing the message.
    We configured the JMS Sender & Receiver channel as per solution given in SDN for the quetion. ( (2.8) Does the JMS Adapter support the JMSReplyTo feature? )
    1. In Sender communication channel, checked the "JMS Message ReplyTo Destination" attribute  of 'Adapter specific message attributes'
    2. In Receiver communication channel, added the "JMS.Message.DynamicDestination" parameter and value 'true' (without quotes for both strings) in "Set JMS Additional Parameters" table
    3. Added the "JMSReplyTo" header syntax in input xml message as below:
                        a. Message : <?xml version="1.0" encoding="UTF-8"?>
                                 <ns0:getEmployeeInfo xmlns:ns0="namespace">
                                 <employeeId>0000001</employeeId>
                                 </ns0:getEmployeeInfo>
                        b. Destination = com.someDestination
                        c. JMSReplyTo= com.someReplyQueue
    We have selected Transport protocol option "Access JMS Provider Generically"
    But it is not able to send the reply to replyTo destination of the message.
    Wondering if there is anything in the JMS Adapter setting like reply to Destination (technical term DCJMSReplyTo) which can be set to reply queue of the message (to a dynamic destination).
    Please let me know in case anybody knows about the same.
    Thanks & Regards,
    Jayashri Rade

    Refer: http://docs.oracle.com/cd/B14099_19/integrate.1012/b25307/adptr_jms.htm
    •The JMS API specifies three types of acknowledgments that can be sent by the JMS publisher:
    ◦DUPS_OK_ACKNOWLEDGE, for consumers that are not concerned about duplicate messages
    ◦AUTO_ACKNOWLEDGE, in which the session automatically acknowledges the receipt of a message
    ◦CLIENT_ACKNOWLEDGE, in which the client acknowledges the message by calling the message's acknowledge method

  • Dynamic queue selection with Asynchronous RFC call

    Hi Experts,
    I have a new requirement in designing the business process thru XI. The scenario is posting production orders from a web service thru XI to R3 ( RFC calls). The requirement is that the production orders may come from different plant (Plant and production line combination). So in order to faciliate the load balancing we need to dynamically allot all the process orders from a Plant to single or two queues ( by queues i mean the queuing of the RFC requests with QoS = EO or EOIO). So dynamic selection of queues (XBIXnn) is possible in XI ?.
    Please let me know in case you need further clarification on this
    Thanks in advance

    Rajesh,
    Some more interesting read from,
    http://help.sap.com/saphelp_nw04/helpdata/en/43/65ce41ae343e2be10000000a1553f6/content.htm
    <i>Define Quality of Service (EOIO)
           8.      Specify EOIO (Exactly Once in Order) as the quality of service, as required.
    Messages are then delivered in the same sequence that they are sent in by the integration process.
                                a.      Specify a queue in the Queue Name field.
    You can choose the name of the queue yourself.
    Max. length: 16 characters
    Permitted characters are alphanumeric characters and the following special characters:
    / (slash)
    _ (underscore)
    - (hyphen)
    All send steps that have the same queue name are delivered in the sequence that they are sent in by the integration process.</i> 
    Should be possible if you use a BPM.
    Regards
    Bhavesh

  • Dynamic queue publication in JBI

    In Jcaps513 jcd you could dynamically publish to a queue with the sendTo() method, perhaps based upon incoming message type. How would you do something similar in JBI/BPEL coding?
    Rupert

    Mikael
    Its is possible in the BPEL code by assigning a value to the JMS BC/Outbound/Destination property in the properties section of the outbound partner link in an assign activity.How is that dynamic, in that you can set the value on-the-fly at runtime?
    Michael
    Can/t do that. There is no support for the JMS BC to use a message part to set destination.Consider using JCA MDB with the JMS JCA Adapter instead.
    Ok, thanks.
    Rupert

  • Dynamic Queues using JMS Adapter - Possible?

    Can anyone advise if its possible to dynamically set the JMS Queue DestinationName at runtime when using the JMS Adapter?
    My guess is not, but I thought I'd ask anyway...
    Dennis

    Hi Dennis,
    Did u get a solution for this.
    Even i have a same scenario where i have to select the destination queue dynamically.
    Any help in this regards...
    Regards
    Ashwini

  • MessageQ: dynamic queue names

    In our application we would like to do the following:
    at runtime, attach to a temporary, secondary queue.
    bind some arbitrary name to this queue. exec a new process with the new queue
    name given to it as parameter.
    The 'child' process should be able to read messages put on the queue by the 'father'.
    I haven't been able to get this to work. After creating
    a temporary, secondary queue, my bind_q call fails with a PAMS__NOOBJECT error.
    Are there any configuration items that are needed before this
    can work?
    Thanks, Guy
    If theres a more appropriate forum for MessageQ questions, could you please point
    me to it? Thanks, Guy

    > please refer the link what you provided in section 2.8 mentioned JMS Receiver communication channel will give response back,but i never tried.
    Yest because this document is applicabe for a scenario where request msg will come form sender JMS to XI and then Response will be sent back again to JMS by using receiver JMS adapter. So senario is JMS request --- R3 (via XI) --- R3 response to JMS.
    But here case is different. e.g. RFC --> PI --> JMS  and reply will get back from JMS  to RFC.  So definetly in this case response will come from sender JMS and not from receiver JMS.
    Read sec 2.8 throughly, you will come to know how to set the queue names dynamically for RECEIVER JMS Adapter.
    Regards,
    Sarvesh

  • Dynamic Queue

    Hi,
    Is anyone know how to create queue dynamically in OpenMQ? (not by the administration console)
    The manual shows how to create queue administratively, but I rather want to create it by the code.
    Please give me a hand...
    Regards,
    okomet

    This is a very simple code that when executed will create a queue called "ClusterQueue" if one does not exist already. This will only work if broker's autocreate property is set to true.
    Please note that this only applies to a pure JMS client. In GlassFish things work differently because GF interacts with MQ via resource adapter. That's why you have to define your JMS resources in GF admin console or in your deployment descriptor.
    Hope this helps - Tom
    try {
                queueConnection.start();
                queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                queue = queueSession.createQueue("ClusterQueue");
                queueReceiver = queueSession.createReceiver(queue);
                msg = queueReceiver.receive();
                if ( msg instanceof TextMessage ){
                    TextMessage txtMsg = (TextMessage) msg;
                    long timeStamp = txtMsg.getJMSTimestamp();
                    long theTime = System.currentTimeMillis() - timeStamp;
                    System.out.println("It took " + theTime + " to receive a message");
            } catch (JMSException ex) {
                Logger.getLogger(JMSConsumer.class.getName()).log(Level.SEVERE, null, ex);
            }

  • Dynamic queue listener in Message driven bean

    Hi all
    I wonder if exists a way for creating a message driven bean that reads messages from a queue defined on fly.
    I mean I'd like to create an mdb that read from queue ,where the queue name is defined in a data base table .
    Hope to be clear.
    Thanks in advance

    Yes, you can use either a queue or a topic to drive an MDB.
    There are a number of discussion threads related to MDB's in
    weblogic.develoepr.interest.jms.
    "Herman Lam" <[email protected]> wrote in message
    news:3ac891da$[email protected]..
    >
    Hi Folk:
    Does anyone know whether the Weblogic 6.0 EJB 2.0 Message Driven Bean cansupport
    queue event for the OnMessage( javax.jms.Message messagenmae)
    callback method or does it only support publisher/subscriber event ?
    Best Regards
    Herman

Maybe you are looking for