[jboss-svn-commits] JBL Code SVN: r7918 - in labs/jbossesb/trunk/product/samples/trailblazer2: . client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker esb/conf esb/src/org/jboss/soa/esb/samples/trailblazer/util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 28 22:08:57 EST 2006
Author: daniel.brum at jboss.com
Date: 2006-11-28 22:08:50 -0500 (Tue, 28 Nov 2006)
New Revision: 7918
Modified:
labs/jbossesb/trunk/product/samples/trailblazer2/build.properties
labs/jbossesb/trunk/product/samples/trailblazer2/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java
labs/jbossesb/trunk/product/samples/trailblazer2/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/SendJMSMessage.java
labs/jbossesb/trunk/product/samples/trailblazer2/esb/conf/banksgateway-esb.xml
labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/Launcher.java
labs/jbossesb/trunk/product/samples/trailblazer2/trailblazer-properties.xml
Log:
Modified: labs/jbossesb/trunk/product/samples/trailblazer2/build.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/build.properties 2006-11-29 02:25:24 UTC (rev 7917)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/build.properties 2006-11-29 03:08:50 UTC (rev 7918)
@@ -1,2 +1,2 @@
-org.jboss.soa.samples.trailblazer.jboss_home=C:/dev/jboss4.0.5
+org.jboss.soa.samples.trailblazer.jboss_home=/home/dbrum/jboss-4.0.4
org.jboss.soa.samples.trailblazer.jboss_server=default
Modified: labs/jbossesb/trunk/product/samples/trailblazer2/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java 2006-11-29 02:25:24 UTC (rev 7917)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java 2006-11-29 03:08:50 UTC (rev 7918)
@@ -22,17 +22,12 @@
*/
-import java.io.IOException;
-
-import javax.xml.parsers.ParserConfigurationException;
-
import org.apache.log4j.Logger;
import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.eprs.JMSEpr;
import org.jboss.soa.esb.common.ModulePropertyManager;
-import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierFactory;
import org.jboss.soa.esb.couriers.CourierTimeoutException;
import org.jboss.soa.esb.couriers.CourierUtil;
@@ -43,7 +38,6 @@
import org.jboss.soa.esb.samples.trailblazer.web.WebCustomer;
import org.jboss.soa.esb.services.registry.Registry;
import org.jboss.soa.esb.services.registry.RegistryFactory;
-import org.jboss.soa.esb.util.Util;
/*
* LoanBroker is responsible for getting customer requests for loans onto the JBoss ESB
@@ -61,8 +55,10 @@
//used to locate our entries in the trailblazer-properties
private final String MODULE_NAME = "trailblazer";
private final String SERVICE_NAME = "org.jboss.soa.esb.trailblazer.request.service.epr.name";
- private final String SERVICE_CAT = "org.jboss.soa.esb.trailblazer.request.service.category";
+ private final String SERVICE_CAT = "org.jboss.soa.esb.trailblazer.request.service.category";
+ private final String JMS_BANK_QUEUE="org.jboss.soa.esb.trailblazer.jmsbank.queue";
+
public LoanBroker() {
System.setProperty("org.jboss.soa.esb.propertyFile", "trailblazer-properties.xml");
// System.setProperty("juddi.propertiesFile", "juddi.properties");
@@ -73,24 +69,75 @@
Customer customer = getCustomer(wCustomer);
//keep the customer in a file someplace for later use, if needed
- CustomerMasterFile.addCustomer(String.valueOf(customer.ssn), customer);
-
+ CustomerMasterFile.addCustomer(String.valueOf(customer.ssn), customer);
+
+ //step 1 - send to credit agency for credit score if available
+ //uses 2way courier for a response TODO: figure out why this does not work!
+ sendToCreditAgency(customer);
+
+ //step 2 - send to JMS Bank - async
+ sendToJMSBank(customer);
+
+ //step 3 - send to File Bank (when listener is ready)
+
+ //step 4 - send to SQL Bank (when listener ready)
+
+ }
+
+ private Customer getCustomer(WebCustomer wCustomer) {
+ Customer customer = new Customer();
+ customer.ssn = wCustomer.ssn;
+ customer.name = wCustomer.name;
+ customer.address = wCustomer.address;
+ customer.email = wCustomer.email;
+ customer.salary = wCustomer.salary;
+ customer.loanAmount = wCustomer.loanAmount;
+ customer.loanDuration = wCustomer.loanDuration;
+ customer.creditScore = 0;
+
+ return customer;
+ }
+
+
+
+ private void sendToJMSBank(Customer customer) {
+ try {
+ //create a Quote Request that the bank expects
+ QuoteRequest quote = new QuoteRequest();
+ quote.ssn=customer.ssn;
+ quote.amount=(int)customer.loanAmount;
+ quote.creditScore=customer.creditScore;
+ quote.creditHistoryLen=0; //not sure who added this one
+ quote.term=customer.loanDuration;
+
+ SendJMSMessage sender = new SendJMSMessage();
+ sender.setupConnection(
+ ModulePropertyManager.getPropertyManager(MODULE_NAME).getProperty(JMS_BANK_QUEUE));
+ sender.sendAMessage(quote.toString());
+ sender.stop();
+ }catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ private int sendToCreditAgency(Customer customer) {
Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
Message replyMessage=null;
+ int score =0;
//convert our customer to a bean xml representation
-// XMLEncoder encoder=null;
-// try {
-// ByteArrayOutputStream bytes = new ByteArrayOutputStream();
-// ObjectOutputStream oos = new ObjectOutputStream(bytes);
-// encoder = new XMLEncoder(oos);
-// encoder.writeObject(wCustomer);
-// encoder.close();
-// System.out.println("encoded customer: "+ bytes.toString());
-// } catch (IOException e2) {
-// // TODO Auto-generated catch block
-// e2.printStackTrace();
-// }
+ // XMLEncoder encoder=null;
+ // try {
+ // ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ // ObjectOutputStream oos = new ObjectOutputStream(bytes);
+ // encoder = new XMLEncoder(oos);
+ // encoder.writeObject(wCustomer);
+ // encoder.close();
+ // System.out.println("encoded customer: "+ bytes.toString());
+ // } catch (IOException e2) {
+ // // TODO Auto-generated catch block
+ // e2.printStackTrace();
+ // }
//set the customer inside the message - csv format for now to test
message.getBody().setContents(customer.getCSV().getBytes());
@@ -127,8 +174,13 @@
if (courier.deliver(message)) {
courier.setReplyToEpr(replyEPR);
replyMessage = courier.pickup(5000); //TODO: replace with a time value from Config
- logger.debug("received reply from creditAgency action");
- logger.debug("message received: " + replyMessage.getBody().getContents());
+ if (replyMessage !=null) {
+ logger.debug("received reply from creditAgency action");
+ logger.debug("message received: " + replyMessage.getBody().getContents());
+ score = new Integer(new String(replyMessage.getBody().getContents())).intValue();
+
+
+ }
} else
throw new ActionProcessingException("error delivering the message to the credit agency");
@@ -140,34 +192,10 @@
logger.error("exception occured: " + ex2);
ex2.printStackTrace();
}
- //step 2 - send to JMS Bank
- //step 3 - send to File Bank (when listener is ready)
-
- //step 4 - send to SQL Bank (when listener ready)
-
+ return score;
}
- private Customer getCustomer(WebCustomer wCustomer) {
- Customer customer = new Customer();
- customer.ssn = wCustomer.ssn;
- customer.name = wCustomer.name;
- customer.address = wCustomer.address;
- customer.email = wCustomer.email;
- customer.salary = wCustomer.salary;
- customer.loanAmount = wCustomer.loanAmount;
- customer.loanDuration = wCustomer.loanDuration;
- customer.creditScore = 0;
-
- return customer;
- }
- public static void main(String[] args) {
- LoanBroker broker = new LoanBroker();
- WebCustomer wCustomer = new WebCustomer("me", "123 Anywhere st.", "Jboss", 500.00, 12, 100.00,12345,"email");
- broker.processLoanRequest(wCustomer);
- }
-
-
}
Modified: labs/jbossesb/trunk/product/samples/trailblazer2/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/SendJMSMessage.java 2006-11-29 02:25:24 UTC (rev 7917)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/SendJMSMessage.java 2006-11-29 03:08:50 UTC (rev 7918)
@@ -9,6 +9,7 @@
import javax.jms.QueueSession;
import javax.jms.QueueSender;
import javax.jms.ObjectMessage;
+import javax.jms.TextMessage;
import java.io.File;
import java.io.FileReader;
@@ -42,7 +43,7 @@
public void sendAMessage(String msg) throws JMSException {
QueueSender send = session.createSender(que);
- ObjectMessage tm = session.createObjectMessage(msg);
+ TextMessage tm = session.createTextMessage(msg);
send.send(tm);
send.close();
}
Modified: labs/jbossesb/trunk/product/samples/trailblazer2/esb/conf/banksgateway-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/esb/conf/banksgateway-esb.xml 2006-11-29 02:25:24 UTC (rev 7917)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/esb/conf/banksgateway-esb.xml 2006-11-29 03:08:50 UTC (rev 7918)
@@ -15,4 +15,3 @@
-->
</esb-jms-gateway>
</jms-banks-gateway>
-"product/samples/trailblazer2/build.xml"
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/Launcher.java
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/Launcher.java 2006-11-29 02:25:24 UTC (rev 7917)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/Launcher.java 2006-11-29 03:08:50 UTC (rev 7918)
@@ -24,10 +24,10 @@
public static void main (String args[]) throws Exception
{
- System.setProperty("org.jboss.soa.esb.propertyFile", "trailblazer-properties.xml");
-// System.out.println("args passed into Launcher: " + args.length);
- String arg0=null, arg1=null;
+ System.setProperty("org.jboss.soa.esb.propertyFile", "trailblazer-properties.xml");
+
//Adding the to make it easy to run in eclipse
+ String arg0=null, arg1=null, arg2=null;
String baseDir="";
if (args.length==0) {
arg0 = "60";
@@ -35,7 +35,8 @@
baseDir = "product/samples/trailblazer2/";
}
arg1 = baseDir + "esb/conf/loanbroker-esb.xml";
- System.out.println("Setting default arguments:" + arg0 + " " + arg1);
+ arg2 = baseDir + "esb/conf/banksgateway-esb.xml";
+ System.out.println("Setting default arguments:" + arg0 + " " + arg1 + " " + arg2);
}
//eclipse peace out
if (args.length > 1) {
@@ -48,9 +49,10 @@
Launcher launcher = new Launcher();
- if(args.length > 2)
+ if(args.length > 2) {
+ System.out.println("calling triggerListener with 3 arguments...");
launcher.triggerListener(Long.valueOf(arg0).longValue(), arg1, args[2]);
- else
+ }else
launcher.triggerListener(Long.valueOf(arg0).longValue(), arg1, null);
}
@@ -70,6 +72,7 @@
}
if (null != gatewayConfigFile) {
+ Thread.sleep(5000);
_logger.info("starting gateway listener with config file - " + gatewayConfigFile);
_gatewayController = new GatewayListenerController(gatewayConfigFile);
new Thread(_gatewayController).start();
Modified: labs/jbossesb/trunk/product/samples/trailblazer2/trailblazer-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/trailblazer-properties.xml 2006-11-29 02:25:24 UTC (rev 7917)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/trailblazer-properties.xml 2006-11-29 03:08:50 UTC (rev 7918)
@@ -79,5 +79,6 @@
<properties name="trailblazer">
<property name="org.jboss.soa.esb.trailblazer.request.service.epr.name" value="creditagency"/>
<property name="org.jboss.soa.esb.trailblazer.request.service.category" value="trailblazer"/>
+ <property name="org.jboss.soa.esb.trailblazer.jmsbank.queue" value="queue/C"/>
</properties>
</esb>
More information about the jboss-svn-commits
mailing list