1 /* 2 * Copyright 2005-2008 The Kuali Foundation 3 * 4 * 5 * Licensed under the Educational Community License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.opensource.org/licenses/ecl2.php 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.kuali.rice.kew.test; 18 19 20 public class TestMessageBean {//implements MessageListener { 21 22 private static int counter = 0; 23 24 /*public void onMessage(Message msg) { 25 try { 26 final String message = "message recieved: \'"+((TextMessage)msg).getText()+"\'"; 27 System.out.println(message + ". count=" + ++counter); 28 Transaction transaction = Current.getTransactionManager().getTransaction(); 29 System.out.println("what's my threads transaction 1? " + transaction); 30 TransactionTemplate txTemplate = SpringServiceLocator.getTransactionTemplate(); 31 txTemplate.execute(new TransactionCallback() { 32 public Object doInTransaction(TransactionStatus status) { 33 try{ 34 Transaction transaction = Current.getTransactionManager().getTransaction(); 35 System.out.println("what's my threads transaction 2? " + transaction); 36 } catch (Exception e) { throw new RuntimeException(e); } 37 //System.out.println("My datassource? " + SpringServiceLocator.getEdenDataSource()); 38 JdbcTemplate template = new JdbcTemplate(SpringServiceLocator.getEdenDataSource()); 39 return template.execute(new ConnectionCallback() { 40 public Object doInConnection(Connection connection) throws SQLException { 41 String sql = "INSERT INTO ACTIVEMQ_TEST VALUES(?)"; 42 PreparedStatement preparedStatement = connection.prepareStatement(sql); 43 preparedStatement.setString(1, message); 44 preparedStatement.executeUpdate(); 45 System.out.println("doing prepared statement."); 46 return null; 47 } 48 }); 49 } 50 }); 51 52 } catch (Exception e) { 53 e.printStackTrace(); 54 throw new RuntimeException("caught exception jmsing"); 55 } 56 }*/ 57 58 // public void onMessage(Message msg) { 59 // try { 60 // final String message = "message recieved: \'"+((TextMessage)msg).getText()+"\'"; 61 // JdbcTemplate template = new JdbcTemplate(SpringServiceLocator.getEdenDataSource()); 62 // template.execute(new ConnectionCallback() { 63 // public Object doInConnection(Connection connection) throws SQLException { 64 // String sql = "INSERT INTO ACTIVEMQ_TEST VALUES(?)"; 65 // PreparedStatement preparedStatement = connection.prepareStatement(sql); 66 // preparedStatement.setString(1, message); 67 // preparedStatement.executeUpdate(); 68 // System.out.println("doing prepared statement."); 69 // return null; 70 // } 71 // }); 72 // 73 // } catch (Exception e) { 74 // e.printStackTrace(); 75 // throw new RuntimeException("caught exception jmsing"); 76 // } 77 // } 78 // 79 // public static boolean isDone() { 80 // return counter == 1000; 81 // } 82 }