SXI Forum

A place to collect usefull tips, tricks and implementation strategies.

You are not logged in.

#1 16-02-2020 11:35:16

StephanB
Member
Registered: 21-11-2018
Posts: 39

Adding a Heart Beat to X-ServiceBroker contracts

Adding a Heart Beat to X-ServiceBroker contracts to replace the one in the current configurations :
I have added a Heart Beat to a X-ServiceBroker contract by doing the following.

In the configuration you will need to do the following:

Connectors:

<Connector id="CreateHB" type="XML">
      <Connection xsi:type="sxi:XML">
        <sxi:Write>
          <sxi:SaveLocation>E:\SXI\XPress\XmlOut</sxi:SaveLocation>
          <sxi:FileName>X-HB~%UNIQUE%.xml</sxi:FileName>
          <sxi:Stylesheet>..\..\usr\stylesheets\HeartBeat_DOC.xsl</sxi:Stylesheet>
        </sxi:Write>
        <sxi:RetryDelay>60</sxi:RetryDelay>
        <sxi:WaitForWriteCompletion>10</sxi:WaitForWriteCompletion>
      </Connection>
      <sxi:ReturnCodes>
        <sxi:Success/>
        <sxi:RecoverableError/>
      </sxi:ReturnCodes>
</Connector>

The style sheets I have used 'HeartBeat_DOC.xsl'

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns="http://www.sxi.co.za/XMLSchema" xmlns:sxi="http://www.sxi.co.za/XMLSchema" exclude-result-prefixes="sxi">
    <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
    <xsl:template match="/">
        <XHb xmlns="http://www.sxi.co.za/XMLSchema">
            <XHeader>
                <XPress>
                    <Destination>
                            <xsl:if test="//dest">
                                <xsl:value-of select="//dest"/>
                            </xsl:if>
                            <xsl:if test="//sxi:Destination">
                                <xsl:value-of select="//sxi:Destination"/>
                            </xsl:if>
                    </Destination>
                </XPress>
            </XHeader>
            <MD>
                <xsl:if test="//md">
                    <xsl:value-of select="//md"/>
                </xsl:if>
                <xsl:if test="//MD">
                    <xsl:value-of select="//MD"/>
                </xsl:if>
                <xsl:if test="//Md">
                    <xsl:value-of select="//Md"/>
                </xsl:if>
                <xsl:if test="//sxi:MD">
                    <xsl:value-of select="//sxi:MD"/>
                </xsl:if>
            </MD>
            <Type>
                <xsl:if test="//type">
                    <xsl:value-of select="//type"/>
                </xsl:if>
                <xsl:if test="//Type">
                    <xsl:value-of select="//Type"/>
                </xsl:if>
                <xsl:if test="//TYPE">
                    <xsl:value-of select="//TYPE"/>
                </xsl:if>
                <xsl:if test="//sxi:Type">
                    <xsl:value-of select="//sxi:Type"/>
                </xsl:if>
            </Type>
        </XHb>
    </xsl:template>
    
</xsl:stylesheet>

Actions:

    <Action name="HeartBeat">
     
      <Mappings>
        <Create dataDefinition="GenerateHB" connectorId="CreateHB" source="../../XPress/XmlOut"/>
      </Mappings>
     
    </Action>

Data Definitions:

<sxi:DataDefinition name="GenerateHB">
      <sxi:Fields>
       
        <sxi:Field name="Destination">
          <sxi:Rules>
            <sxi:Default>127.0.0.1</sxi:Default>
          </sxi:Rules>
          <sxi:OutputField>Destination</sxi:OutputField>
        </sxi:Field>
		
        <!-- The MD is the Server Name -->
        <sxi:Field name="MD">
          <sxi:Rules>
            <sxi:Default>NRSSBLOG01</sxi:Default>
          </sxi:Rules>
          <sxi:OutputField>MD</sxi:OutputField>
        </sxi:Field>
       
        <!-- The Type is the X-ServiceBroker contract name Exp. 'DCXAfgri_Outgoing' with a prefix of 'X-ServiceBroker-'  -->
        <sxi:Field name="Type">
          <sxi:Rules>
            <sxi:Default>X-ServiceBroker-DCXAfgri_Outgoing</sxi:Default>
          </sxi:Rules>
          <sxi:OutputField>Type</sxi:OutputField>
        </sxi:Field>
       
      </sxi:Fields>
    </sxi:DataDefinition>

One you have done the above you will need to setup a Schedule in Service Broker to trigger the Heart Beat file. You can look at this post to do the a Trigger in X-ServiceBroker Schedule Configuring a Trigger in X-ServiceBroker Schedules

Entry Points in the ServiceBrokerTrigger.xml

<!-- ***************** Trigger for a X-ServiceBroker to create a Heart Beat doc ***************** -->        
        <EntryPoint name="Heartbeat_Client_PROD">
            <Format>
                <sxi:Transmission xsi:type="sxi:XmlTransmission">
                    <sxi:Destination>127.0.0.1</sxi:Destination>
                    <sxi:OutputMethod>
                        <sxi:TransmitMethod>Local</sxi:TransmitMethod>
                    </sxi:OutputMethod>
                </sxi:Transmission>
                <Action>HeartBeat</Action>
                <Provider>Client_PROD</Provider>
                <AdditionalElements>
                    <Element>HeartBeat</Element>
                </AdditionalElements>
            </Format>
        </EntryPoint>

        <!-- ***************** Triger for Client X-ServiceBroker to create a Heart Beat doc ***************** -->  
        <EntryPoint name="Heartbeat_Client">
            <Format>
                <sxi:Transmission xsi:type="sxi:XmlTransmission">
                    <sxi:Destination>127.0.0.1</sxi:Destination>
                    <sxi:OutputMethod>
                        <sxi:TransmitMethod>Local</sxi:TransmitMethod>
                    </sxi:OutputMethod>
                </sxi:Transmission>
                <Action>HeartBeat</Action>
                <Provider>Client</Provider>
                <AdditionalElements>
                    <Element>HeartBeat</Element>
                </AdditionalElements>
            </Format>
        </EntryPoint>

In the X-ServiceBroker Initialisation.xml file

<!-- ***************** HeartBeat triger for Client to check Service Broker ***************** -->      
      <Schedule name="Heartbeat_Client_PROD">
        <!-- The trigger will be triggered every 3 minutes -->
        <AT>*/3 * * * *</AT>
        <Action>
        <Path>E:\SXI\X-ServiceBroker\tasks</Path>
        <Command>ServiceBrokerTrigger.class</Command>
          <Arguments>HeartbeatClient_PROD</Arguments>
        </Action>
      </Schedule>
     
      <!-- ***************** HeartBeat triger for Client to check Service Broker ***************** -->      
      <Schedule name="Heartbeat_Client">
        <!-- The trigger will be triggered every 3 minutes -->
        <AT>*/3 * * * *</AT>
        <Action>
          <Path>E:\SXI\X-ServiceBroker\tasks</Path>
          <Command>ServiceBrokerTrigger.class</Command>
          <Arguments>HeartbeatClient</Arguments>
        </Action>
      </Schedule>

Once all is done you will have to add the Heart Beat Notifications for the FAILED and REPAIRED to X-Notify.
I have stated working on a configuration to replacing the X-Notify it still in working progress. Once I have it working correctly, I will add it to the Forum.

Last edited by StephanB (27-02-2022 09:49:47)

Offline

Board footer

Powered by FluxBB