How to check if Message already exists in the queue and if message is processing currently

Hi everyone
I am new to Azure and worked on adding messages to the queue through workerrole1. Worker role 2 pulls them out from queue and processing them and de-queing them.
Worker role1 runs method gets called after every 10 seconds and puts messages in queue
CloudQueueMessage
message = newCloudQueueMessage(oAzureWorker.WorkerInstanceOf
+ "_"+ oAzureWorker.AgentId.ToString()
+ "|"+ ExecutionId.ToString());
                                queue.AddMessage(message);
Worker role2 runs method gets called after every 10 seconds too and checks the queue like this
foreach
(CloudQueueMessagemessage
inqueue.GetMessages(20,
TimeSpan.FromMinutes(5)))
// Process all (20) messages in less than 5 minutes, deleting each message after processing.
// Process message
queue.DeleteMessage(message);
Following are my questions
1) How do I check in worker role1 if the message is already in queue, Because I don't want to queue it back again if its not yet processed and is in the queue already
2) How do I check in worker role1 if the message is currently processing. Because I don't want to queue it back again.
3) How do I make sure that ALL the messages get processed in the order they are inserted. I know Queue is FIFO, but I know if the message gets delayed in processing another instance can pick it up, even if it gets picked up by another instance, I want to
make sure that the order remains.
Right now the instances of both these worker roles are 1, in the future when we increase them, I don't want them to queue the same messages multiple times or queue them if the message is already in process mode.

Hi Sarah,
I agree to the Frank's suggestion. Why you need to burden the worker role 1 to check if the message really sits on the queue or not? You can do this simply in your code before pushing it on queue instead querying queue.
All you need to do on worker role 1 is - push the message on the queue and forget as the entire queue design in azure is designed from asynchronous processing.
About worker role 2 - Use the GetMessage method which hides retrieved message's from other clients and hence makes sure that only one client is processing it at a time. If processing is successful - delete the message. if it is not - the message will be
visible anyways after the mentioned time provided in the GetMessage method.
I agree that when you will increase number of instances of your worker role 1 which might insert duplicates in the queue - in that case - you might need to introduce the shared entity (like database) and let all instances communicate through it to avoid
the duplication of messages on queue. 
Bhushan | http://www.passionatetechie.blogspot.com | http://twitter.com/BhushanGawale

Similar Messages

  • How to check if a constraint existed in the table and drop it?

    Hi all,
    I want to drop a constraint from a table. I do not know if this constraint already existed in the table. So I want to check if this exists first.
    Below is my query:
    DECLARE
    itemExists NUMBER;
    BEGIN
         itemExists := 0;
    SELECT COUNT(CONSTRAINT_NAME) INTO itemExists
    FROM ALL_CONSTRAINTS
    WHERE UPPER(CONSTRAINT_NAME) = UPPER('my_constraint');
    IF itemExists > 0 THEN
    ALTER TABLE my_table DROP CONSTRAINT my_constraint;
    END IF;
    END;
    Here is the error I got when I executed the above query:
    ORA-06550: line 11, column 5: PLS-00103: Encountered the symbol "ALTER" when expecting one of the following: ( begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge
    Please help me with this!
    Greatly appreciate!
    Khoi Le

    Yes, I also tried to put the pl-sql in the Execute Immediate. However, the error still remains
    EXECUTE IMMEDIATE 'DECLARE
    itemExists NUMBER;
    BEGIN
         itemExists := 0;
    SELECT COUNT(CONSTRAINT_NAME) INTO itemExists
    FROM ALL_CONSTRAINTS
    WHERE UPPER(CONSTRAINT_NAME) = UPPER('my_constraint');
    IF itemExists > 0 THEN
    ALTER TABLE my_table DROP CONSTRAINT my_constraint;
    END IF;
    END';
    I execute the above code via running the batch file.
    Here is the error after I ran the batch file:
    ORA-06550: line 11, column 5:
    PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
    ( begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    continue close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe purge
    The symbol "lock was inserted before "ALTER" to continue.
    ORA-06550: line 11, column 53:
    PLS-00103: Encountered the symbol "DROP" when expecting one of the following:
    . , @ in <an identifier>
    <a double-quoted delimited-identifier> partition subpartition
    ORA-06512: at line 2117
    I can not manually drop it. I need to do this via running an update script file.
    Is there a different way to accomplish this?
    Thank you very much!

  • How to check whether a file exist in the program folder or not?

    Hi guys,
    how to check whether a file exist in the program folder or not? Let is say i recieve a file name from user then i want to know if the file is there not and act on that base.
    abdul

    Look at the class java.io.File and the .exists() method:
    http://java.sun.com/j2se/1.4/docs/api/java/io/File.html

  • How to check if nativemenu already exists?

    In my simple example below, everytime you click on the link to reload the page, a new nativemenu is created along with the one that was already there... Click the HOME-INDEX link multiple times and you will see multiple copies of same menu pop up along the top.
    How can I check to see if the menu already exists, so that it is NOT recreated everytime?
    Using Air 1.5 on Win XP Pro.
    Thanks
    INDEX.HTML FILE;
    <html>
    <head>
      <title>index.html example</title>
      <script type="text/javascript" src="includes/AIRAliases.js"></script>
      <script type="text/javascript" src="includes/AIRMenuBuilder.js"></script>
      <script type="text/javascript">
        var MainMenu = air.ui.Menu.createFromXML("source/MainMenu.xml");
        air.ui.Menu.setAsMenu(MainMenu);
      </script>
    </head>
    <body>
      <h1>index.html example</h1>
      <br>
      <a href="index.html">HOME-INDEX</a>
    </body>
    </html>
    SOURCE/MAINMENU.XML FILE:
    <?xml version="1.0" encoding="utf-8" ?>
    <root>
        <menuitem label="File">
            <menuitem label="Close" onSelect="doFileClose"/>
        </menuitem>
        <menuitem label="Help">
            <menuitem label="About" onSelect="doHelpAbout"/>
        </menuitem>
    </root>

    I have not been able to figure out how to determine if the meny already exists or not, but I did come across using this:
    var _MainMenu = air.ui.Menu.createFromXML("source/MainMenu.xml");
    air.ui.Menu.setAsMenu(_MainMenu, true); //2nd paramter is Overwrite=true
    instead of this:
    var _MainMenu = air.ui.Menu.createFromXML("source/MainMenu.xml");
    air.ui.Menu.setAsMenu(_MainMenu);//No second parameter specified, so assumes Overwrite=false
    Adding the 2nd 'true' parameter still causes the menu to be created everytime, but it will OVERWRITE the previous menu, so there will only ever be one instance of the menu.
    Depending on the size of the menu, it would probably be less cpu intensive to just use somekind of IF statement to determine if it already existed, but if that does not exist, then this is the only alternative I can find right now.
    Thanks

  • How to check if file already exist in application server?

    Hi there,
    Does anyone know a quick way to check if a file has already exists in an application server?
    Thanks in advance.
    Cheers.

    Call the function PFL_CHECK_OS_FILE_EXISTENCE.
    Best regards Jack
    FUNCTION PFL_CHECK_OS_FILE_EXISTENCE.
    ""Lokale Schnittstelle:
    *"       IMPORTING
    *"              FULLY_QUALIFIED_FILENAME LIKE  TPFHT-PFFILE
    *"       EXPORTING
    *"              FILE_EXISTS LIKE  BTCH0000-CHAR1
      OPEN DATASET FULLY_QUALIFIED_FILENAME FOR INPUT.
      IF SY-SUBRC EQ 0.
         FILE_EXISTS = 'X'.
         CLOSE DATASET FULLY_QUALIFIED_FILENAME.
      ELSE.
         CLEAR FILE_EXISTS.
      ENDIF.
    ENDFUNCTION.

  • How to check if a user exists in the system ?

    Dear Gurus,
    I want to check whether a user ID exists in the system after logon by using VBA. If the user ID exists, then I will update the user's information with external data by using the method user.change.
    When running below codes, error occurs and error msg is: "The persistent key for an business object instance of type USER has not been set. Cannot invoke method EXISTENCECHECK"
    How can I do to check the user ID existence ?
    Set oUser = oBAPICtrl.GetSapObject("user")
    oUser.ExistenceCheck "MyUserID", return:=oReturn
    Thanks and Regards,
    Bao Yan

    Mickey,
    I'm afraid I never did get this to work properly. However, in the way of all bad/good (delete as appropriate) programmers eveywhere I worked around this problem. I was using this code in Banner.asp to change the view based on the user group so if a given session variable was set a user would see a different view. It works fine with no slow down on the page and you should be able to adapt it to what you need.
    Hope this helps.
    Neville
    Note: Application variables are ones I have defined in config.xml.
    Code follows:
    <!--START:INC\common\getgroup.asp-->
    <% 'NAH 29/03/2004 ' 'This check the to see if the current user has the group in their membership that has been defined as the group to provide an alternative view of the portal.' 'The group variable is defined in the config.xml as "ALTVIEWGROUP"'
    'Do not do this is we have already matched the group'If Session("groupMatch") <> "1" and Session("groupMatch") <> "2" then
    Dim pGroup
    pGroup = Application("ALTVIEWGROUP") Set Session("groupMatch") = nothing
    Dim Plumtree
    Set Plumtree = Server.CreateObject("ADODB.Recordset") Plumtree.ActiveConnection = "Driver={SQL Server};Server=" & Application("DBSERVER") & ";Database=" & Application("PLUMTREEDB") & ";" Plumtree.Source = "SELECT GROUPID FROM " & Application("PLUMTREEDBUSER") & ".PTGROUPMEMBERSHIP WHERE (USERID = " & strUserID & ") AND (GROUPID = " & pGroup & ")" Plumtree.CursorType = 3 Plumtree.CursorLocation = 2 Plumtree.LockType = 1 Plumtree.Open()
    'If there are records we should have a match otherwise set the session varible to no match.' If Plumtree.EOF then Session("groupMatch") = "2" Else 'By getting here the user should have the matching group but complete one final check to make sure' If cInt(Plumtree.Fields.Item("GROUPID").Value) = cInt(pGroup) then Session("groupMatch") = "1" Else Session("groupMatch") = "2" End If
    End If
    Plumtree.Close() Set Plumtree = Nothing
    End if%><!--END:INC\common\getgroup.asp-->

  • How to check which RFCs causing issues in the system and RFC response times

    Hi,
    We have an issue with the RFC response times in CRM and need investigstion. We need to know which Which RFCs causing issues and how we can solve the problems.
    Regards

    Hi,
    chek the below code
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
    EXPORTING
    FILE = W_FILENAME
    RECEIVING
    RESULT = W_RESULT
    EXCEPTIONS
    CNTL_ERROR = 1
    ERROR_NO_GUI = 2
    WRONG_PARAMETER = 3
    NOT_SUPPORTED_BY_GUI = 4
    others = 5.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-* MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    IF W_RESULT IS INITIAL.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST
    EXPORTING
    DIRECTORY = W_FILENAME
    RECEIVING
    RESULT = W_RESULT
    EXCEPTIONS
    CNTL_ERROR = 1
    ERROR_NO_GUI = 2
    WRONG_PARAMETER = 3
    NOT_SUPPORTED_BY_GUI = 4
    OTHERS = 5.
    IF SY-SUBRC <> 0.
    ENDIF.
    ENDIF.
    IF W_RESULT = 'X'.
    RC = '1'.
    ELSE.
    RC = '0'.
    ENDIF.
    reward if helpful.
    Regards,
    nagaraj

  • How to check if the file already exists in the client directory

    Hi all.
    I'm on devsuite 10g. I'm using webutil to download files from DB using webutil function db_to_client.
    What I need is to check if the file already exists in the client directory and if yes to display a message to ask the user if he wants to overwrite or no. How can I make this???
    Here is the code that I'm using to download the file.
    Thanks all for the collaboration.
    Fabrizio
    declare
    file_path varchar2(2000) := null;
    BEGIN
    /** I ask where saving the file on the client machine **/
    file_path:= webutil_file.file_selection_dialog
    (directory_name => null,
    file_name => :bin_docs.name,
    file_filter => '',
    title => 'Saving file',
    dialog_type => save_file, --save_file
    select_file => TRUE);
    /** I download the file from DB to client **/
    if webutil_file_transfer.DB_To_Client_With_Progress
    ( file_path ,
    'BIN_DOCS',
    'DOC' ,
    'doc_id = '||:bin_docs.doc_id,
    'Downloading file',
    ' '||:bin_docs.name) then
    msg_alert('Download del file avvenuto con successo','I',false);
    else
    msg_alert('Si è verificato il seguente errore in fase di download '||SQLERRM,'I',false);
    end if;
    end;

    How about something like the below:
    Note: I have a yes/no alert to asking if they want to over-write the existing file.
    DECLARE
    file_path VARCHAR2(2000) := null;
    over_write BOOLEAN := TRUE;
    BEGIN
    /** I ask where saving the file on the client machine **/
    file_path:= webutil_file.file_selection_dialog
    (directory_name => null,
    file_name => :bin_docs.name,
    file_filter => '',
    title => 'Saving file',
    dialog_type => save_file, --save_file
    select_file => TRUE);
    IF webutil.file_exists(file_path) THEN
    /** check a file by the same name exists in the selected directory **/
    IF show_alert('Ask_overright') != alert_button1 THEN
    /** If we say no then set over_write value to false **/
    over_write := FALSE;
    END IF;
    END IF;
    IF over_write THEN
    /** I download the file from DB to client **/
    IF webutil_file_transfer.DB_To_Client_With_Progress
    ( file_path ,
    'BIN_DOCS',
    'DOC' ,
    'doc_id = '||:bin_docs.doc_id,
    'Downloading file',
    ' '||:bin_docs.name) then
    msg_alert('Download del file avvenuto con successo','I',false);
    ELSE
    msg_alert('Si è verificato il seguente errore in fase di'
    ||' download '||SQLERRM,'I',false);
    END IF
    END IF;
    END;
    cheers
    Q

  • How do I make my already existing check boxes "checkable" [so I can check and uncheck them on PDF Expert]

    How do I make my already existing check boxes on a (PDF Document) checkable - So I can check and uncheck them on PDF Expert or Annotate 101.
    I am using ADOBE Acrobat PRO with millions of options, but no easy "here is how to do the one thing you want to do" anywhere within reason.
    Please help me.
    Thank You

    Can you check and uncheck the boxes in Acrobat?

  • How to check if the file already exists in the application server directory

    Hi all. I'm on devsuite 10g.
    I transfer file from local machine to application server using webutil function webutil_file_transfer.client_to_as and I want to check if the file I'm transfering already exists on the server directory.
    How can I make this?
    Thanks all,
    Fabrizio

    use the text_io package and open the file in read-mode.
    like this
    declare
    xFileType text_io.file_type;
    begin
    xFileType := text_io.fopen('c:\temp\test.txt','R'); --file on the middle tier
    -- file exists;
    text_io.fclose(xFileType);
    exception
    when others then
    --file doesn't exist
    end;
    regards
    Christian

  • This entry already exists in the following tables  'G/L Accounts' (OACT) (ODBC -2035)  [Message 131-183]

    Hi expert,
    In chart of account one G/L currency i want to change local currency to all currency but system is showing this massage
    This entry already exists in the following tables  'G/L Accounts' (OACT) (ODBC -2035)  [Message 131-183]
    what is the reason and how to change please advise.
    Regards
    Mukesh Singh

    Hi,
    You may check this thread:
    Re: This entry already exists in the following tables -Message
    Also check SAP Note Number: 1054713 to see if it applies to you. It might be a bug too.
    Thanks,
    Gordon

  • Please help me how to check a material does existed group code in system (w

    Hi all,
    Please help me...
    I have inputted quantity for  tx MC 94  but when I input them into  tx MC94, I met  a message " Structure  not yet maintained for  this conbination characterstics". Step by step to show a error message as below:
    Step 1: Launch MC 94
    step 2: Enter Planning
    Step 3: Enter  Prod.Code. Material (ex: enter material code :0101010260008, this code is existed  Prod.Code )
    Step 4: Click on "Inactive Version " button
    ==> A error message is showed.
    Please help me how to check a material does existed group code in system (which table to  check  it)?
    How to record the message" Structure  not yet maintained for  this conbination characterstics" to catch up it in my program?
    Thank in advance.

    Karenloria,
    1. Check in MC8C, which Infostructure is used for Planning type "Planning" or the one you are entering in the intial screen of MC94.
    2. Using transaction MC63 for the infostructure identified in step 1, check the planning hierarchy maintained. If this product is not maintined maintain using MC62.
    You can also check using SE16 transction the current infostructe records(Plan) for the table name = infostructure identified in step 1.
    Regards,
    Prasobh

  • Error when creating a user - IAM-3010183 : An error occurred while checking if a user already exists with the Common Name generated.

    Error when creating a user - IAM-3010183 : An error occurred while checking if a user already exists with the Common Name generated.

    in OIM 11g R2
    Message was edited by: 2b3c0737-074f-48d0-a760-e24e3ed9a37c

  • This entry already exists in the following tables -Message

    Hi,
    Im getting a [RDN1.WhsCode][line:3], 'This entry already exists in the following tables(ODBC-2035)'
    This message is presented frequently in returns and credit memos. Our company uses batch numbers for our items. When the item is returned, is returned to a different warehouse from it was originally delivered, so we change the warehosue in the return form and credit memo form. So we need to click the "create" button in the batch selection window, because there are no batch numbers to be selected.
    Any Ideas as how to solve the problem?
    Thank you.

    Hi,
    This entry already exists in the following tables Message is always related to duplicated record creation or application error.  For you case, I think it is better to return to original warehouse first and do inventory transfer to the actual return location in the second step.
    Thanks,
    Gordon

  • Getting error message 2053 "This entry already exists in the following tab"

    Hi all
    i have a user form which is connected to UDO of type document which has a document line user table which is bounded to a matrix within the user form.
    when i add a new line to the matrix and press update it works fine. when i change a value in one of the fields of the newly added row and press the update button, i recieve the error message:
    "2053 This entry already exists in the following table".
    question is what is causing this error and how can it be fixed?
    appreciate the help
    Yoav

    Hi Yoav,
    If you run "Restore numbering"from the administration/.../Restore menu it will probably be solved.
    Regards
    Ad

Maybe you are looking for