Showing posts with label ESB. Show all posts
Showing posts with label ESB. Show all posts

Thursday, September 12, 2013

Why I need a port.mapping property when clustering WSO2 API Manager/ WSO2 ESB?

In a dynamically clustered set-up where you front a carbon instance using a WSO2 ELB, it is a responsibility of a Carbon server to send its information to ELB. You can visualize this as a "Member object somehow getting passed to ELB from Carbon server instance". In Carbon server's clustering section, under properties, you can define any Member property. This way, you can let ELB know about the information other than the basic ones. What are the basic information, you might think. Typically those are host name, http port, https port etc.

WSO2 ESB, WSO2 API Manager etc. are bit special w.r.t. ports since they usually have 2 http ports (compare to 1 http port of WSO2 AS). Hence, here we have to somehow send this additional information to ELB. Easiest way to do that is by setting a member property. Here, we use port.mapping property. Also, in order to front these special servers we need 2 http ports in ELB too, which are exposed to outside. There's a deployment decision to be made here, i.e. which http port of ELB should map to which http port of the server (i.e. servlet http port or Nhttp http port). With that in mind, let me explain, how you should use this port.mapping property.
Let me consider only the http scenario. Say, in your API-M instance, you have used 8280 as the Nhttp transport port (axis2.xml) and 9763 as the Servlet transport port (catalina-server.xml). Also ELB has 2 http ports one is 8280 and the other is 8290. Imagine there's a Member object, and in this case Member's http port would be 8280 (usually the port defined in axis2.xml gets here). But since ELB has 2 ports, there's no way to correctly map ports, by only specifying Member's http port. There arises the importance of port.mapping property. You have to think this property from the perspective of ELB.

<property name="port.mapping.8290" value="9763"/>


Let's assume we define the above property, now this means, if a request comes to ELB, in its 8290 port (see... we're thinking from ELB's perspective), forward that request to the 9763 port of the Member. Having only this property is enough, we do not need following property,

<property name="port.mapping.8280" value="8280"/>

Let me explain why. The logic was written in a way, that port.mapping properties get higher precedence over the default ports. This means, that when a request comes to ELB, ELB will first check whether the port it received the request from, is specified as a port.mapping property. If it is, it will grab the target port from that property. If not, it will send the request to the default http port. Hence, if a request received to the 8280 port of ELB, it will be automatically get redirected to 8280 port of the Member (since it's the http port of Member).

Similarly, we should define a mapping for https servlet port.

Hope someone find this useful.

Thursday, September 5, 2013

Checking the non-existent of a property using WSO2 ESB 4.6

You can't simply do a string regex matching, if you are to check the non-existence of a property. What you could do is to leverage the boolean Xpath function [1], within a filter mediator.

Please see the following sample proxy configuration:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="TEST" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <filter source="boolean(get-property('accept'))" regex="false">
            <then>
               <log level="custom">
                  <property name="*********" value="NULL Property Value"/>
               </log>
            </then>
            <else>
               <log level="custom">
                  <property name="*********" value="NOT NULL Property Value"/>
               </log>
            </else>
         </filter>
         <send/>
      </inSequence>
      <outSequence>
         <log/>
         <send/>
      </outSequence>
   </target>
   <description></description>
</proxy>
                             

Hope this will save some amount of time of quite a bit of you :-)

[1] http://www.w3.org/TR/xpath/#function-boolean

Friday, March 2, 2012

Documentation on WSO2 ESB's Connection Debug Object's logs

This is a documentation I created upon a Client's request. Should thank Hiranya for helping me out on this.

A connection debug object would be accumulated during request processing, but make use only if the connection encounters issues during processing.

Abbreviations

C2E: Client to ESB
E2C: ESB to Client
E2S: ESB to back-end Server
S2E: back-end Server to ESB


Log
Meaning
C2E-Req-ConnCreateTime
Time that the client created a connection with ESB.
C2E-Req-StartTime
Time that the ESB started processing the client request.
C2E-Req-EndTime
Time that the ESB finished processing the client request.
C2E-Req-URL
This is the request URI obtained from the request line of a request from client to ESB. The Request-URI is a Uniform Resource Identifier and identifies the resource upon which to apply the request. [1]
C2E-Req-Protocol
This is the protocol version obtained from the request line of a request from client to ESB.
C2E-Req-Method
This is the method token obtained from the request line of a request from client to ESB. (eg: GET, POST etc. [1])
C2E-Req-IP
Remote Client IP address where the request came from.
C2E-Req-Info
HTTP header of the request from client to ESB.
E2C-Resp-Start
Upon the request from client, ESB sends out a response back to the client. This is the time that the ESB started to send the response.
E2C-Resp-End
This is the time that the ESB completed sending the response.
E2S-Req-Start
Start time of the last request sent from ESB to a back-end server.
E2S-Req-End
Completion time of the request sent from ESB to a back-end server.
E2S-Req-ConnCreateTime
Time that the ESB created a connection with a back-end server.
E2S-Req-URL
URI of the back-end service (EndpointReference) that the last request is headed to.
E2S-Req-Protocol
This is the protocol version obtained from the request line of the last request from ESB to back-end server.
E2S-Req-Method
This is the method token obtained from the request line of the last request from ESB to back-end server. (eg: GET, POST etc. )
E2S-Previous-Attempts
This provides details on the previous request sent by ESB to the back-end server.
S2E-Resp-Start
Time that the ESB receives a response from a back-end server.
S2E-Resp-End
Time that the ESB complete processing a response from a back-end server.
S2E-Resp-Status
This is the status line of the response received by the ESB. The first line of a Response message is the Status-Line, consisting of the protocol version followed by a numeric status code and its associated textual phrase, with each element separated by SP characters.
S2E-Resp-Info
HTTP header of the response from the back-end server to ESB.
Total-Time
(E2C-Resp-End) - (C2E-Req-StartTime)
Svc-Time
(S2E-Resp-End) - (E2S-Req-Start)
ESB-Time
(Total-Time) - (Svc-Time)

  • You can find conversion patterns of logs etc. in “log4j.properties” file located at “{$ESB_HOME}/lib” folder.
  • You can find log files inside “{$ESB_HOME}/repository/logs” folder.
  • You can see HTTP headers and messages if you add “log4j.logger.org.apache.synapse.transport.nhttp.wire=DEBUG” line into your “log4j.properties” file.
  • You can set the log level of org.apache.synapse to DEBUG, to enable debugging for mediation.
  • Please see [2] for various log4j conversion patterns.

References