Difference between revisions of "GVExample TOUPPER A"
(→Configuring a queue in JBoss) |
(→Defining Workflow Operations) |
||
Line 250: | Line 250: | ||
[[File:GVExamplesTOUPPER5.jpg|thumb|Exporting configuration]]Once the flow is correctly configured, the user can export the configuration and pass it to the {{GVESB}} import tool, in order to add into the {{GVESB}} the service just created. | [[File:GVExamplesTOUPPER5.jpg|thumb|Exporting configuration]]Once the flow is correctly configured, the user can export the configuration and pass it to the {{GVESB}} import tool, in order to add into the {{GVESB}} the service just created. | ||
+ | |||
# The Export function is available in the view "Project". Expand the project | # The Export function is available in the view "Project". Expand the project | ||
# Before you proceed press F5 to refresh the file list. | # Before you proceed press F5 to refresh the file list. |
Revision as of 07:54, 19 February 2012
Contents
Description
This simple example shows how to configure an asynchronous service with Forward JMS. Service TOUPPER_A will receive a phrase as input and will return the same phrase in upper case.
How To
The best mode for creating a Service is through the Wizard. But for use it you must first define a new Group, System and Channel, if you do not want to use those already presents, and the workflow operations.
Defining Group, System and Channel
From the core view:
- Right click the element Groups -> Insert after (or Insert before) -> Group. A new element Group will be created.
- Click on the Group new element and set the attribute id-group from the Properties View. We named it DEFAULT_GRP
- Expand the GVSystems item.
- Right clicking on Systems, insert-after -> System. A new element System will be created.
- Set the System parameters in the Properties panel. We named it GVESB_TEST
- You can insert a new Channel right clicking the new System element -> Insert after (or Insert before) -> Channel*. A new Channel element will be created
- Click on this new Channel element and set the property id_channel. We named it TEST_CHANNEL_A
Configuring a queue in JBoss
The queues are configured in JBoss by an XML file.
A queue has:
- A name that serves to identify it to JBoss.
- A JNDI Name is used by a client to connect to the queue.
- RedeliveryLimit (optional), to indicate how many times a message is put back into the queue for processing if the application does not confirm its reading.
- RedeliveryDelay (optional), to indicate the time (in ms) a message will be available in queue if the application does not confirm its reading.
The JndiName can be found in the JBoss jmx-console in JBoss module "service = JNDIView".
In this example we use the queues TOUPPER_A_Request_Queue and TOUPPER_A_Response_Queue. To configure both queues go to file gvesb-mq-destinations-service.xml present in the directory {{gv.app.home}}/application/deploy and insert the following mbeans:
<mbean code="org.jboss.jms.server.destination.QueueService"
name="jboss.messaging.destination:service=Queue,name=TOUPPER_A_Request_Queue"
xmbean-dd="xmdesc/Queue-xmbean.xml">
<depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
<depends>jboss.messaging:service=PostOffice</depends>
<attribute name="JNDIName">gvesb/jms/queue/TOUPPER_A_Request_Queue</attribute>
<attribute name="RedeliveryDelay">60000</attribute>
<attribute name="MaxDeliveryAttempts">100</attribute>
</mbean>
<mbean code="org.jboss.jms.server.destination.QueueService"
name="jboss.messaging.destination:service=Queue,name=TOUPPER_A_Response_Queue"
xmbean-dd="xmdesc/Queue-xmbean.xml">
<depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
<depends>jboss.messaging:service=PostOffice</depends>
<attribute name="JNDIName">gvesb/jms/queue/TOUPPER_A_Response_Queue</attribute>
<attribute name="RedeliveryDelay">60000</attribute>
<attribute name="MaxDeliveryAttempts">100</attribute>
</mbean>
Defining Workflow Operations
Once you have created the Channel, insert into the operations you need for the workflow. In this case:
Plugin | Value |
---|---|
jms-enqueue | connection-factory="java:/XAConnectionFactory" destination-name="gvesb/jms/queue/TOUPPER_A_Request_Queue" name="JMSEnqueueTo::TOUPPER_A_Req" ref-dp="WriteString_JMSBytesMessageDataProvider" XAHelper
|
jms-enqueue | connection-factory="java:/XAConnectionFactory" delivery-mode="persistent" destination-name="gvesb/jms/queue/TOUPPER_A_Response_Queue" name="JMSEnqueueTo::TOUPPER_A_Resp" ref-dp="WriteString_JMSBytesMessageDataProvider" XAHelper
|
jms-dequeue | connection-factory="java:/XAConnectionFactory" delivery-mode="persistent" destination-name="gvesb/jms/queue/TOUPPER_A_Response_Queue" name="JMSDequeueTo::TOUPPER_A_Resp" ref-dp="ReadString_JMSBytesMessageDataProvider" receive-type="timeout" XAHelper
|
test-service-call | name="toupper_call" |
Check that Data Providers WriteString_JMSBytesMessageDataProvider and ReadString_JMSBytesMessageDataProvider will be present in the element DataProviders (JMSBytesMessageDataProvider and StringDataProvider respectively), visualized from the VulCon Adapter view. If don't you can add it setting their attributes as seen in the following table:
Data Provider | Value |
---|---|
JMSBytesMessageDataProvider | name="WriteString_JMSBytesMessageDataProvider" Field:
|
StringDataProvider | name="ReadString_JMSBytesMessageDataProvider" Field:
|
Now we are able to use the Wizard.
- From the Core View of VulCon. Right click the element Services -> Wizard New Service
- A new windows will be open where you can set the name of the Service you want to create, in this case we named TOUPPER_A, and your Group, we used DEFAULT_GRP. You can also select the paradigm, for this example will be asynchronous-synchronous. Click next.
- Set System as GVESB_TEST and Channel as TEST_CHANNEL_A. Then chose as Request Operation JMSEnqueueTo::TOUPPER_A_Req, and the response Operation toupper_call. Then finish.
As you can see from the core view, inside the Services element, a new Service named TOUPPER_A has been created. This service contains three Operations:
We setted the first one as a Request (to enqueue), and the second as a GetReply (to dequeue). Nodes will be setted as seen in the following table:
Node | Request | GetReply |
---|---|---|
GVOperationNode | output: output_JMSEnqueueTo::TOUPPER_A_Req id="request" id-system="GVESB_TEST" input="input_JMSEnqueueTo::TOUPPER_A_Req" next-node-id="check_status" op-type="enqueue" operation-name="JMSEnqueueTo::TOUPPER_A_Req" |
output: "output_null" id="request" id-system="GVESB_TEST" input="input_null" next-node-id="check_status" op-type="dequeue" operation-name="JMSDequeueTo::TOUPPER_A_Resp" |
GVNodeCheck | default-id="return_status" id="check_status" input="output_JMSEnqueueTo::TOUPPER_A_Req" on-exception-id="return_error" op-type="check" |
default-id="return_status" id="check_status" input="output_null" on-exception-id="return_error" |
GVEndNode | id="return_status" op-type="end" output="output_JMSEnqueueTo::TOUPPER_A_Req" |
id="return_status" op-type="end" |
GVEndNode | id="return_error" output="output_JMSEnqueueTo::TOUPPER_A_Req" |
id="return_error" output="output_null" |
Operation FWD_TOUPPER_A will be configured as follow: Attributes: name="Forward" operation-activation="on" out-check-type="none"
Nodes/Subelements | Attributes |
---|---|
GVOperationNode | id-system="GVESB" input="input" next-node-id="enqueue_response" op-type="call" operation-name="toupper_call" output="output" |
GVOperationNode | id="enqueue_response" id-system="GVESB" input="output" next-node-id="end" op-type="enqueue" operation-name="JMSEnqueueTo::TOUPPER_A_Resp" output="output" |
GVEndNode | end-business-process="no" id="end" op-type="end" output="output" ChangeGVBuffer: clear-data="true" |
The GVCore.xml configuration file will be changed as follow:
- Into Services element will be added the tag
<Service group-name="DEFAULT_GRP" id-service="TOUPPER_A"
service-activation="on" statistics="off">
<Operation name="Request" operation-activation="on"
out-check-type="sys-svc-tid" type="operation">
<Description>VulCon generated Operation</Description>
<Participant id-channel="TEST_CHANNEL_A" id-system="GVESB_TEST"/>
<Flow first-node="request" point-x="50" point-y="150">
<GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
id="request" id-system="GVESB_TEST"
input="input_JMSEnqueueTo::TOUPPER_A_Req"
next-node-id="check_status" op-type="enqueue"
operation-name="JMSEnqueueTo::TOUPPER_A_Req"
output="output_JMSEnqueueTo::TOUPPER_A_Req"
point-x="200" point-y="150" type="flow-node"/>
<GVNodeCheck class="it.greenvulcano.gvesb.core.flow.GVNodeCheck"
default-id="return_status" id="check_status"
input="output_JMSEnqueueTo::TOUPPER_A_Req"
on-exception-id="return_error" op-type="check"
point-x="350" point-y="150" type="flow-node"/>
<GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
id="return_status" op-type="end"
output="output_JMSEnqueueTo::TOUPPER_A_Req"
point-x="700" point-y="150" type="flow-node"/>
<GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
id="return_error" op-type="end"
output="output_JMSEnqueueTo::TOUPPER_A_Req"
point-x="350" point-y="300" type="flow-node"/>
</Flow>
</Operation>
<Operation name="GetReply" operation-activation="on"
out-check-type="sys-svc-tid" type="operation">
<Description>VulCon generated Operation</Description>
<Participant id-channel="TEST_CHANNEL_A" id-system="GVESB_TEST"/>
<Flow first-node="request" point-x="50" point-y="150">
<GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
id="request" id-system="GVESB_TEST"
input="input_null" next-node-id="check_status"
op-type="dequeue"
operation-name="JMSDequeueTo::TOUPPER_A_Resp"
output="output_null" point-x="200" point-y="150"
type="flow-node"/>
<GVNodeCheck class="it.greenvulcano.gvesb.core.flow.GVNodeCheck"
default-id="return_status" id="check_status"
input="output_null" on-exception-id="return_error"
op-type="check" point-x="350" point-y="150"
type="flow-node"/>
<GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
id="return_status" op-type="end" output="output_null"
point-x="700" point-y="150" type="flow-node"/>
<GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
id="return_error" op-type="end" output="output_null"
point-x="350" point-y="300" type="flow-node"/>
</Flow>
</Operation>
<Operation forward-name="FWD_TOUPPER_A" name="Forward"
operation-activation="on" out-check-type="none"
type="operation">
<Participant id-channel="TEST_CHANNEL_A" id-system="GVESB"/>
<Flow first-node="call_server" point-x="20" point-y="150">
<GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
id="call_server" id-system="GVESB" input="input"
next-node-id="enqueue_response" op-type="call"
operation-name="toupper_call" output="output"
point-x="147" point-y="148" type="flow-node"/>
<GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
id="enqueue_response" id-system="GVESB"
input="output" next-node-id="end"
op-type="enqueue"
operation-name="JMSEnqueueTo::TOUPPER_A_Resp"
output="output" point-x="319" point-y="152"
type="flow-node"/>
<GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
end-business-process="no" id="end" op-type="end"
output="output" point-x="532" point-y="149"
type="flow-node">
<ChangeGVBuffer clear-data="true"/>
</GVEndNode>
</Flow>
</Operation>
</Service>
- Into System element will be added the tag
<Channel id-channel="TEST_CHANNEL_A">
<jms-enqueue acknowledge-type="auto-acknowledge"
class="it.greenvulcano.gvesb.virtual.j2ee.JMSEnqueueOperation"
connection-factory="java:/XAConnectionFactory"
delivery-mode="persistent"
destination-name="gvesb/jms/queue/TOUPPER_A_Request_Queue"
destination-type="queue"
name="JMSEnqueueTo::TOUPPER_A_Req" priority="4"
ref-dp="WriteString_JMSBytesMessageDataProvider"
transacted="false" type="enqueue">
<XAHelper auto-enlist="false" transaction-status="TMSUCCESS"/>
</jms-enqueue>
<jms-enqueue acknowledge-type="auto-acknowledge"
class="it.greenvulcano.gvesb.virtual.j2ee.JMSEnqueueOperation"
connection-factory="java:/XAConnectionFactory"
delivery-mode="persistent"
destination-name="gvesb/jms/queue/TOUPPER_A_Response_Queue"
destination-type="queue"
name="JMSEnqueueTo::TOUPPER_A_Resp" priority="4"
transacted="false" type="enqueue">
<XAHelper auto-enlist="false" transaction-status="TMSUCCESS"/>
</jms-enqueue>
<jms-dequeue acknowledge-type="auto-acknowledge"
class="it.greenvulcano.gvesb.virtual.j2ee.JMSDequeueOperation"
connection-factory="java:/XAConnectionFactory"
destination-name="gvesb/jms/queue/TOUPPER_A_Response_Queue"
destination-type="queue"
name="JMSDequeueTo::TOUPPER_A_Resp"
receive-timeout-overridable="false"
receive-type="timeout" transacted="false" type="dequeue">
<XAHelper auto-enlist="false" transaction-status="TMSUCCESS"/>
</jms-dequeue>
<test-service-call class="it.greenvulcano.gvesb.virtual.internal.TestServiceCall"
name="toupper_call" service="toupper" type="call"/>
</Channel>
Now you are able to test your first VulCon service from the GV Console®. But first you need to export the configuration.
Once the flow is correctly configured, the user can export the configuration and pass it to the GreenVulcano® ESB import tool, in order to add into the GreenVulcano® ESB the service just created.
- The Export function is available in the view "Project". Expand the project
- Before you proceed press F5 to refresh the file list.
- Right click the conf folder. It will open a drop-down list.
- Export your project as a compressed file.
Testing with GV Console
It is finally arrived the time to test your project. To do that execute the following steps:
Suppose you have saved the VulCon project as "${{gv.app.home}}/TEST/REPG1.zip". To deploy the new Service follow this steps:
- Start GreenVulcano® ESB
- Access to the GV Console.
- In the Deploy New Service section click Browse and select the file where you saved the VulCon configuration.
- `Click Submit.
The section Deploy Services will be open. In this section you can select the services you want to deploy.
- Clicking on service TOUPPER_A a new view will be showed containing the files GVCore.xml present in local and on server side.
- Click Deploy. Now you can save the document and write some notes about it.
- Save the Document. By saving you will return to the Deploy Service section.
Now pass to the GV Console section Utility.
- Click on Reload configuration
- Select GVCore.xml and then Reload. A new windows will be open to confirm the operation
- Click OK.
Go to the GV Console section Testing. In this section you can finally test your new service:
- Into the Service voice select TOUPPER_A
- Into the System voice select GVESB_TEST
- Click Request
When test finishes, the Testing view will be expanded for containing the GVBUFFER OUTPUT. In this case no properties have been defined so there are only be presents the main informations about the process (System, Service, Id, etc.). Standard fields and the detailed GVBuffer are described in the Output File Name (we setted it as ${{gv.app.home}}/log/TestOutput.txt).
In case of error or exceptions you can review the logs file presents in the folder ${{gv.app.home}}/log/.