WSO2 Integrator: How to setup FIX Initiator failover? - wso2

How can I configure a WSO2 Integrator FIX initiator endpoint which utilizes automatic session failover supported by Quickfix/J?
In Quickfix/J, it is possible to configure automatic failover of the initiator session using the FIX config file as follows (assuming two localhost FIX servers listening on ports 9997,9998)
[SESSION]
SenderCompID=SYNAPSE
TargetCompID=EXEC
SocketConnectHost=localhost
SocketConnectPort=9997
SocketConnectHost1=localhost
SocketConnectPort1=9998
ReconnectInterval=5
All examples in WSO2 documentation show FIX endpoints configured with a hardcoded host such as:
<send>
<endpoint>
<address uri="fix://localhost:9997?BeginString=FIX.4.4&SenderCompID=SYNAPSE&TargetCompID=EXEC"/>
</endpoint>
</send>
This pattern is not possible for us because the target FIX server is on a remote server with a hostname that is different per environment, so I never want to hardcore the target host like this.
Ideally I would like to do something like this:
<send>
<address uri="fix://<dynamic hostname>:9997?BeginString=FIX.4.4&SenderCompID=SYNAPSE&TargetCompID=EXEC"/>
// the endpoint representing the above FIX Session
// where the target host is dynamically defined
// and not hardcoded anywhere in my car application
</send>
On the receiver/listener side as a Proxy Service this works fine, because in the proxy service it lifts the configuration from the supplied initiator config URL parameter, so the failover happens "under the hood" by the FIX engine.
<parameter name="transport.fix.InitiatorConfigURL">quickfix.cfg</parameter>
However it doesn't look like it's possible to do the same when you are sending a message to the target FIX server.
Does anyone have a good suggestion or an example for how to achieve this?

As you are using a normal 'address endpoint' you should also be able to use the normal failover configurations: see https://docs.wso2.com/display/ESB500/Configuring+Failover+Endpoints for info.

Related

WSO2 EI - Handle SFTP errors and invoke Fault/error Sequence

I'm trying to write a SFTP location through a jms/http proxy. However when there is an error on SFTP endpoint (wrong password, network connectivity issue, remote Dir not exists) I want to trigger fault sequence and handle this error (Try some DLC kind of scenario). I found that fault Sequcence is not invoking for FTP errors unless you set OUT_ONLY=false. However WSO2 docs recommends set OUT_ONLY=true for ftp writes. Similar Question is asked here too. How to handle VFS proxy error in WSO2 EI 6.4?
If I set OUT_ONLY=false it triggers faultSquence for both failures and success FTP writes.
Any workaround to catch FTP errors and trigger faultSequence ?
You can define a responseAction in the endpoint configuration. Please refer to the following sample configuration. The responseAction spedifies when a response comes to a timed out request specifies whether to discard it or invoke the fault handler. Apart from defining the responseAction in the endpoint, you can replace the send mediator with the file connector and it will also invoke the fault sequence during an error.
<send>
<endpoint name="wms-fault-endpoint">
<address uri="vfs:ftp://admin:admin1#localhost:2121/testJ/out">
<timeout>
<duration>10000</duration>
<responseAction>fault</responseAction>
</timeout>
</address>
</endpoint>
</send>
[1]-https://docs.wso2.com/display/EI611/Endpoint+Error+Handling
[2]- https://docs.wso2.com/display/ESBCONNECTORS/File+Connector

wso2 inline configuration of activemq jms failover transport

ActiveMQ's failover transport can be configured in the URI:
http://activemq.apache.org/failover-transport-reference.html
in a proxy service, you can use:
<address uri="jms:/MyQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.provider.url=failover:(tcp://localhost:61616)?startupMaxReconnectAttempts=10&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
This works with one configuration parameter. However, I couldn't find a way to have multiple parameters. Let's say I also want to configure the timeout parameter. I tried:
<address uri="jms:/MyQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.provider.url=failover:(tcp://localhost:61616)?startupMaxReconnectAttempts=10&timeout=10&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
This doesn't work because the timeout parameter is not part of the provider.url parameter.
I also tried:
<address uri="jms:/MyQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.provider.url=failover:(tcp://localhost:61616)?startupMaxReconnectAttempts=10;timeout=10&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
This doesn't work because activemq doesn't support using ';' instead of '&' as a separator
I then tried
<address uri="jms:/MyQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.provider.url=failover:(tcp://localhost:61616)?startupMaxReconnectAttempts=10%26timeout=10&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
This doesn't work because wso2 doesn't url-decode the provider.url parameter before passing it to activemq.
How can I pass multiple parameters in activeMQ's failover transport configuration URI ?

WSO2 ESB webservice load balance

Is there a way for distributing services requests among different servers? The ideia is high avaiability for a webservice, controlled by wso2 esb. I'll have same service deployed in more then one server(jboss) and I intend wso2 handle this.
The option 'pinned servers', when creating custom proxy, can do this?
The "Pinned server" attribute controls the Proxy service deployment in Several servers. Sometimes We need to use a one CAPP file to deploy artifacts in several servers, but may require to deploy a proxy service artifact in Selected servers. So in this case "Pinned server" attribute can be used.
You can give a list of Synapse server names, where this Proxy Service should be deployed using pinnedServers attribute. It takes the server names separated by comma or space character. If there is no pinned server list, then the Proxy Service will be started in all server instances.
If a pinned server names list is given, it will only start in the given named Synapse server instances.
For your question "Is there a way for distributing services reuests among different servers?"
You can achieve this using a cluster setup with a Loadbalancers like nginex, httpd.
httpd
nginx
If you need to use pinned server option, you can add a property called pinnedServers property in proxy like below
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="myproxy"
transports="https,http"
pinnedServers="server1"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<address uri="http://www.google.com"/>
</endpoint>
</target>
<description/>
</proxy>
In here "server1" is synapse server name where this Proxy Service should be deployed using pinnedServers attribute.
Next you need to add synapse server instance name as following in axis2.xml according to above proxy
<parameter name="SynapseConfig.ServerName" locked="false">server1</parameter>
You need to restart the ESB to get the effect from the pinnedServers property.
Then you need to give the name to a Synapse server instance by specifying -DSynapseServerName= property when you execute the startup script, wso2server.bat or wso2server.sh
Please refer [1] as a reference of setting the pinnedServers property in proxy.
[1] https://docs.wso2.com/display/ESB403/Proxy+Services

How do I pass a dynamic parameter as a part of the URL of a REST service while using WSO2 ESB Proxy Service?

I am trying to simply host a REST service as a proxy service in WSO2 ESB. I am using Custom Proxy to do this. When I run the created proxy, I am not able to pass parameters to the proxy service at run time. How do I do this?
My REST service will be hit on a URL of format:http://ip:host/requestMapping/{name}
The parameter 'name' has to be passed from the UI through the ESB to the service through a proxy service hosted on the ESB. Can you help me with the steps to follow to make this work?
I tried using this page:
http://wso2.com/library/articles/2013/12/restful-integration-with-wso2-esb/
But that is for creating APIs which I have been successfully in creating. But I am unable to do this using Proxy services.
Basically in my program, when the user interacts with the UI, he enters a name as input. This name has to be passed to the proxy service hosted in the ESB which should forward this as a path variable to my REST service.
Right now, my service body is:
<inSequence>
<send>
<endpoint>
<http method="POST" uri-template="http://ip:port/resourceMapping/{uri.var.name}"></http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send></send>
</outSequence>
When I run this, instead of sending the name as entered by the user, it sends "uri.var.name" to the REST service. On the other hand, if I define a property tag and define a value for it and then do this, the REST service gets the value of the property that I have set. But I need this value to be sent dynamically by the user so I can't define property and value inside.
Please help me.
I think, the best approach is to use API in this case because the request to the ESB is REST and endpoint also accepting REST. This is the best practice.

WSO2 indirect Endpoint inside Failover Group

Is it possible to use an Indirect Enpoint inside the definition of a Failover Group endpoint?
I mean something like this:
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="failOver2">
<failover>
<endpoint key="LBEndpoint" />
</failover>
</endpoint>
Where LBEndpoint is a load balance endpoint defined and saved previously in the registry.
When i click on the Save button... all my configuration is lost and the fail over group comes back into this form:
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="failOver2">
<failover/>
</endpoint>
Is this a bug? Inside the WSO2 ESB documentation it says that all this is possible.
Can you try editing synapse configuration directly? That is, not using sequence editor UI. Go to sourceview and manually edit and point the endpoint key in failoverendpoint.