Handling the case when no value exists

Hello,
I am reading in the documentation about the Context class and the lookup function, but it does not state clearly what it does when a value is not found in the naming service. Does it return null, throw an exception, or what?
Thanks.

Please do not re-post. It would be easier to follow up a single thread.

Similar Messages

  • How to handle "The specified resource does not exist" exception while using entity group transactions to purge WADLogs table

    Hi,
    We have a requirement to purge the Azure WADLogs table on a periodic basis. We are achieving this by using Entity group transactions to delete the
    records older than 15 days. The logic is like this.
    bool recordDoesNotExistExceptionOccured = false;
    CloudTable wadLogsTable = tableClient.GetTableReference(WADLogsTableName);
    partitionKey = "0" + DateTime.UtcNow.AddDays(noOfDays).Ticks;
    TableQuery<WadLogsEntity> buildQuery = new TableQuery<WadLogsEntity>().Where(
    TableQuery.GenerateFilterCondition("PartitionKey",
    QueryComparisons.LessThanOrEqual, partitionKey));
    while (!recordDoesNotExistExceptionOccured)
    IEnumerable<WadLogsEntity> result = wadLogsTable.ExecuteQuery(buildQuery).Take(1000);
    //// Batch entity delete.
    if (result != null && result.Count() > 0)
    Dictionary<string, TableBatchOperation> batches = new Dictionary<string, TableBatchOperation>();
    foreach (var entity in result)
    TableOperation tableOperation = TableOperation.Delete(entity);
    if (!batches.ContainsKey(entity.PartitionKey))
    batches.Add(entity.PartitionKey, new TableBatchOperation());
    // A Batch Operation allows a maximum 100 entities in the batch which must share the same PartitionKey.
    if (batches[entity.PartitionKey].Count < 100)
    batches[entity.PartitionKey].Add(tableOperation);
    // Execute batches.
    foreach (var batch in batches.Values)
    try
    await wadLogsTable.ExecuteBatchAsync(batch);
    catch (Exception exception)
    // Log exception here.
    // Set flag.
    if (exception.Message.Contains(ResourceDoesNotExist))
    recordDoesNotExistExceptionOccured = true;
    break;
    else
    break;
    My questions are:
    Is this an efficient way to purge the WADLogs table? If not, what can make this better?
    Is this the correct way to handle the "Specified resource does not exist exception"? If not, how can I make this better?
    Would this logic fail in any particular case?
    How would this approach change if this code is in a worker which has multiple instances deployed?
    I have come up with this code by referencing the solution given
    here by Keith Murray.

    Hi Nikhil,
    Thanks for your posting!
    I tested your and Keith's code on my side, every thing worked fine. And when result is null or "result.count()<0", the While() loop is break. I found you code had some logic to handle the error "ResourceDoesNotExist" .
    It seems that the code worked fine. If you always occurred this error, I suggest you could debug your code and find which line of code throw the exception.   
    >> Is this an efficient way to purge the WADLogs table? If not, what can make this better?
    Base on my experience, we could use code (like the above logic code) and using the third party tool to delete the entities manually. In my opinion, I think the code is every efficient, it could be auto-run and save our workload.
     >>Is this the correct way to handle the "Specified resource does not exist exception"? If not, how can I make this better?
    In you code, you used the "recordDoesNotExistExceptionOccured " as a flag to check whether the entity is null. It is a good choice. I had tried to deleted the log table entities, but I used the flag to check the result number.
    For example, I planed the query result count is 100, if the number is lower than 100, I will set the flag as false, and break the while loop. 
    >>Would this logic fail in any particular case?
    I think it shouldn't fail. But if the result is "0", your while loop will always run. It will never stop. I think you could add "recordDoesNotExistExceptionOccured
    = true;" into your "else" block.
    >>How would this approach change if this code is in a worker which has multiple instances deployed?
    You don't change anything expect the "else" block. It would work fine on the worker role.
    If any question about this issue, please let me know free.
    Regards,
    Will
    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.

  • Handling the context when integrating SAP with WBIMB

    I need to integrate SAP systems with an integration platform that is based on WebSphere Message Broker 5 (WBIMB). Now I am looking for a feasible solution to integrate these platforms.
    I am concerned about how to handle the context when integrating SAP with WBIMB.
    I have read the topic “SAP XI and WBI adapters” (SAP XI  and WBI adapters) in this forum with interest. However, my requirements are slightly different, and my knowledge on development in SAP is limited.
    The WBIMB integration platform acts as an Enterprise Service Bus in a SOA. We have a general requirement about guaranteed delivery i.e. once and only once, and therefore the transport protocol is MQ. The HTTP protocol does not satisfy this requirement. Thus we can use Web Services when they are carried as SOAP messages over MQ, but SOAP/HTTP is not acceptable.
    The SAP systems can act as service provider as well as service consumer. The WBIMB act as an intermediary, which routes service requests to the proper provider and service responses back to the consumer.
    When acting as a service consumer, the SAP system shall specify the context such that WBIMB is able to route the service request to the service provider. Routing is based on the context, which is specified as a property in the MQRFH2 usr folder. Thus the MQ message containing the service request from the SAP system shall specify this usr property, and the value will depend on the requested service. In JMS, the value can be set by calling the TextMessage.setStringProperty method e.g. as TextMessage.setStringProperty(“MyContext”, “XYZ”).
    When acting as a service provider, the SAP system shall pass the context from the request back in the response message to WBIMB. Actually, I want to pass the complete usr folder from request to response, because it contains more information than just the context property.
    I need answers to the questions:
    1. How can I set the context from SAP when it acts as service consumer?
    2. How can I get SAP to pass the context (MQRFH2 usr folder) from request to response when it acts as service provider?
    3. I have looked at the SAP XI JMS Adapter. It looks as I can set additional JMS parameters. But the property value will depend on which service to call. Do I need to setup a JMS Adapter per service or can I set the value dynamically?
    4. Can the SAP XI JMS Adapter pass the context from request to response?
    5. Are there better alternatives than using the SAP XI JMS Adapter?
    Many thanks for any help you can give me in advance.

    Hi Daniel,
    Thanks for your answer. I expected it would turn out this way
    So the good news is that when SAP is acting as service consumer it sounds fairly easy to set up a mapping from XI message to MQ context.
    But when SAP acts as service provider it sounds as more customisation is required and I am worried about having to save the state. It will hit performance when the context is not carried as part of the message. In this case I prefer to use a generic solution on WBIMB, where I can handle the context for SAP (as well as other service providers). Then I only depend on the ability to set correlation in the response. But it will still cost performance because WBIMB also has to save the state on temporary MQ queue.
    Ideally, the SAP XI/Adapter should be able to pass the context 'out-of-the-box' to better support intermediaries like the WBIMB as ESB. I put this on my wishlist
    Anyway, I appreciate that you was able to confirm my observations.
    BR
    Allan

  • Datasource Enahncement - What is the case when i am not req to do USER Exit

    Experts,
      Can someone explain me what is/are the cases when i do not require to code in the user exit to populate the enhanced field?
    I see for some datasource the enhanced values are populated automatically.
    Appreciate your answers.
    Thanks
    Hari

    Hi Hari,
    In some cases we  do not need to write any code .
    Whenever we need to enhance our datasource we first check in LBWE if the required filed is available in the pool .
    If it is available in pool we simply transfer it to extract structure and in this case we do not write wny code.
    The second case is when we append our extractiion structure because the required field is not abailabl ein the pool.
    In this case we need to write code to populate the field.
    Hope it helps
    Manish Sharma

  • Alert On UDF's when Duplicate value exists

    Hi Experts,
    I want an Alerts message on a UDF's Gate Entry Pass (G.E. No), when any duplicate value is entered in this UDF's.
    e.g.:-  a value is entered in this udf is 30.  when same value is entered it should give an alert that value already exists.
    Thanks & Regards,
    Pankaj Sharma.

    Hi Gordon,
    I am using this UDF's on the GRPO Form and the UDF's name is U_GE_NO(Gate Entry No). my client  uses this field when the material entered the company premises and entered the unique value. so to remove duplicacy in data the want the alert.

  • How to handle the Exception when RegisterEventProcessorAsync

    In our Cloud Service project, we have 2 instances for work role (deploy to Azure), the work role is consume events from the EventHub using EventProcessorHost).
    When we want to register EventProcessor to consume data (see below):
    await eventProcessorHost.RegisterEventProcessorAsync<eventProcessor>();
    Sometimes we will got the Exception:
    Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (412) There is
    currently a lease on the blob and no lease ID was specified in the request.. ---> System.Net.WebException: The remote server returned an error: (412)
    There is currently a lease on the blob and no lease ID was specified in the request..
      at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, T retVal, StorageCommandBase`1 cmd, Exception ex)
       at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpWebResponse resp, T retVal, StorageCommandBase`1 cmd, Exception ex)
       at Microsoft.WindowsAzure.Storage.Blob.CloudBlobSharedImpl.<DeleteBlobImpl>b__1b(RESTCommand`1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx)
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult)
       --- End of inner exception stack trace ---
       at Microsoft.WindowsAzure.Storage.Core.Util.StorageAsyncResult`1.End()
       at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndDeleteIfExists(IAsyncResult asyncResult)
       at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass1`1.<CreateCallback>b__0(IAsyncResult ar)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       at Microsoft.ServiceBus.Messaging.BlobLeaseManager.<DeleteAllAsync>d__2a.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.ServiceBus.Messaging.EventProcessorHost.<InitializeAsync>d__4.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.ServiceBus.Messaging.EventProcessorHost.<StartAsync>d__e.MoveNext()
       --- End of inner exception stack trace ---
       at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
       at System.Threading.Tasks.Task.Wait()
    at awaiteventProcessorHost.RegisterEventProcessorAsync<eventProcessor>();
    If we got the Exception, we won’t got messages any more.
    From the Call Stack, we found it was cause by delete the Blob. So we wonder that, when we call
    RegisterEventProcessorAsync,
    the hub will delete the blob and renew one in Storage?
    If we delete the blob for the EventHub manually and then run our server again. It worked as usual.
    But we can do it like this way manually, so is there any way to handle the exception in code to make the EventProcessorHost worked?
    Thanks so much!

    If we use different blob container name for different EventProcessorHost, is it a workaround for the issue?
       var
    eventProcessorHost = new
    EventProcessorHost(
                    hostName,
                    hubName,
                    consumerGroupName,
                    serviceBusConnectionString,
                    storageConnectionString,
    leaseContainerName);

  • When ipod has synched with library I find that extra copies of a whole album have been made on the ipod when onlu one exists in the iTunes library. How do I get rid of the extra copies without deleting from my library?

    When my ipod has synched with music library I am finding extra copies of whole albums (minus artwork) have been made on my ipod when only one exists in my library. How do I get rid of the extra copies without deleting the album from the library?

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • How to handle the lack of  unentered  values in a text field

    hello
    i am a bit new to Swing . i have created a form where i need the user to input details BUT HE DOES NOT HAVE TO ENTER VALUES IN ALL THE FIELDS .
    when i pass values to all the text fields it works well but when i fail to enter one of the fields it throws exceptions .
    how can i rectify this problem ?
    i really need ideas .

    hi,
    i think. i am having similar kind of errors. can you please have a look on this and advice me.
    * this part of code is used to save object */
         if (e.getSource () ==save)
              if(SName.getText().trim().length())!=0 && SNo.getText().trim().length())!= 0 && Smark.getText().trim().length() != 0)
                   StudentMark s = new StudentMark(SNo.getText(),SName.getText());
                   try{
                   s.setMark(Integer.parseInt(Smark.getText()));
                   v.addElement(s);
                   JOptionPane.showMessageDialog(null, "Saved Succesfully:" + s.toString());
                   catch (NumberFormatException e2)
                   JOptionPane.showMessageDialog(null," Record cannot saved-Entered Mark is not a Integer- Enter Number");
                   SName.setText(" ");
                   SNo.setText(" ");
                   Smark.setText(" ");
                   //SName.requestFocus();
    /* this part of code is used to save object */
    using this code to save marks,name and module no. on first time it works fine but on second time it put some white space before name,module no and mark. and if i treid to save it gives me exception msg as it not recognised mark with a white space.
    thnaks,

  • JWS not recognising the property when its value contains % character

    Hi All,
    We are seeing an issue with particular versions of Java Web Start like 1.5.0_15 and 1.6.0_06
    The issue which we are facing is that Java Web Start is not recognizing the properties which contains % character.
    For Example,.
    <property name='user' value='chandra%'/>
    <property name='version' value='1.1'</property>
    <property name='sessionId' value='afg4l5n55%bn3'/>
    <property name='cookie' value='abcdefghijk'/>
    The properties with % character are not getting loaded
    If I download the jnlp file, the property is there, if I choose show jnlp file in "javaws -viewer" it's not there.
    This was working fine before we upgraded.
    I would really appreciate if someone let me know whats happening.
    Thanks,
    Chandra

    acprasad wrote: We are seeing an issue with particular versions of Java Web Start like 1.5.0_15 and 1.6.0_06
    I am not surprised, based on ...
    >
    For Example,.
    <property name='user' value='chandra%'/>
    <property name='version' value='1.1'</property>
    <property name='sessionId' value='afg4l5n55%bn3'/>
    <property name='cookie' value='abcdefghijk'/>
    ..this invalid snippet. I suggest that you, and every other person with a JNLP problem, to validate the JNLP against a DTD or XSD. Invalid JNLP files are acted on by the plug-in, usually, to some extent.. The problem is that the behavior may change from JRE version to version.
    By the way, when posting code, or HTML or XML, it is usually better to use code tags by selecting the text and clicking the 'CODE' button above where you type.. E.G.
    <property name='user' value='chandra%'/>
    <property name='version' value='1.1'</property>
    <property name='sessionId' value='afg4l5n55%bn3'/>
    <property name='cookie' value='abcdefghijk'/>Edited by: AndrewThompson64 on Jun 5, 2008 12:16 PM

  • How to handle the right shifting of value

    Hi All,
    In graphical mapping I am having some values they are coming to rceiver in CSV file . In excel coloum when come to receiver side some getting shift to right side ,,, How can I handle this ?
    city=0
    col
        ++++++++++++0(wrong )
    0(correct)
    Plz suggest
    Regards
    Edited by: gangadhar kh on Mar 18, 2010 1:49 PM

    HI ,
    I getting the data in excel  there is one field
    in which nothing is coimg
    kkk              -
    LLLLLL
    nothing        -
    Value(000)
    but the problem is next to this field value shitfting KKK field coloum
    kkk              -
    LLLLLL
    Value(000)
    beacuse of this only my all values in coloum are getting shift frm right to left...
    Plz suggest
    Regards
    Edited by: gangadhar kh on Mar 19, 2010 7:35 AM

  • Please tell me the cases when I will use Call transaction/ Batch Session.

    Can you please tell me when I will use Call transaction or  Batch Session in the time of uploading data through BDC.
    Regards,
    Subhasish

    Hi subhasish,
    1. One of the main criteria is
    2. If error handling facility is required, then batch session is the best,
      otherwise if we use call transaction, then error handling code,
      has to be written in the program itself.
    3. Batch session provides lot of facilities to the user.
    regards,
    amit m.

  • How to hide the link when no data exists

    I have created a new page in inventory module here.I have developed a search page like if i query through organization all the items related to that are displayed in results table.I have introduced one more dummy colums called details with image and in property for that details i have implemented drill down details.
    When i click that details link i will go to next page to display lot details for the item.
    Here there are lot details for some items and some items dont have lot details.SWo the details button must be enabled for the items which have lot details only and for other it must be in disable state.
    Can any one tell me how to disable for the items which dont have lot details and enable for the it3ems which has lot details.
    Right now it is in enable state for all the items it was going to next page.
    I nedd to go to next p[age only if i have the related information for that item.
    How to do this type of scenario                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Please do not re-post. It would be easier to follow up a single thread.

  • How to handle the error when using Connection.setAutoCommit()

    I use Jboss's datapool to realize the connection to Sybase
    Database.And after connected to the database I wrote "con.setAutoCommit(false)" then the error occured.
    The error is "java.sql.SQLException: JZ0SJ: Metadata accessor information was not found on this database. Please install the required tables as mention ed in the jConnect documentation."
    I think it is because there is something wrong with the
    configuration of the database but can not handle it .So please
    help me,thank you!

    I use Jboss's datapool to realize the connection to
    o Sybase
    Database.And after connected to the database I wrote
    "con.setAutoCommit(false)" then the error occured.
    The error is "java.sql.SQLException: JZ0SJ: Metadata
    a accessor information was not found on this database.
    Please install the required tables as mention ed in
    the jConnect documentation."
    I think it is because there is something wrong with
    th the
    configuration of the database but can not handle it
    .So please
    help me,thank you!Most likely it means that your either DB or JDBC driver doesn't
    support transactional approach, I mean: commit(), rollback() functions, so it reports setAutoCommit(false) as errorneous situation.
    Paul

  • How to handle the battery when AC is connected to Satellite?

    Hi,
    I've just bought first Toshiba laptop, and want to get the best from the battery life, as the one on my last laptop is now buggered.
    My question is : If I indend to run the laptop almost always from the mains adaptor, is it possible or advisable to actually remove the battery all together so as not to subject the battery to repeated charging and discharging cycles.
    Thanks in advance.

    Hi
    I would also recommend removing the battery from the notebook if you use the notebook mostly with the AC adaptor.
    You should also 3 - 4 times charge and discharge completely the battery.
    This is necessary because the batteries support a memory effect.
    You said its your first Toshiba notebook. So I think you should take a look into the user manual which should be installed on the unit.
    In my user manual I have found many interesting information about the battery handling.
    So it could be interesting for you too.

  • How to handle the current row with radio button selection???

    Hi Everyone,
    I have one ADF page with one table and one "Find" button.
    I have created one new attribute with VARCHAR2(1) in the VO and dragged that attribute as first column in the table. And changed that first column to Radio Button to select only one row at a time.
    Upon clicking on the "Find" button i need to get the values of current selected row.
    How can i get the values of selected row?
    What code should i write to get the values of selected row in Method Binding of "Find" button?
    Any suggestions will be really useful.
    Thanks.

    Hello Kumar,
    I have some comments on your case.
    >
    I have created one new attribute with VARCHAR2(1) in the VO
    >
    1- You should create this attribute in the Entity object and then add it to the view object.
    2- Do you need that only one radio button is set at a time for all rows ? If yes then you need to handle the case when the user set more than one row and clear the value of the attribute for all other rows.
    >
    How can i get all the values of current row in backing bean method(method binding of Find method)?
    can u plz provide me the code for that?
    >
    If you mean by the current row is that the row with its value of the selected attribute is set (the radio button is set for that row), then you can write a method in the viewObjectImpl class and expose it to client interface and call it from your bean.
    here is an example based in Department table in HR schema.
    //This method is written in DepartmentsViewImpl   
    public Row getSelectedRadioRow(){
                //create a second row set to not impact the row set used in ADF
                RowSet duplicateRowSet = this.createRowSet("duplicateRowSet");
                //get the current row of the table to set it back after re-executing the VO
                DepartmentsViewRowImpl currentRow = (DepartmentsViewRowImpl)this.getCurrentRow();
                Row[] filteredRows = duplicateRowSet.getFilteredRows("IsSelected", "1");
                DepartmentsViewRowImpl row=null;
                if(filteredRows.length>0){
                    row = (DepartmentsViewRowImpl)filteredRows[0];
                    System.out.println("Department Name " + row.getDepartmentName());              
                this.setCurrentRow(currentRow);
                duplicateRowSet.closeRowSet();
                return row;           
            }

Maybe you are looking for