Skip to main content

Auditing And Logging Messages Using Events in IBM Integration Bus \ WebSphere Message Broker - Middleware News

In IBM Integration Bus \WebSphere Message Broker Message Flows , you can Audit and Log data using database procedures or SQL statements and calling them in ESQL Scripts or in Java Compute Nodes, but this Time in this tutorial you can Audit and log the data using Events.
We have two types of events:
  1. Transaction Events : Transaction start, Transaction end and Transaction Rollback and they can omitted by Input Nodes [ex. HTTPInput, SOAPInput, MQInput,...etc].
  2. Terminal Events : and It is available for All Nodes in the Message Flow.
Before We start we must Know that Events are Published to Topic With String Format :   
"$SYS/Broker//Monitoring//",
so we well create MQ Object to listen on this topic with "Subscription object".

Agenda :

  • Create Application with MonitoringService_MsgFlow.
  • Create Message Set and Event Message definition file.
  • Create Message Flow SubscribeAuditData to Fetch published Events From Queue.
  • Create Local Queues for the Sample Using WebSphere MQ Explorer.
  • Create Subscription to Subscribe the events publish in Topic used in Event process.
  • Test And Send The Data.
  1. Open IBM Integration Bus Toolkit , and Choose Integration Development prespective.
  2. Right Click on Application Development workspace  New-> Application or from File -> New - Application.


     
  3. In Application Name : "monitoring-sample", "monitoring-sample" Application is created.
  4. Right Click on "monitoring-sample" Application -> New -> Message Flow.


     
  5. In Message Flow Name : "MonitoringService_MsgFlow" and check on Broker Schema and type in Schema TextBox "provider", then Click "Finish".


     
  6. From The Toolbar, File -> New ->other, then Expand "Integration Bus Message Set Development"->Message Set, Then Click Next.

  7. In Message Set Name , And Project Name Give them "MonitoringSample_MsgSet", Then Click "Finish".
  8. Right Click on the Application and Choose "Project References" tab.


     
  9. Check on "MonitoringSample_MsgSet" Project To make it Part for the Application.
  10. Expand  "Message Sets" of the Application and Right Click on  "MonitoringSample_MsgSet" ->New->Message Definition File From ->IBM Supplied Message.

  11. From the Menu Choose "IBM Integration Bus Monitoring Event" then Click "Finish".




     
  12. Open The Message Flow "MonitoringService_MsgFlow" Then put : The Nodes :
    Node Type: Properties Wire
    MQ Input
    • Queue Name : TEST_QUEUE.IN
    • Message Domain : XMLNSC
    • Node Name :TEST_QUEUE.IN
    • Out Terminal -> In Process Message Compute
    • Failure + catch Terminal To Error Handler Compute Node.
    Compute Node
    • Module Name : ProcessMessage_Compute
    • Node Name :     Process Message
    • Out Termainl -> In MQ Output Node
    MQ Output
    • Queue Name : TEST_QUEUE.OUT
    • Node Name : TEST _QUEUE.OUT
    MQ Error
    • Queue Name : QUEUE_ERROR.OUT
    • Node Name   : QUEUE_ERROR.OUT
    Compute Node
    • Module Name : HandleErrorCompute
    • Node Name : Error Handler Compute
    • Out Terminal MQ Error Node.
    We have this Flow :


  13.  Right Click on "Process Message" Compute Node Then Click on "Properties".
  14. Go To "monitoring-sample"  , right click -> New -> ESQL File.
  15. Type File Name : "ErrorHandler.ESQL"
     
  16.  Type The Code Below in the File :


    BROKER SCHEMA util
    CREATE COMPUTE MODULE  ErrorHandler_Compute
       CREATE FUNCTION Main() RETURNS BOOLEAN
       BEGIN
           SET OutputRoot.XMLNC.result.result = InputExceptionList;
           RETURN TRUE;
       END;
    END MODULE;

     
  17. Add it To Error Handler Compute Node.
  18. Create Anther ESQL File With Name ProcessMessage.ESQL
  19. Add This Code to it :


    CREATE COMPUTE MODULE MonitoringService_MsgFlow_Compute
          CREATE FUNCTION Main() RETURNS BOOLEAN
           BEGIN
              CALL CopyMessageHeaders();
              CALL CopyEntireMessage();
        
               SET Environment.employee = InputRoot.XMLNSC.employee;
               RETURN TRUE;
            END;
         CREATE PROCEDURE CopyMessageHeaders() BEGIN
           DECLARE I INTEGER 1;
           DECLARE J INTEGER;
           SET J = CARDINALITY(InputRoot.*[]);
           WHILE I < J DO
             SET OutputRoot.*[I] = InputRoot.*[I];
             SET I = I + 1;
           END WHILE;
          END;
         CREATE PROCEDURE CopyEntireMessage() BEGIN
           SET OutputRoot = InputRoot;
          END;
    END MODULE;

     
  20. Use This ESQL Compute in Proccess Message Node.
  21. From "Monitoring" Tab -> Click it to view Event Tables.
  22. Click "Add" To add new Event.
  23. Select Event Source "Terminal In".
  24. In Data Location Click on "Add", Then "Edit".
  25. In XPath Editor : Type : $Environment/employee, then Press "Finish" , then Press Ok.
  26. Check on "Include biststream data in payload" and set the Content ->All and Encoding to base64binary.
  27. Then Press Ok.

  28. Create New Message Flow in Broker Schema "util" and Name it with "SubscribeAuditData_MsgFlow".
  29. Put the Nodes Like the Following table :

    Node Type Properties  Wire
    MQ Input
    • Node Name : QUEUE_EVENT_SUB
    • Queue Name : QUEUE_EVENT_SUB
    • Out Terminal -> Input Process Message.
    • Failure+Catch Terminals ->Error Handler Compute Node
    Compute Node
    • Node Name : Process Message.
    • Module Name : ProcessAuditData_Compute
    • Out Terminal : EVENT_QUEUE.OUT
    Compute Node
    • Node Name : Error Handler.
    • Module Name : ErrorHandler_Compute
    • Out Terminal : QUEUE_ERROR.OUT.
    MQ Output
    • Node Name : EVENT_QUEUE.OUT.
    MQ Output
    • QueueName : QUEUE_ERROR.OUT
    • Node Name : QUEUE_ERROR.OUT

  30. Create New ESQL File And Call it FetchEvent.ESQL.
  31. Put this Code Inside.



    BROKER SCHEMA util
    DECLARE wmb NAMESPACE 'http://www.ibm.com/xmlns/prod/websphere/messagebroker/6.1.0/monitoring/event';
    CREATE COMPUTE MODULE AuditData
          CREATE FUNCTION Main() RETURNS BOOLEAN
          BEGIN
            CALL CopyMessageHeaders();
            CALL CopyEntireMessage();
            SET OutputRoot.XMLNSC.ReplyData.wmb:event = OutputRoot.XMLNSC.wmb:event;
            DECLARE BodyMessageAsBlob BLOB ASBITSTREAM(OutputRoot.XMLNSC.ReplyData CCSID 1208);
            DECLARE BodyMessageASCHAR CHARACTER CAST(BodyMessageAsBlob AS CHARACTER CCSID 1208);
            -- You can put any code here if you like to store event in database

            DELETE FIELD OutputRoot.XMLNSC.wmb:event;
            DELETE FIELD OutputRoot.XMLNSC.ReplyData;
            SET OutputRoot.XMLNSC.Result.MessageData = BodyMessageASCHAR;
            RETURN TRUE;
           END;
           CREATE PROCEDURE CopyMessageHeaders() BEGIN
              DECLARE I INTEGER 1;
              DECLARE J INTEGER;
              SET J = CARDINALITY(InputRoot.*[]);
              WHILE I < J DO
                SET OutputRoot.*[I] = InputRoot.*[I];
                SET I = I + 1;
              END WHILE;
            END;
           CREATE PROCEDURE CopyEntireMessage() BEGIN
            SET OutputRoot = InputRoot;
           END;
    END MODULE;






     
  32. Then , Set This Module to ProcessMessage Compute Node in the Flow.
  33. For Error Handler compute Node Set the Moudle the previous Error Handler Compute Module we created before.
     
  34. From File ->New->Bar File Then Give it name MontiorSampleBar.bar.
  35. In Prepare window Choose "monitoring-sample" Application.
  36. In Build options , check all options and uncheck "Add workspace project source files".
  37. Click Build and Save.
  38. Deploy the bar to the Execution group.
  39. Open "terminal" or the cmd in IBM Integration Console. then type the command "


    mqsichangeflowmonitoring -e -k monitoring-sample -f provider.MonitoringService_MsgFlow -c active

     
  40. Open WebSphere MQ Explorer and Open Your Queue Manager, Then Expand Queues
  41. Right Click on Queues -> New -> Local Queue.
  42. In The Name Set : "TEST_QUEUE.IN", Then Next, Then Set "persistent" to "Default presistent". Then Click Finsh.



    Do The Similar Step with Queues :

    - TEST_QUEUE.OUT.         - QUEUE_ERROR.OUT.
    - EVENT_QUEUE.OUT.       - QEUEU_EVENT_SUB.


  43. In WebSphere MQ, Righ Click on "Subscriptions" -> New->Subscription.
    Note :
        Events are published to the topic with string Format

    "$SYS/Broker//Monitoring//",

     so we need Subscription object as listener on this topic to subscribed the published events.
     
  44. In The Subscription Name : "MONITORING_SUBSCRIPTION".
  45. Set Topic NameSYSTEM.BROKER.MB.TOPIC.
  46. Set the Topic String : As Format "$SYS/Broker//Monitoring//" In Our case:
    $SYS/Broker/IB9NODE/Monitoring/default/provider.MonitoringService_MsgFlow.
     
  47. Set Destination Queue Manager .
  48. Set Destination Name : QUEUE_EVENT_SUB we created above, Then Click Finish.


     
  49. Open "MonitoringService_MsgFlow", right click and "Test", change Body to "Edit as Text", then Copy this Message and paste it:

     
             101
             HAmdoon
             ahmad@taha.com
             2014-12-12
             AD_VP
     

 


  • Press Send Message .
  • Open WebSphere MQ Explorer then Browse Queues List Right click on "EVENT_QUEUE.OUT" and "Browse Messages ".
  • You well find the Message stored in The Queue.

  • Comments

    1. very nice,...............


      www.shayarihishayari.com

      www.funmazalo.com

      wwwshayarixyz.com

      www.everyindia.com

      ReplyDelete

    Post a Comment

    adsrerrapop

    Popular posts from this blog

    IBM Websphere MQ interview Questions Part 5

    MQ Series: - It is an IBM web sphere product which is evolved in 1990’s. MQ series does transportation from one point to other. It is an EAI tool (Middle ware) VERSIONS:-5.0, 5.1, 5.3, 6.0, 7.0(new version). The currently using version is 6.2 Note: – MQ series supports more than 35+ operating systems. It is platform Independent. For every OS we have different MQ series software’s. But the functionality of MQ series Default path for installing MQ series is:- C: programfiles\BM\clipse\SDK30 C: programfiles\IBM\WebsphereMQ After installation it will create a group and user. Some middleware technologies are Tibco, SAP XI. MQ series deals with two things, they are OBJECTS, SERVICES. In OBJECTS we have • QUEUES • CHANNELS • PROCESS • AUTHENTICATION • QUERY MANAGER. In SERVICES we have LISTENERS. Objects: – objects are used to handle the transactions with the help of services. QUEUE MANAGER maintains all the objects and services. QUEUE: – it is a database structure

    IBM Websphere MQ Reason code list / mq reason codes / websphere mq error codes / mq error messages

    Reason code list ================= The following is a list of reason codes, in numeric order, providing detailed information to help you understand them, including: * An explanation of the circumstances that have caused the code to be raised * The associated completion code * Suggested programmer actions in response to the code * 0 (0000) (RC0): MQRC_NONE * 900 (0384) (RC900): MQRC_APPL_FIRST * 999 (03E7) (RC999): MQRC_APPL_LAST * 2001 (07D1) (RC2001): MQRC_ALIAS_BASE_Q_TYPE_ERROR * 2002 (07D2) (RC2002): MQRC_ALREADY_CONNECTED * 2003 (07D3) (RC2003): MQRC_BACKED_OUT * 2004 (07D4) (RC2004): MQRC_BUFFER_ERROR * 2005 (07D5) (RC2005): MQRC_BUFFER_LENGTH_ERROR * 2006 (07D6) (RC2006): MQRC_CHAR_ATTR_LENGTH_ERROR * 2007 (07D7) (RC2007): MQRC_CHAR_ATTRS_ERROR * 2008 (07D8) (RC2008): MQRC_CHAR_ATTRS_TOO_SHORT * 2009 (07D9) (RC2009): MQRC_CONNECTION_BROKEN * 2010 (07DA) (RC2010): MQRC_DATA_LENGTH_ERROR * 2011 (07DB) (RC2011): MQRC_DYNAMIC_Q_NAME_ERROR * 2012 (07DC) (RC201

    IBM WebSphere MQ – Common install/uninstall issues for MQ Version on Windows - Middleware News

    Creating a log file when you install or uninstall WebSphere MQ WebSphere MQ for Windows is installed using the Microsoft Installer (MSI). If you install the MQ server or client through launchpad , MQPARMS or setup.exe , then a log file is automatically generated in %temp% during installation. Alternatively you can supply parameters on the installation MSI command msiexec to generate a log file, or enable MSI logging system-wide (which generates MSI logs for all install and uninstall operations). If you uninstall through the Windows Add/Remove programs option, no log file is generated. You should either uninstall from the MSI command line and supply parameters to generate a log file, or enable MSI logging system-wide (which generates MSI logs for all install and uninstall operations). For details on how to enable MSI logging, see the following article in the WebSphere MQ product documentation: Advanced installation using msiexec For details on how to enable system-w