I'm facing up to the load balance algorithm implementation for customizing the load balance endpoint.
On this documentation page:
http://docs.wso2.org/display/ESB470/Load-balance+Endpoint
I read:
Algorithm - Either a default "Round-robin" or custom loaded algorithm of the group. See more information about this algorithm in the article.
Where "article" is a link point to this page:
http://supunk.blogspot.it/2010/02/writing-load-balance-algorithm-for-wso2.html
But the referred article is not complete and doesn't tell anything about the algorithm development. Could anyone give me a valid example?
You can use below sample to send multiple request to share between diffent endpoint using RoundRobin algo.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestLoadBalance"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<endpoint>
<loadbalance algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService/"/>
</endpoint>
<endpoint>
<address uri="http://localhost:9001/services/SimpleStockQuoteService/"/>
</endpoint>
<endpoint>
<address uri="http://localhost:9002/services/SimpleStockQuoteService/"/>
</endpoint>
</loadbalance>
</endpoint>
</target>
<description/>
</proxy>
As the documentation specifies, the algorithm should be an implementation of org.apache.synapse.endpoints.algorithms.LoadbalanceAlgorithm
You need to write a class implementing LoadbalanceAlgorithm interface. You can refer the existing implementations RoundRobin, WeightedRRLCAlgorithm and WeightedRoundRobin classes found in org.apache.synapse.endpoints.algorithms package.
Then create a jar file with your class and add it to <ESB_HOME>/repository/components/lib folder and restart the server.
Now when adding a Load Balance Endpoint, select Other... for the Algorithm and provide the full classname of your custom algorithm. For example: org.apache.synapse.endpoints.algorithms.WeightedRoundRobin
Looking at
LoadBalanceAlgortihm it's not possibile to simply give it a dynamic list of endpoint.
Concerning LoadBalanceMambershipHandler and its implementation (Axis2 and Service)...it uses object like:
org.apache.axis2.clustering.management.GroupManagementAgent
and
org.apache.axis2.clustering.ClusteringAgent
so you have to configure your nodes in cluster using the axi2.xml inside /repository/conf/axis2 folder of your ESB.
Use the ESB registry to save the loadbalance enpoint in and then access it by code for adding it a new list of address endpoint.
Related
Hi I am trying to use Data Service Call. When I use it in any proxy service in wso2 I get an error Unknown mediator referenced by configuration element: dataServiceCall
https://apim.docs.wso2.com/en/latest/reference/mediators/dss-mediator/
I am following the link as mentioned above. Can someone guide me what am I doing wrong ?
Below is the code I have written
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="TestData" startOnLoad="true" transports="http https local" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<dataServiceCall serviceName="Hello">
</dataServiceCall>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
</proxy>
Probably this has to do with the version of the Integration Studio you are using. It seems the IDE is unable to find the DataServiceCall Mediator. First, try updating the Integration Studio referring this document. If that doesn't work, try using a newer version of the Integration Studio.
Once updated the Dataservicecall Mediator should be listed under the Mediators section.
You are calling a dataservice but you didn't initiate this dataservice project before,so you have to make a dataservice before calling this dataservice from the proxy service.After that a design of "dataServiceCall " will appear in the integration Studio.
I was looking into hazelcast and found some good integrations with springboot. However, I want to understand if that is it or if we need the hazelcast servers to make a prod ready implementation. Can some one point out a resouce where I can look at the setup
You can run Hazelcast in either an embedded mode -- where the Hazelcast cluster nodes are colocated with the application clients -- or in a client-server mode, where the Hazelcast cluster is separate from the application clients. Both can be used for production. Embedded is generally easier to get up and running quickly. Client-Server might be better if you want to be able to tune and scale the cluster independently of the application clients.
See https://support.hazelcast.com/hc/en-us/articles/115004441586-What-s-the-difference-between-client-server-vs-embedded-topologies-
The only change in application code to switch between architectures is the line of code that instantiates the client
Hazelcast.newHazelcastInstance(); // creates an embedded client instance
while
Hazelcast.newHazelcastClient(); // creates a server client instance
I'd recommend the reference manual as the definitive source on configuration options and how to achieve what you need
https://docs.hazelcast.org/docs/latest/manual/html-single/
I would recommend to go through the reference manual. But I would also like to share how I have deployed the hazelcast instances on production servers and how I have used it.
Step 1: Create a xml config file.
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast
xsi:schemaLocation="http://www.hazelcast.com/schema/config https://hazelcast.com/schema/config/hazelcast-config-3.9.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>"your_service_name"</name>
<password>"service_password_chosen"</password>
</group>
<properties>
<property name="hazelcast.partition.count">83</property>
</properties>
<management-center enabled="true" update-interval="3">--url--</management-center>
<network>
<join>
<multicast enabled="false"/>
<aws enabled="false"></aws>
<tcp-ip enabled="true">
<member>"internal ip of your instance"</member>
<member>"internal ip of other instance</member>
</tcp-ip>
</join>
</network>
<map name="*.ttl3hr">
<max-size policy="USED_HEAP_PERCENTAGE">3</max-size>
<eviction-policy>LFU</eviction-policy>
<statistics-enabled>true</statistics-enabled>
<backup-count>0</backup-count>
<async-backup-count>1</async-backup-count>
<read-backup-data>true</read-backup-data>
<time-to-live-seconds>10800</time-to-live-seconds> <!--3 hours-->
</map>
Step 2: Add #EnableCaching and add a bean in the file annotated with #Configuration.
#Bean
public CacheManager cacheManager(HazelcastInstance hazelcastInstance) {
return new com.hazelcast.spring.cache.HazelcastCacheManager(hazelcastInstance);
}
Step 3: Then you can annotate your methods with #Cacheable annotation.
#Cacheable(cacheNames = "your_cache_name")
public POJO foo(Parameter1 parameter1,
Parameter2 parameter2) {
return pojoRepository.findByParameters(parameter1, parameter2);
}
I’m exploring the use of topics and events in WSO2 ESB 4.8.1, I created a topic and subscribed to it the endpoint of one dataservice running in WSO2 WSAS(A), I supposed that if I published a message with the structure defined for the incoming message of one of A operations in the publish tool of the Topic Details console, the message would be sent to the supscriptor (A) and everything where going to work fine, but it don’t. Why?
I also create a proxy service with an event mediator and configured the event mediator with the name of the created topic. Then I Try the proxy service with an incoming message with the same structure explained before. I was expecting to at least get an incoming message in the WSAS Soap Tracer, but nothing happened.
Am I missing something?
The eventing infrastructure is based upon the WS-Eventing specification. Since you are using a WSDL based service as a subscriber of the topic and intend to invoke a specific operation of that service, I imagine it is failing because the SOAP message and/or SOAP action are incorrect because the message sent to the topic and the service are based around WS-Eventing and not your service.
I created the simple proxy below and subscribed it to a topic.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="LogSubMessage" transports="http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full" category="ERROR">
<property name="SERVICE" value="LogSubMessage"/>
</log>
</inSequence>
<outSequence><send/></outSequence>
</target>
</proxy>
I then sent a <test/> message to the topic.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ns:topic xmlns:ns="http://wso2.org/ns/2009/09/eventing/notify">topicname</ns:topic>
</soapenv:Header>
<soapenv:Body>
<test/>
</soapenv:Body>
</soapenv:Envelope>
As you can see in the message above, the message logged in the service contains WS-Eventing SOAP headers and the SOAP action was set to http://ws.apache.org/ws/2007/05/eventing-extended/Publish . If your data service requires that the SOAP header contain the name of the operation to invoke, then it would reject this request.
I would suggest creating a proxy service, similar to the the one above, that would subscribe to the topic. This service would set the correct SOAP action, perform any message transformations you need, and call your data service.
I have configured Tomcat 6 with in-memory session replication. I am also using IIS 7 (I know, I know) and the AJP connector via isapi_redirector. The cluster is working properly and I am able to replicate session attributes using the SessionExample in the examples war. The problem is that I am unable to do the same in my custom application. I have added the distributable tag to the web.xml file on both servers in my test cluster. However, I don't see any message in the logs mentioning the attributes getting sent to the cluster (I see them for SessionExample). The only primary differences that I can see in my app from the examples:
The examples war uses servlet 2.5. I am still required to use 2.4.
My application uses SSO and requires the user to login.
The application is a portal application.
Also, in the code of the application, I am setting a simple string in the attribute, so nothing fancy.
So, I was wondering if anyone has some tips to get this working?
Thanks
Here is the cluster section within of my server.xml:
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="6">
<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"/>
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.104"
port="45564"
frequency="500"
dropTime="10000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="4000"
autoBind="100"
selectorTimeout="7000"
maxThreads="6"
timeout="15000"/>
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"
timeout="70000"/>
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/apache-tomcat-6.0.37/war-deploy/war-temp/"
deployDir="/apache-tomcat-6.0.37/webapps/"
watchDir="/apache-tomcat-6.0.37/war-deploy/war-listen/"
watchEnabled="true"/>
<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
Sorry. I found the issue. I was expecting to see messages in the log regarding the creation of the session attributes. I didn't realize that the examples project had a session listener that was outputting the messages to the log. I was thinking that it was simply from the log level that I had set.
Thanks to anyone who read this post.
I am currently playing around with the WSO2 enterprise service bus, some cxf based webservices and mtom attachments.
Using SoapUI (MTOM enabled), I submit the following request to one backend service:
...
<incident>
....
<attachmentList>
<attachment>
<contentID>cid:soapui32.png</contentID>
</attachment>
</attachmentList>
</incident>
...
With MTOM enabled Raw data is
...
<attachmentList>
<attachment>
<contentID>
<inc:Include href="cid:soapui32.png" xmlns:inc="http://www.w3.org/2004/08/xop/include"/>
</contentID>
</attachment>
</attachmentList>
...
------=_Part_0_22113723.1360006252844
Content-Type: image/x-png; name=soapui32.png
Content-Transfer-Encoding: binary
Content-ID: <soapui32.png>
Content-Disposition: attachment; name="soapui32.png"; filename="soapui32.png"
......
So far, so good.
Now, as the next step, I create a WSDL based proxy service (WSO2 ESB 4.5.1) for this webservice.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="testService" transports="https,http" statistics="enable" trace="enable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<wsdl service="IncidentService" port="IncidentServicePort" uri="uri2myservicewsdl"/>
</endpoint>
</target>
<publishWSDL uri="uri2myservicewsdl"/>
<description></description>
</proxy>
enableMTOM is set to true in the axis2.xml, MTOM is enabled for the proxy service.
If I submit exactly the same request with the same attachment via SoapUI, the esb transforms the attachment to inline content (debug log):
DEBUG - Starting Activation Handler invocation. Incoming Message:
......
<incident>
<attachmentList>
<attachment>
<contentID>iVBORw0KGgoAAAANSUh.....</contentID>
</attachment>
</attachmentList>
</incident>
.....
</soapenv:Body></soapenv:Envelope>
{org.wso2.carbon.activation.module.ActivationHandler}
Where can I enable MTOM, so that the proxy doesnt transform it to inline content?
Many thanks in advance.
Workaround
Maybe someone is interested, even if it's just a workaround:
I had enabled MTOM and SwA attachments in the axis2.xml (wso2 esb conf directory).
As soon as I disabled SwA and only left MTOM enabled, attachments are not transformed to inline content any more.
Now SwA is disabled for all proxy services, but that's ok for the moment.
I will have another look at it later, maybe it's a bug.