SOAP onto the bus, persist synchronously and retrieve messag
wili Oct 27, 2008 8:24 AMscenario:
A client sends a SOAP message to a JBossWS endpoint on the bus. There the message is persisted with a classification e.g. "new". On success, the client receives a SUCCESS response. A (scheduled) service will retrieve all new Messages out of the store and process their bodies.
A client must be sure that JBoss ESB will deliver the message even if it crashes (this is the reason for persisting).
The following code snippets don't really work:
@WebService(name = "LockingWS", targetNamespace="http://united/locking")
public class LockingWS {
@WebMethod
@WebResult(name="result")
public String lock(@WebParam(name="param1") String message) throws MessageDeliverException {
Message esbMessage = SOAPProcessor.getMessage();
if(esbMessage != null) {
ServiceInvoker si = new ServiceInvoker("MyServiceCategory","PersistService");
try {
si.deliverSync(esbMessage, 1000);
} catch (Exception e) {
e.printStackTrace();
return "ERROR";
}
return "SUCCESS";
}
return "ERROR";
}
}<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5"> <providers> <jms-provider name="JBossMQ" connection-factory="ConnectionFactory"> <jms-bus busid="quickstartGwChannel"> <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_webservice_producer_gw" /> </jms-bus> <jms-bus busid="quickstartEsbChannel"> <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_webservice_producer_esb" /> </jms-bus> </jms-provider> <jbr-provider name="JBR-Http" protocol="http" host="localhost"> <jbr-bus busid="Http-1" port="8765" /> </jbr-provider> </providers> <services> <service category="MyServiceCategory" name="MyWSProducerService" description="WS Frontend speaks natively to the ESB"> <listeners> <jbr-listener name="Http-Gateway" busidref="Http-1" is-gateway="true" /> <jms-listener name="JMS-ESBListener" busidref="quickstartEsbChannel" /> </listeners> <actions> <action name="JBossWSAdapter" class="org.jboss.soa.esb.actions.soap.SOAPProcessor"> <property name="jbossws-endpoint" value="LockingWS" /> </action> </actions> </service> <service name="PersistService" category="MyServiceCategory" description="persisitiert alle einkommenden Messages" invmScope="GLOBAL"> <actions> <action name="PersistAction" class="org.jboss.soa.esb.actions.MessagePersister"> <property name="classification" value="new" /> <property name="message-store-class" value="org.jboss.internal.soa.esb.persistence.format.db.DBMessageStoreImpl" /> </action> </actions> </service> </services> </jbossesb>
I think there is a better way to do this, but how?