In a simple scenario it is possible to implement a Proxy service which the client sees and calls to, a message store which stores those messages in a JMS queue and a message processor which fetches those messages and send to the defined endpoint.
We can implement a scenario which uses more than one queues and more than one message stores to put messages into those queues and more than one message processors to fetch from queues and serves one backend endpoint. Here we will have to use more than one proxy service in ESB and the requests coming in can be load balanced to which proxy it should go and which ESB node it should go.
Here I'm using three proxy services in two ESB nodes. The load balancing to each proxy needs to be done from the client side. But the load balancing to each ESB node will be happened by the ELB.
First you have to configure a ESB Cluster load balanced by a WSO2 ELB and with JMS transport enabled with a WSO2 MB. After that you can use the following synapse configurations to implement the scenario.
One set of Proxy, Store, Processor, Endpoint configuration of ESB node 1;
Proxy;
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Proxy1"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="OUT_ONLY" value="true"/>
<property name="target.endpoint" value="logndrop"/>
<store messageStore="JMSMS"/>
</inSequence>
</target>
</proxy>
Endpoint;
<?xml version="1.0" encoding="UTF-8"?>
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="logndrop">
<address uri="http://localhost:9773/as/services/LognDrop"/>
</endpoint>
Message Store;
<?xml version="1.0" encoding="UTF-8"?>
<messageStore xmlns="http://ws.apache.org/ns/synapse"
class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore"
name="JMSMS">
<parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
<parameter name="java.naming.provider.url">repository/conf/jndi.properties</parameter>
<parameter name="store.jms.destination">JMSMS</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
</messageStore>
Message Processor;
<?xml version="1.0" encoding="UTF-8"?>
<messageProcessor xmlns="http://ws.apache.org/ns/synapse"
class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor"
name="Processor1"
messageStore="JMSMS">
<parameter name="max.delivery.attempts">4</parameter>
<parameter name="interval">4000</parameter>
</messageProcessor>
The other set of Proxy, Store, Processor, Endpoint configuration of ESB node 1;
Proxy;
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Proxy2"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="OUT_ONLY" value="true"/>
<property name="target.endpoint" value="logndrop"/>
<store messageStore="JMSMS2"/>
</inSequence>
</target>
</proxy>
Endpoint;
<?xml version="1.0" encoding="UTF-8"?>
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="logndrop">
<address uri="http://localhost:9773/as/services/LognDrop"/>
</endpoint>
Message Store;
<?xml version="1.0" encoding="UTF-8"?>
<messageStore xmlns="http://ws.apache.org/ns/synapse"
class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore"
name="JMSMS2">
<parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
<parameter name="java.naming.provider.url">repository/conf/jndi.properties</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.jms.destination">JMSMS2</parameter>
</messageStore>
Message Processor;
<?xml version="1.0" encoding="UTF-8"?>
<messageProcessor xmlns="http://ws.apache.org/ns/synapse"
class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor"
name="Processor2"
messageStore="JMSMS2">
<parameter name="max.delivery.attempts">4</parameter>
<parameter name="interval">4000</parameter>
</messageProcessor>
This configuration needs to be synced with one other esb node in a esb cluster. The requests needs to be load balanced to each proxies by the client. And each of these messages will be load balanced to each ESB node in the cluster by the ELB. In my implementation I haven't used a ELB so that I had to load balance the requests to each esb nodes too by the client. Also I used three Proxy services, three Message Stores and Three Message Processors which talks to the same backend. Here only two are mentioned.
The backend service is a Axis2 Service which prints the incoming message and forget it.
public class LognDrop {
public void logndrop(String value) {
System.out.println("Value is:" + value);
}
}
Service can be found at;
https://svn.wso2.org/repos/wso2/trunk/commons/qa/qa-artifacts/app-server/LognDrop.aar
An Apache Jmeter project is the client which sends a string value to the proxy services. So that finally we can see how the requests are processed.
The Jmeter script can be found at;
https://svn.wso2.org/repos/wso2/trunk/commons/qa/qa-artifacts/app-server/jmeter-tests/InvokeLognDrop.jmx
Results;
You can enable DEBUG logs for ESB JMS Message Processors by putting the following entry in {ESB_HOME}/repository/conf/log4j.properties
#JMS Message Processor log
log4j.logger.org.wso2.carbon.jmsms.MSMPLog=DEBUG
so that you can see the execution in the ESB side as following;
[2013-07-10 12:39:42,416] DEBUG - MSMPLog [JMSMS] Storing[1] MessageID:urn:uuid:d3e97693-9b07-46e4-a7c9-4b108965a188
[2013-07-10 12:39:42,439] DEBUG - MSMPLog [JMSMS] Storing[2] MessageID:urn:uuid:e9e391cb-3778-4e9e-8490-99d68dea4a9d
[2013-07-10 12:39:42,492] DEBUG - MSMPLog [JMSMS2] Storing[1] MessageID:urn:uuid:d0b76a30-9107-4db9-b159-8b70b707d29b
[2013-07-10 12:39:42,510] DEBUG - MSMPLog [JMSMS2] Storing[2] MessageID:urn:uuid:7c4579bf-cdb5-4173-a961-36c7cbeb2299
[2013-07-10 12:39:42,567] DEBUG - MSMPLog [JMSMS3] Storing[1] MessageID:urn:uuid:289e4073-1199-4805-9c32-46d689902059
[2013-07-10 12:39:42,584] DEBUG - MSMPLog [JMSMS3] Storing[2] MessageID:urn:uuid:f942d2c1-14b1-4867-8727-f745af147a6b
[2013-07-10 12:39:42,590] DEBUG - MSMPLog [JMSMS] Storing[3] MessageID:urn:uuid:32aa8ac0-470c-4293-8d36-1682df482a2a
[2013-07-10 12:39:42,658] DEBUG - MSMPLog [JMSMS] Storing[4] MessageID:urn:uuid:962808ff-19bf-4d86-a4b1-2e7e0b4363ec
[2013-07-10 12:39:42,672] DEBUG - MSMPLog [JMSMS2] Storing[3] MessageID:urn:uuid:62b3cfe6-f947-49e2-a43f-a39d09970147
[2013-07-10 12:39:42,716] DEBUG - MSMPLog [JMSMS2] Storing[4] MessageID:urn:uuid:d463555f-6955-450a-9b84-d2d2a6749712
[2013-07-10 12:39:42,731] DEBUG - MSMPLog [JMSMS3] Storing[3] MessageID:urn:uuid:56221673-e159-4604-8baf-31193fb0536e
[2013-07-10 12:39:42,747] DEBUG - MSMPLog [JMSMS] Storing[5] MessageID:urn:uuid:76ad4a31-91f4-4372-a851-2189723c485c
[2013-07-10 12:39:42,783] DEBUG - MSMPLog [JMSMS3] Storing[4] MessageID:urn:uuid:087fba00-7d6f-4138-8fa8-06c1549b508a
[2013-07-10 12:39:42,845] DEBUG - MSMPLog [JMSMS] Storing[6] MessageID:urn:uuid:5ba9bdba-9ada-48ae-ac33-41bcd22d4b73
[2013-07-10 12:39:42,848] DEBUG - MSMPLog [JMSMS2] Storing[5] MessageID:urn:uuid:7af16cc1-ee29-4f16-addc-0d9ae4b51f9b
[2013-07-10 12:39:42,921] DEBUG - MSMPLog [JMSMS2] Storing[6] MessageID:urn:uuid:3d802cb7-a029-4a59-b8b3-4c1b1074d4ab
[2013-07-10 12:39:42,971] DEBUG - MSMPLog [JMSMS] Storing[7] MessageID:urn:uuid:0dbd1ff5-071f-4d4e-b9df-ede65146cd20
[2013-07-10 12:39:42,999] DEBUG - MSMPLog [JMSMS3] Storing[5] MessageID:urn:uuid:19f02a23-6149-4c82-be32-9ec69986a45e
[2013-07-10 12:39:43,058] DEBUG - MSMPLog [JMSMS] Storing[8] MessageID:urn:uuid:3307251f-31cb-4690-bb23-224c4fd8d480
[2013-07-10 12:39:43,075] DEBUG - MSMPLog [JMSMS3] Storing[6] MessageID:urn:uuid:ba76517e-f4f2-4a5d-81eb-ed6c4f260783
[2013-07-10 12:39:43,078] DEBUG - MSMPLog [JMSMS2] Storing[7] MessageID:urn:uuid:3c5aa2fb-ad8c-4f9e-8c4d-222a21d2892f
[2013-07-10 12:39:43,150] DEBUG - MSMPLog [JMSMS] Storing[9] MessageID:urn:uuid:a08658be-a5b4-4cc4-a485-b53b86a2d871
[2013-07-10 12:39:43,161] DEBUG - MSMPLog [JMSMS3] Storing[7] MessageID:urn:uuid:3a487564-41ff-464a-bca7-6bc83030f03b
[2013-07-10 12:39:43,170] DEBUG - MSMPLog [JMSMS2] Storing[8] MessageID:urn:uuid:773b675f-f96f-48b1-a1f9-be31b102a933
[2013-07-10 12:39:43,177] DEBUG - MSMPLog [Processor2] Fetched[1] MessageID:urn:uuid:d0b76a30-9107-4db9-b159-8b70b707d29b
[2013-07-10 12:39:43,199] DEBUG - MSMPLog [Processor2] Fetched[2] MessageID:urn:uuid:3c121aab-ca24-45ba-a3bb-c727ecfda28a
[2013-07-10 12:39:43,227] DEBUG - MSMPLog [JMSMS2] Storing[7] MessageID:urn:uuid:82f95665-c758-4c8e-ae8d-a0db3c389a32
[2013-07-10 12:39:43,236] DEBUG - MSMPLog [Processor2] Fetched[3] MessageID:urn:uuid:62b3cfe6-f947-49e2-a43f-a39d09970147
[2013-07-10 12:39:43,246] DEBUG - MSMPLog [JMSMS] Storing[10] MessageID:urn:uuid:be8c177b-2483-4db4-8a39-fcf6f6b4793e
[2013-07-10 12:39:43,255] DEBUG - MSMPLog [Processor2] Fetched[4] MessageID:urn:uuid:d463555f-6955-450a-9b84-d2d2a6749712
[2013-07-10 12:39:43,303] DEBUG - MSMPLog [JMSMS3] Storing[8] MessageID:urn:uuid:91fef3e9-1146-4903-a790-02fee3685f26
[2013-07-10 12:39:43,337] DEBUG - MSMPLog [JMSMS2] Storing[6] MessageID:urn:uuid:2b4a76a8-2c6d-4e99-9da7-be5cf207aee1
[2013-07-10 12:39:43,348] DEBUG - MSMPLog [JMSMS3] Storing[9] MessageID:urn:uuid:cc754b66-11bf-40f0-b9d8-7ec72ac7397a
[2013-07-10 12:39:43,379] DEBUG - MSMPLog [JMSMS3] Storing[10] MessageID:urn:uuid:06bf808e-f35f-4724-ad34-d723d39b7131
[2013-07-10 12:39:43,412] DEBUG - MSMPLog [Processor2] Fetched[5] MessageID:urn:uuid:7af16cc1-ee29-4f16-addc-0d9ae4b51f9b
[2013-07-10 12:39:43,436] DEBUG - MSMPLog [Processor2] Fetched[6] MessageID:urn:uuid:3d802cb7-a029-4a59-b8b3-4c1b1074d4ab
[2013-07-10 12:39:43,455] DEBUG - MSMPLog [Processor2] Fetched[7] MessageID:urn:uuid:3c5aa2fb-ad8c-4f9e-8c4d-222a21d2892f
[2013-07-10 12:39:43,835] DEBUG - MSMPLog [Processor1] Fetched[1] MessageID:urn:uuid:1f50e3f1-46aa-470c-bf77-feea4088f32b
[2013-07-10 12:39:43,852] DEBUG - MSMPLog [Processor1] Fetched[2] MessageID:urn:uuid:32aa8ac0-470c-4293-8d36-1682df482a2a
[2013-07-10 12:39:43,867] DEBUG - MSMPLog [Processor1] Fetched[3] MessageID:urn:uuid:8bb300cb-faa9-45b4-bbd9-1d1e83f5aea7
[2013-07-10 12:39:43,878] DEBUG - MSMPLog [Processor1] Fetched[4] MessageID:urn:uuid:2103ba47-77e8-4518-8050-e18b81be62dd
[2013-07-10 12:39:43,890] DEBUG - MSMPLog [Processor3] Fetched[1] MessageID:urn:uuid:289e4073-1199-4805-9c32-46d689902059
[2013-07-10 12:39:43,893] DEBUG - MSMPLog [Processor1] Fetched[5] MessageID:urn:uuid:ee2b3c05-8a68-40ef-a2f1-be8c12a2a788
[2013-07-10 12:39:43,916] DEBUG - MSMPLog [Processor2] Fetched[8] MessageID:urn:uuid:773b675f-f96f-48b1-a1f9-be31b102a933
[2013-07-10 12:39:43,938] DEBUG - MSMPLog [Processor3] Fetched[2] MessageID:urn:uuid:b6fdf8eb-24eb-4ff4-8d49-5b58ae4fd38a
[2013-07-10 12:39:43,943] DEBUG - MSMPLog [Processor2] Fetched[9] MessageID:urn:uuid:82f95665-c758-4c8e-ae8d-a0db3c389a32
[2013-07-10 12:39:43,947] DEBUG - MSMPLog [Processor1] Fetched[6] MessageID:urn:uuid:e24eb516-c99c-4051-af0c-6120e9c9cd01
[2013-07-10 12:39:43,960] DEBUG - MSMPLog [Processor3] Fetched[3] MessageID:urn:uuid:56221673-e159-4604-8baf-31193fb0536e
[2013-07-10 12:39:43,961] DEBUG - MSMPLog [Processor2] Fetched[10] MessageID:urn:uuid:2b4a76a8-2c6d-4e99-9da7-be5cf207aee1
[2013-07-10 12:39:43,967] DEBUG - MSMPLog [Processor1] Fetched[7] MessageID:urn:uuid:909f69a0-44d9-462c-a8f8-1065fe81232d
[2013-07-10 12:39:43,974] DEBUG - MSMPLog [Processor3] Fetched[4] MessageID:urn:uuid:087fba00-7d6f-4138-8fa8-06c1549b508a
[2013-07-10 12:39:43,979] DEBUG - MSMPLog [Processor1] Fetched[8] MessageID:urn:uuid:54b99480-9976-436f-8aa2-f80d70602433
[2013-07-10 12:39:43,985] DEBUG - MSMPLog [Processor3] Fetched[5] MessageID:urn:uuid:19f02a23-6149-4c82-be32-9ec69986a45e
[2013-07-10 12:39:43,995] DEBUG - MSMPLog [Processor3] Fetched[6] MessageID:urn:uuid:ba76517e-f4f2-4a5d-81eb-ed6c4f260783
[2013-07-10 12:39:44,006] DEBUG - MSMPLog [Processor3] Fetched[7] MessageID:urn:uuid:3a487564-41ff-464a-bca7-6bc83030f03b
[2013-07-10 12:39:44,016] DEBUG - MSMPLog [Processor3] Fetched[8] MessageID:urn:uuid:91fef3e9-1146-4903-a790-02fee3685f26
[2013-07-10 12:39:44,031] DEBUG - MSMPLog [Processor3] Fetched[9] MessageID:urn:uuid:cc754b66-11bf-40f0-b9d8-7ec72ac7397a
[2013-07-10 12:39:44,045] DEBUG - MSMPLog [Processor3] Fetched[10] MessageID:urn:uuid:06bf808e-f35f-4724-ad34-d723d39b7131
[2013-07-10 12:40:38,572] DEBUG - MSMPLog [Processor1] Fetched[9] MessageID:urn:uuid:962808ff-19bf-4d86-a4b1-2e7e0b4363ec
[2013-07-10 12:40:38,587] DEBUG - MSMPLog [Processor1] Fetched[10] MessageID:urn:uuid:76ad4a31-91f4-4372-a851-2189723c485c
This log is same in the other ESB node as well. But since both of the ESBs servce one backend service the log there will be like this;
Value is:2
Value is:2
Value is:2
Value is:1
Value is:3
Value is:2
Value is:1
Value is:4
Value is:3
Value is:1
Value is:1
Value is:3
Value is:4
Value is:5
Value is:3
Value is:5
Value is:6
Value is:4
Value is:6
Value is:6
Value is:5
Value is:7
Value is:7
Value is:7
Value is:6
Value is:8
Value is:1
Value is:3
Value is:5
Value is:6
Value is:2
Value is:7
Value is:7
Value is:8
Value is:9
Value is:8
Value is:9
Value is:10
Value is:2
Value is:10
Value is:8
Value is:9
Value is:8
Value is:9
Value is:3
Value is:10
Value is:9
Value is:10
Value is:4
Value is:10
Value is:5
Value is:6
Value is:7
Value is:8
Value is:9
Value is:10
Value is:1
Value is:4
Value is:4
Value is:5
No comments:
Post a Comment