Collection: It is an object that represents a group of objects.
Java Collections Framework is all about how we store group of objects and manipulate them.
It reduces the programming effort and increases performance while providing high interoperability.
This post guides how to create a maven project from the scratch and integrate it with TestNG. If you are a beginner at test automation, this post may help you.
Paxos algorithm is used to achieve consensus among a distributed set of computers that communicate via an asynchronous network.
We will understand the Paxos Algorithm by taking a simple problem such as detecting Prime Numbers in a distributed environment.
In order to start the consensus, first, we need to have a coordinator node in our cluster. It is explained in my previous article how can we decide the master node in a distributed environment using the Bully Algorithm. You can check that here.
Once the master node is decided, it starts its work as described below.
This blog post explains the end to end implementation of the Bully Algorithm which is a leader election algorithm in Distributed Systems.
A distributed system is a collection of independent computers that appears to its users as a single coherent system.
These multiple nodes are physically separate but linked with each other. They communicate with each other to complete each others’ and one end goal.
Distributed Algorithms run in a Distributed System. We have two types of Distributed algorithms which are Leader Election Algorithms and Consensus Algorithms.
In a clustered system, Leader Election Algorithms helps nodes to decide who the leader of the system is. …
Assume that your actual Rest API gets a number of identical hits, but actually that Rest Endpoint expects only one hit in order to proceed with the rest of the work!
How to handle this?
In Python, we can handle the scenario by developing a proxy.
Assume that our actual API resides at ‘http://localhost:6001/response’
But we need to send only one request to this API, but actually it getting hit by 100 calls. In order to avoid this, we can make this simple trick.
Create another API as below and count the number of hits.
@app.route('/proxy', methods=['POST'])
def proxy():
with counter.get_lock():
counter.value += 1
unique_count = counter.value
url = 'http://localhost:6001/response'
if unique_count == 1:
data = request.get_json()
requests.post(url, …
We can invoke APIs using a request payload or sending them in the URL as query parameters.
We can do several operations using the property mediator with the query parameters.
We can check this using a simple property as below. Assume my URL is as below. We can check if all these query params exist in the URL. The query params in this URL are name, term, and amount.
http://localhost:8290/api?name=isruu&term=30&amount=250000
You can further read about Query Parameters from this doc.
Let’s look at the following scenario. Assume the user enters the customer name, term, and loan amount in the request as above. …
Using WSO2 Enrich mediator
Assume we need to copy a whole message context to a property for further use. As an example, if we use Amazon SQS Connector, we may need that message to send it to a Queue as the message body, but we need to pass it as a property. How can we achieve this?
Let’s assume that we are building a message which needs to be passed to the SimpleStockQuote. The request simply follows like this.
<m0:getQuote xmlns:m0="http://services.samples">
<m0:request>
<m0:symbol>WSO2</m0:symbol>
</m0:request>
</m0:getQuote>
Thinking from the ease of the user, we do not want the user to send this message as the input. Therefore we ask from the user only the value for the symbol parameter. …
By default XPath 2.0 functions are disabled in WSO2 EI. In this post, we will look at how can we use them in EI 6 and EI7.
[mediation]
synapse.enable_xpath_dom_failover="true"
synapse.xpath.dom.failover.enabled=true
Assume we get the following request payload from the user.
The QueueURL contains QueueId and the QueueName. Assume we need to extract only the QueueId which is ‘728847610545’.
We can simply substring the URL by using XPath 2.0 functions. …
We can build messages via sending parameters in the URL or as a payload as a POST request. In both ways, we can build a customized message using Payload Factory.
Starting SimpleStockQuote Service
./axis2Server.sh
3. Go to <PRODUCT-HOME>/samples/axis2Server/src/SimpleStockQuoteService folder and build it using the following command.
ant
Let’s move to our first scenario.
Below will be the payload that the user needs to send.
{
"companyName":"WSO2"
}
Below is the API. You can build the API using the WSO2 Integration Studio. …
This tutorial guides you on how to expose the data in a CSV file as a data service using WSO2 Integration Studio and WSO2 Micro Integrator.
About