5 Replies Latest reply on Aug 25, 2011 7:42 AM by RupakKhurana

    What Destination Name to use with DataServiceTransaction in Model Driven approach

    RupakKhurana Level 1

      Hello

      I am using Model Driven Approach where no destinations are configured in data-management-config.xml, it is done automatically. In my backend webapp, I want to persist some data and push the changes to the clients. While I can use DataServiceTransaction.createItem() but what destination name should I use? What is the default name of the destination created by model assembler?

       

      thanks

      RK

        • 1. Re: What Destination Name to use with DataServiceTransaction in Model Driven approach
          Rohit . Kumar Adobe Employee

          Hi Rupak,

           

          You should pass the destination name to DST. And by default, it is called <ModelName>.<NameOfEntity>

           

          Rohit

          1 person found this helpful
          • 2. Re: What Destination Name to use with DataServiceTransaction in Model Driven approach
            Ashish Vashisht Level 1

            The Destination Id is <ModelName>.<EntityName> (Note the dot . in between the two parts). If you have Flash Builder with the Data Services Modeller plugin installed, you can actually see the destination in the Destinations view, under DMS Destinations.

             

            I also wanted to note, if you run into issues calling Data Service Transaction on the server, you may want to try setting the Message Broker on the FlexContext like this:

             

            MessageBroker messageBroker = MessageBroker.getMessageBroker(null); //Pass in the Message Broker ID if you have changed it.
            FlexContext.setThreadLocalMessageBroker(messageBroker);

             

            then when you are done with the Data Service Transaction, you can call setThreadLocalMessageBroker() with null.

            1 person found this helpful
            • 3. Re: What Destination Name to use with DataServiceTransaction in Model Driven approach
              RupakKhurana Level 1

              Hi Ashish

              Now the Destination ID is correct but I get the following exception. Also tried setting the Message Broker on the FlexContext but same error. The code is as follows.

               

              Pls advise

               

              Rupak

               

               

                      MessageBroker messageBroker = MessageBroker.getMessageBroker(null); //Pass in the Message Broker ID if you have changed it.
                      FlexContext.setThreadLocalMessageBroker(messageBroker);

                       DataServiceTransaction dtx = DataServiceTransaction.begin(false); 
                       //DataServiceTransaction dtx = DataServiceTransaction.getCurrentDataServiceTransaction();
                       dtx.setSendChangesToAdapter(true);
                       Currency c1 = new Currency();
                       c1.setCurrencyCode("ABC");
                       c1.setCurrencyName("Dummy Currency");
                       c1.setCurrencyLastUpdated(new Date());
                       c1.setCurrencyId(new Integer(537)); 
                       dtx.createItem("TraderWorkStation.Currency", c1); 
                       dtx.commit();
                      
                       FlexContext.setThreadLocalMessageBroker(null);

               

               

              TWSServer08/24/2011 11:15:31.736 DEBUG Service.Data.Transaction Started non-jta data service transaction

              TWSServer08/24/2011 11:15:31.768 DEBUG Service.Data.Transaction Sending server message to adapter: Flex Message (flex.data.messages.DataMessage)

                  operation = create

                  id = {currencyId=537}

                  clientId = srv:91D4E7AE-B0DB-B0EA-681D-4404F4AC8E96

                  correlationId = null

                  destination = TraderWorkStation.Currency

                  messageId = srv:91D4E7AE-B0DB-B0EA-681D-4404F4AC8E96:0

                  timestamp = 1314198931739

                  timeToLive = 0

                  body = TraderWorkStation.Currency@238

              TWSServer08/24/2011 11:15:31.771 DEBUG Service.Data.General Before TraderWorkStation.Currency.createItem (

                  (TraderWorkStation.Currency) {currencyId=537} (14308998) {

                      currencyName = Dummy Currency

                      currencyCode = ABC

                      currencyId = 537

                      currencyLastUpdated = Wed Aug 24 11:15:31 EDT 2011

                  })

              TWSServer08/24/2011 11:15:31.797 DEBUG Endpoint.AMF Serializing AMF/HTTP response

              Version: 3

                (Message #0 targetURI=/1/onStatus, responseURI=)

                  (Typed Object #0 'flex.messaging.messages.ErrorMessage')

                    headers = (Object #1)

                    rootCause = null

                    body = null

                    correlationId = "7816F4B3-E6EC-B7CD-A98D-FC5EFF8A3646"

                    faultDetail = null

                    faultString = "The item of type, 'TraderWorkStation.Currency', passed to the assembler does not match the assembler's configured entity type, 'TraderWorkStation.package1.Currency'.  To convert 'flex.messaging.io.amf.ASObject' to a strong type automatically, set the item-class in the destination."

                    clientId = "91D4E4EF-9095-35C3-0E30-0059517696E5"

                    timeToLive = 0.0

                    destination = "AdminControlService"

                    timestamp = 1.314198931792E12

                    extendedData = null

                    faultCode = "Server.Processing"

                    messageId = "91D4EF9D-F0F1-D3D1-5F9B-2F636C098859"

               

              Message was edited by: RupakKhurana

              • 4. Re: What Destination Name to use with DataServiceTransaction in Model Driven approach
                Ashish Vashisht Level 1

                As Don mentioned in the other thread, you can use the ServerGeneratedEntities annotation to control this. For more information, see this documentation:

                http://help.adobe.com/en_US/LiveCycleDataServicesES/3.1/Developing/WS4976f0ec3ef482461096f 38112701857408-8000.html

                • 5. Re: What Destination Name to use with DataServiceTransaction in Model Driven approach
                  RupakKhurana Level 1

                  Ok, so far so good, but in my original code, I am using dtx.setSendChangesToAdapter(true) and expect that the createIte

                  m() would be persisted to the database. Is it not the case, while I see that the new item is sent to the client but it is not being written to the database.