Friday, March 11, 2016



In some cases you might want to read the system date and get it into the ESB and perform an action based on the time. The easiest way to do this is by using the property mediator and using default synapse properties.

You can do this in the following manner.


<property name="StrigVal"
                   expression="get-property('SYSTEM_DATE')"
                   scope="default"
                   type="STRING"/>


A full proxy service that uses the default SYSTEM_DATE.



<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="Proxy"
       transports="http,https"
       statistics="enable"
       trace="enable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="StrigVal"
                   expression="get-property('SYSTEM_DATE')"
                   scope="default"
                   type="STRING"/>
         <log level="custom">
            <property name="StrigVal ==" expression="$ctx:StrigVal"/>
         </log>
      </inSequence>
      <outSequence>
         <log level="custom">
            <property name="StrigVal-out SEQ ==" expression="$ctx:StrigVal"/>
         </log>
      </outSequence>
      <endpoint>
         <address uri="http://www.mocky.io/v2/56e2821f2600003c35eaa2f8"/>
      </endpoint>
   </target>
   <description/>
</proxy>
                                

The Above Proxy will log the following.


INFO - LogMediator StrigVal-out SEQ == = 3/11/16 3:06 PM
Categories:

0 comments:

Post a Comment

Subscribe to RSS Feed Follow me on Twitter!