Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Callbacks execution in queue

    Hi Isomorphic,
    I have question how are callbacks handled when using queue. Imagine following scenario:

    1. start queue
    2. call DS1.validateData with DSCallback1
    3. call DS2.validateData with DSCallback2
    4. send queue with RPCQueueCallback

    For sure RPCQueueCallback gets executed with all responses. But is there a way how to get executed also DSCallbacks for every separate DSRequest which was send inside the queue?

    #2
    Not sure what you're asking. In this scenario, the following callbacks will execute in the following order: DSCallback1, DSCallback2, RPCQueueCallback. So you seem to already have what you are asking for..

    Comment


      #3
      That is good news ... my problem is that DSCallbacks are not getting executed at all. Not sure what I am doing wrong.

      Do I need to send something specific in DSResponse? Now from the DMI I am sending just empty DSResponse, sometimes populated only with validation errors.

      I will try today to reproduce my problem in the showcase.

      Comment


        #4
        See the Error Handling overview - if you are returning an error and DSRequest.willHandleError is not set, it's expected that your callback would not be called.

        Comment


          #5
          yes, I noticed setWillHandleError ... I was using it set to true, but in case when status is STATUS_VALIDATION_ERROR, callback should be invoked even if it is set to false.

          I just made experiment on other place in the project, I think the problem is related only when calling validateData on DS.

          This code should be clear enough:
          Code:
          boolean wasQueuing = RPCManager.startQueue();
          Record record = new Record(valuesManager.getValues());
          getDataSource().validateData(record, new DSCallback() {
              @Override
              public void execute(DSResponse response, Object rawData, DSRequest request) {
                  System.out.println("validate callback");
              }
          }, new DSRequest());
          
          getDataSource().performCustomOperation("myCustom", record, new DSCallback() {
              @Override
              public void execute(DSResponse response, Object rawData, DSRequest request) {
                  System.out.println("custom callback 2");
              }
          }, new DSRequest());
          
          valuesManager.saveData(new DSCallback() {
              @Override
              public void execute(DSResponse response, Object rawData, DSRequest request) {
                  System.out.println("add callback");
              }
          });
          
          
          if (!wasQueuing) {
              RPCManager.sendQueue(new RPCQueueCallback() {
                  @Override
                  public void execute(RPCResponse[] responses) {
                      System.out.println("queue callback");
          
                  }
              });
          }
          The output is following:
          Code:
          custom callback 2
          add callback
          queue callback
          I was trying to run EE Showcase and reproduce it for you in SimpleQueuing example, but I was always getting outOfMemory exception during compilation.

          Comment


            #6
            We were not able to reproduce this issue. We've tested on 5.1d and 5.0p versions.
            Sample Code:
            Code:
            		final DataSource animalsDS = DataSource.get("animals"); 
            		final DataSource supplyItemDS = DataSource.get("supplyItem");
            
            		final ListGrid listGrid1 = new ListGrid();  
            		listGrid1.setWidth(600); 
            		listGrid1.setHeight(200);
            		listGrid1.setAlternateRecordStyles(true);  
            		listGrid1.setDataSource(supplyItemDS);
            		listGrid1.setAutoFetchData(true);
            
            		final ListGrid listGrid = new ListGrid();  
            		listGrid.setWidth(600);  
            		listGrid.setHeight(200);
            		listGrid.setAlternateRecordStyles(true);  
            		listGrid.setDataSource(animalsDS);
            		listGrid.setAutoFetchData(true);
            		listGrid.addRecordClickHandler(new RecordClickHandler() {
            
            			@Override
            			public void onRecordClick(RecordClickEvent event) {
            				boolean wasQueuing = RPCManager.startQueue();
            				ListGridRecord record = listGrid.getSelectedRecord();
            		        animalsDS.validateData(record, new DSCallback() {
            					@Override
            					public void execute(DSResponse dsResponse, Object data,
            							DSRequest dsRequest) {
            						System.out.println("1: validateData");
            					}
            		        }, new DSRequest());
            		        ListGridRecord record1 = listGrid1.getRecord(1);
            		        supplyItemDS.updateData(record1, new DSCallback() {
            					@Override
            					public void execute(DSResponse dsResponse, Object data,
            							DSRequest dsRequest) {
            						System.out.println("2: updateData");
            					}
            		        });
            		        if (!wasQueuing) {
            		            RPCManager.sendQueue(new RPCQueueCallback() {
            						@Override
            						public void execute(RPCResponse... response) {
            							System.out.println("3: queue callback");
            						}
            		            });
            		        }
            			}
                    });
                    VLayout vLayout = new VLayout();
                    vLayout.addMember(listGrid1);
                    vLayout.addMember(listGrid);
                    
                    vLayout.draw();
            The output was:
            Code:
            1: validateData
            2: updateData
            3: queue callback
            Could you test this code to see if you can reproduce your issue?.

            Regards,
            Isomorphic Software

            Comment


              #7
              I reproduced the problem with your code in SmartClient Version: v8.3p_2015-05-26/PowerEdition Deployment (built 2015-05-26)

              Is there any chance to fix it in 3.1?

              Comment


                #8
                3.1 / 8.3 is a couple of versions behind the latest and we can't always guarantee backporting of fixes that far.
                We'll have a developer take a look at whether this particular issue is something we can practically fix in 8.3 and let you know what we find.
                If it turns out to be too involved to fix we can probably suggest a workaround or similar. We'll follow up when we have more information.

                Regards
                Isomorphic Software

                Comment


                  #9
                  We've made a change to 3.1p which we believe will address this issue. Please try the next nightly build dated Sep 2 or above.

                  Regards
                  Isomorphic Software

                  Comment


                    #10
                    I saw only LGPL build, but no PowerEdition, which we use. Aren't you building all version?

                    Thanks for the fix, this will save us many troubles. Because only workaround would be to use custom operation instead, but custom operation is not validating against fields validators specified in DS. It can only invoke our DMI validation.

                    Comment


                      #11
                      We're looking into why the power build didn't get created - we'll let you know when a new build is available for you.

                      Comment


                        #12
                        The build is now available for download .

                        Regards
                        Isomorphic Software

                        Comment


                          #13
                          Yesterday I was trying to confirm that it is working, but I hit different problem after upgrading library.

                          I created separated thread for it. Please see: http://forums.smartclient.com/showthread.php?p=134231
                          Last edited by matus_b; 4 Sep 2015, 00:41. Reason: made a link

                          Comment

                          Working...
                          X