Show TOC Anfang des Inhaltsbereichs

Hintergrunddokumentation Transaktionen im asynchronen Sender-/Inbound-Message-Fluss Dokument im Navigationsbaum lokalisieren

In der Message-Verarbeitung aus Sender/Inbound-Richtung sollten Sie folgende Schritte durchführen:

...

       1.      Modul-Prozessor-Lookup und TransactionManager-Lookup.

       2.      Überprüfung, ob die externe Message-ID bereits im MessageIDMapper gespeichert ist

       3.      Anlegen des neuen Inbound XI-Message-Objekts oder wenigstens der ID für die neue XI-Message

       4.      Starten einer neuen LUW

       5.      Aufruf des Modul-Prozessors: Die beteiligten Module dürfen keine Commit für die LUW durchführen. Sie dürfen jedoch in Fehlersituationen Exceptions ausgeben.

       6.      Anlegen eines Mappings mit dem MessageIDMapper zwischen der externen Message-ID und der XI-Message-ID für die neue gesendete Message.

       7.      Commit der LUW: Die Adapter-Framework Messaging Service-Queues und das Message-ID Mapping werden gemeinsam ausgeführt. So kann das Commit für das externe Protokoll später ausgeführt werden. Duplikate werden durch die vorherige Überprüfung der externen Message-ID bemerkt.

       8.      Commit der Verarbeitung des externen Protokolls, falls es lokale Transaktionen unterstützt.

Im Fehlerfall wird das Commit nicht durchgeführt sondern ein Rollback der LUW vorgenommen.

Beispiel

Im Beispiel sind die einzelnen Schritte angegeben:

public synchronized void onMessage(Message message) {

...

   try {

      // Step 1: Lookup and access the XI AF MP

      if (moduleProcessor == null) {

         String moduleProcessorLookupName = (String)
            parameter.get("moduleProcessorLookupName");

    ModuleProcessorLocalHome moduleProcessorLocalHome =   (ModuleProcessorLocalHome)
            context.lookup(moduleProcessorLookupName);

    moduleProcessor = (ModuleProcessorLocal) moduleProcessorLocalHome.create();

      }

      // Lookup the J2EE TxMgr to begin a LUW inclusive the XI AF MS for EO processing

      if (!txManagerIsInitialized) {

    txManagerLookupName = (String) parameter.get("txManagerLookupName");

    transactionManager = (TransactionManager)context.lookup(txManagerLookupName);

    txManagerIsInitialized = true;

      }

      // Step 2: First check whether this message was already received in case of EO(IO)

      String qos = (String) parameter.get(WorkerImpl.ATT_XIQualityOfService.name);

      if ( (qos.equalsIgnoreCase("ExactlyOnceInOrder")) ||

      (qos.equalsIgnoreCase("ExactlyOnce")) ) {

         String hexxmbmsgid = null;

    if ((hexxmbmsgid = messageIDMapper.getMappedId(jmsmsgid)) != null) {

       //Just ignore the message, commit it if necessary and return

       externalSession.commit();

       return;

         }

      }

      // Step 3: Create the XI message ID. This ID is used later in den modules and set

      // as GUID of the resulting new XI message. It must be consistent for the audit log
      // entries

      IGUID xmbmsgid = GUIDFactory.getInstance().createGUID(IGUID.VERSION_TIME);

      // Step 4: Start joined LUW

      try {

         transactionManager.begin();

      }

      catch (Exception e) { ... }

      // Step 5: Forward the JMS message to the XI AF MP

      ModuleData inputModuleData = new ModuleData();

      inputModuleData.setPrincipalData(message);

      inputModuleData.setSupplementalData("my.xmbmsgid", xmbmsgid);

      ModuleData outputModuleData = moduleProcessor.process(handler.getName(),
        inputModuleData);

      // Step 6: Save message ID mapping for duplicate recognition and PMI logging

      // PMI logging is triggered inside the messageIDmapper

      messageIDMapper.createIDMap(jmsmsgid, xmbmsgid.toHexString(),
         System.currentTimeMillis() + 1000*3600*24);

      // Step 7: Commit data base (XI AF MS queue insertion)

      try {

    transactionManager.commit();

      }

      catch (Exception e) { ... }

      // Step 8: Please note: Even if the system breaks between these two commits

      // the message won't be processed twice and EO is guaranteed.

      // This is done by saving the external message ID in the messageIDMapper

      externalSession.commit();

   } catch (Throwable throwable) {

      TRACE.catching(SIGNATURE, throwable);

      TRACE.warningT(SIGNATURE, JMSCategories.JMS_ROOT,
         "XI inbound processing failed. Rollback DB and external. Message” +
         “ is not lost, will be retried later.");

      transactionManager.rollback();

      externalSession.rollback();

   }

 

Ende des Inhaltsbereichs