Monday, 5 August 2013

HTTP in Message Broker

HTTP nodes in Message Broker


The HTTP-Input node accepts a request and theHTTP-reply node  replies to the destination

Various HTTP nodes in Message Broker
HTTP Input
HTTP Request
HTTP Reply

Through HTTPInput node ,we can listen to HTTP requests from Clients.So,if we use HTTPInput node ,then our  flow becomes the HTTP Server which is exposing its service as Webser vice.
The path url is property will get the HTTP requests intended to this webservice.Sample could be /CustomerTest
Hence the HTTP client should send the requests to the HTTP server as http://<server_ip>:7080 /CustomerTest
7080 – is the port of broker http listener.It is biphttplistener
This is the only HTTP port available for Broker.So,if we want to call another HTTP Service,we need to differentiate it based upon the path url. Eg: /EmployeeTest
If we want,we can also enable http port of execution groups.
To view Brokerwide listener

mqsireportproperties MyBroker -b httplistener -o AllReportableEntityNames -r
(To disable Brokerwide Listener set startListener='false' in mqsichange properties)

HTTPListener
  uuid='HTTPListener'
  enableSSLConnector='false'
  threadPoolSize=''
  traceOverrideLevel=''
  traceOverrideSize=''
  traceLevel='none'
  traceSize='102400 KB'
  javaDebugPort=''
  startListener='true'
HTTPConnector
  uuid='HTTPConnector'
  address=''
  port='7080'
  allowTrace=''
  maxPostSize=''
  acceptCount=''
  bufferSize=''
  compressableMimeTypes=''
  compression=''
  connectionLinger=''
  connectionTimeout=''
  maxHttpHeaderSize=''
  maxKeepAliveRequests=''
  maxSpareThreads=''
  maxThreads=''
  minSpareThreads=''
  noCompressionUserAgents=''
  restrictedUserAgents=''
  socketBuffer=''
  tcpNoDelay=''
  enableLookups='false'
HTTPSConnector
  uuid='HTTPSConnector'
  algorithm='Platform Default'
  clientAuth='Platform Default'
  keystoreFile='Platform Default'
  keystorePass='********'
  keystoreType='Platform Default'
  truststoreFile='Platform Default'
  truststorePass='********'
  truststoreType='Platform Default'
  sslProtocol='Platform Default'
  ciphers='Platform Default'
  address=''
  port=''
  allowTrace=''
  maxPostSize=''
  acceptCount=''
  bufferSize=''
  compressableMimeTypes=''
  compression=''
  connectionLinger=''
  connectionTimeout=''
  maxHttpHeaderSize=''
  maxKeepAliveRequests=''
  maxSpareThreads=''
  maxThreads=''
  minSpareThreads=''
  noCompressionUserAgents=''
  restrictedUserAgents=''
  socketBuffer=''
  tcpNoDelay=''
  enableLookups='false'
=====================================================================
To view Executiongroup HTTP listener
mqsireportproperties MyBroker  -e default -o HTTPConnector -r
HTTPConnector
  uuid='HTTPConnector'
  userTraceLevel='none'
  traceLevel='none'
  userTraceFilter='none'
  traceFilter='none'
  port='0'
  address=''
  allowTrace=''
  maxPostSize=''
  acceptCount=''
  bufferSize=''
  compressableMimeTypes=''
  compression=''
  connectionLinger=''
  connectionTimeout=''
  maxHttpHeaderSize=''
  maxKeepAliveRequests=''
  maxSpareThreads=''
  maxThreads=''
  minSpareThreads=''
  noCompressionUserAgents=''
  restrictedUserAgents=''
  socketBuffer=''
  tcpNoDelay=''
  explicitlySetPortNumber=''
  enableLookups=''
  enableMQListener=''
  shutdownDelay=''
  allowCrossConnectorPolling=''
  autoRespondHTTPHEADRequests=''
=====================================================================
To switch to the embedded execution group-wide listener:
mqsichangeproperties MyBroker -b httplistener -o HTTPListener -n startListener -v false

mqsichangeproperties MyBroker -e default -o ExecutionGroup -n httpNodesUseEmbeddedListener -v true

--------------------------------------------------------------------------------------
To switch to the Broker-wide listener:

mqsichangeproperties MyBroker -b httplistener -o HTTPListener -n startListener -v true

mqsichangeproperties MyBroker -e default -o ExecutionGroup -n httpNodesUseEmbeddedListener -v false
--------------------------------------------------------------------------------------
How to check HTTP port assigned for an execution group?
C:\Program Files\IBM\MQSI\8.0.0.1>mqsireportproperties RadBroker -e default -o H
TTPConnector -a

HTTPConnector
  uuid='HTTPConnector'
  userTraceLevel='none'
  traceLevel='none'
  userTraceFilter='none'
  traceFilter='none'
  port='0'
  address=''
  allowTrace=''
  maxPostSize=''
  acceptCount=''
  bufferSize=''
  compressableMimeTypes=''
  compression=''
  connectionLinger=''
  connectionTimeout=''
  maxHttpHeaderSize=''
  maxKeepAliveRequests=''
  maxSpareThreads=''
  maxThreads=''
  minSpareThreads=''
  noCompressionUserAgents=''
  restrictedUserAgents=''
  socketBuffer=''
  tcpNoDelay=''
  explicitlySetPortNumber=''
  enableLookups=''
  enableMQListener=''
  shutdownDelay=''
  allowCrossConnectorPolling=''
  autoRespondHTTPHEADRequests=''
--------------------------------------------------------------------------------------
HTTP Asynchronous nodes
You can make HTTP requests and receive a response asynchronously using the HTTPAsyncRequest and HTTPAsyncResponse nodes.
HTTP is synchronous: a client issues a request and waits for the corresponding response before anything else is done.
But we can make the client to act for Asynchronous HTTP client as well.In this way,there wont be any performance issues.
Basically, The HTTP client is only aware of a synchronous call.

Various scenarios of client connections:
1)Same client opening many number of connections to HTTP Server (HTTP URL: http://<server_ip>:7080 /CustomerTest)

2)Multiple clients opening multiple number of connections to HTTP Server :- same url (HTTP URL: http://<server_ip>:7080 /CustomerTest)

Workload balancing can be achieved via Load Balancer
If  I have multiple HTTP clients want to communicate with 2 brokers in load balanced way,but there is only one url, HTTP URL: http://<server_ip>:7080 /CustomerTest ,both the brokers are listening at same port.
When there is no load balancer,the client will have an url set at their request.So,only either one of the broker can be set at the url path.
In the case,if we use load balancer,then we can url the load balancer ip at the HTTP request url of HTTP client.By this way we can route the requests to both the brokers as the load balancer will act as network dispatcher.
Moving HTTP connection processing away from broker by using a proxy
The proxy is a servlet engine running inside Websphere Application Server just like Message broker internal process.
Message broker biphttpistener can support maximum upto 1200 concurrent sessions.
If we want more than 1200 sessions,then we can go for proxy engine.
Proxy engine is capable of handling more number of concurrent sessions than the default broker http listener.
HTTP Persistent and Non-Persistent connections
When HTTP request is made from a client,a new TCP connection is opened from client to Server.Once the response is sent by HTTP server through this TCP connection,the connection is terminates.For the next request from the same client ,a new TCP connection is opened.This is called non-persistent connections.This is also called as Short-lived connections.If the clients want to make individual connections then this type of connections can be choosen.But considering the memory and resource utilisations due to session creations ech and everytime would be a overhead.This could be preferred when many number of clients want to have individual connections with HTTP server.
For non-persistant connections,there may be ‘n’ number of clients connecting to the HTTP server.We can restrict the maximum number of concurrent connections by limiting ‘maxthreads’  property.Default is 250.
Command to change is: mqsichangeproperties MyBroker -b httplistener -o HTTPConnector -n maxThreads -v 2000
But machine resources, such as amount of addressable memory, determine the absolute maximum number of concurrent HTTP client connections that you can make to Message Broker, and these resources may be exhausted before the maxThreads limit is reached.
Increase the heap size of the JVM running within the biphttplistener process to let the JVM allocate more threads for the incoming connections. The default setting for the listener JVM is 192 MB, but you should increase it to 512 MB when dealing with large numbers of concurrent connections. To change the value, modify the Message Broker registry.
(http://www.ibm.com/developerworks/websphere/library/techarticles/0608_braithwaite/0608_braithwaite.html)
Hence always better to prefer HTTP persistent connections.This is also called as Long-Lived connections.This can be preferred when small number of clients want to have high volume of throughput from HTTP server.(When small number of clients are there,there will be small number of connections opened.But they are opened for a long time to serve all the requests instantly through the TCP session path).
There is  a property called maxKeepAliveRequests that specifies how many number of requests can be made in a single connection at the maximum.Default is 100. The next request the client sends creates a new socket and again can send up to 100 requests.        
Command to change this property according to our requirement
mqsichangeproperties MyBroker -b httplistener -o HTTPConnector -n maxKeepAliveRequests -v 0.




No comments:

Post a Comment