[jboss-svn-commits] JBL Code SVN: r12503 - in labs/jbossesb/trunk/product/samples/quickstarts/messagestore: src and 8 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jun 12 13:44:29 EDT 2007


Author: kurt.stam at jboss.com
Date: 2007-06-12 13:44:28 -0400 (Tue, 12 Jun 2007)
New Revision: 12503

Added:
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/CheckMessageStoreAction.java
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendEsbMessage.java
   labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendJMSMessage.java
Log:
JBESB-600 Adding MessageStore QS

Added: labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/CheckMessageStoreAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/CheckMessageStoreAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/CheckMessageStoreAction.java	2007-06-12 17:44:28 UTC (rev 12503)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.messagestore;
+
+import java.net.URI;
+
+import org.jboss.internal.soa.esb.persistence.format.MessageStoreFactory;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+
+public class CheckMessageStoreAction extends AbstractActionLifecycle {
+
+    protected ConfigTree _config;
+
+    public CheckMessageStoreAction(ConfigTree config) {
+        _config = config;
+    }
+    /**
+     * Check if the message is in the message store. The Unique Identifyer is set on the message property 
+     * with name MessageStore.MESSAGE_STORE_URI. 
+     * 
+     * @param originalMessage
+     * @return
+     * @throws Exception
+     */
+    public Message process(Message originalMessage) throws Exception 
+    {
+        //I can call the messagestore API directory if it is deployed in the same JVM
+        String messageStoreClass = "org.jboss.internal.soa.esb.persistence.format.db.DBMessageStoreImpl";
+        MessageStore messageStore = MessageStoreFactory.getInstance().getMessageStore(messageStoreClass);
+        //Try to pull the message out
+        Message message = messageStore.getMessage((URI) originalMessage.getProperties().getProperty(MessageStore.MESSAGE_STORE_URI));
+        //Print out the content of the message
+        System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+        System.out.println("Body (from the stored message): "
+                + new String(message.getBody().getByteArray()));
+        System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+        
+        return message;
+
+    }
+
+}
\ No newline at end of file


Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/CheckMessageStoreAction.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendEsbMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendEsbMessage.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendEsbMessage.java	2007-06-12 17:44:28 UTC (rev 12503)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.samples.quickstart.messagestore.test;
+
+import java.net.URI;
+import java.util.UUID;
+
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.listeners.ListenerUtil;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+/**
+ * Standalone class with to send ESB messages to a 'known' [category,name].
+ * <p/> arg0 - service category
+ * <br/>arg1 - service name
+ * <br/>arg2 - Text of message to send
+ * 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @since Version 4.0
+ *
+ */
+public class SendEsbMessage 
+{
+    public static void main(String args[]) throws Exception
+    {
+    	if (args.length < 3)
+    	{
+    		System.out.println("Usage SendEsbMessage <category> <name> <text to send>");
+    	}
+        //Setting the ConnectionFactory such that it will use scout
+        System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");
+    	// Create a message, assign it a UID, and fill in call information
+    	Message esbMessage = MessageFactory.getInstance().getMessage();
+    	Call call = new Call();
+    	call.setMessageID(new URI(UUID.randomUUID().toString()));
+    	esbMessage.getHeader().setCall(call);
+    	
+    	// set body contents with args[2], and send
+    	esbMessage.getBody().setByteArray(args[2].getBytes());
+    	
+    	ListenerUtil.tryToDeliver(esbMessage, args[0], args[1]);
+    	
+    }
+    
+}
\ No newline at end of file


Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendEsbMessage.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendJMSMessage.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendJMSMessage.java	2007-06-12 17:44:28 UTC (rev 12503)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.messagestore.test;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class SendJMSMessage {
+    QueueConnection conn;
+    QueueSession session;
+    Queue que;
+    
+    
+    public void setupConnection() throws JMSException, NamingException
+    {
+		InitialContext iniCtx = new InitialContext();
+    	Object tmp = iniCtx.lookup("ConnectionFactory");
+    	QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+    	conn = qcf.createQueueConnection();
+    	que = (Queue) iniCtx.lookup("queue/quickstart_messagestore_Request_gw");
+    	session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+    	conn.start();
+    	System.out.println("Connection Started");
+    }
+    
+    public void stop() throws JMSException 
+    { 
+        conn.stop();
+        session.close();
+        conn.close();
+    }
+    
+    public void sendAMessage(String msg) throws JMSException {
+    	
+        QueueSender send = session.createSender(que);        
+        ObjectMessage tm = session.createObjectMessage(msg);
+        send.send(tm);        
+        send.close();
+    }
+       
+    
+    public static void main(String args[]) throws Exception
+    {        	    	
+    	SendJMSMessage sm = new SendJMSMessage();
+    	sm.setupConnection();
+    	sm.sendAMessage(args[0]); 
+    	sm.stop();
+    	
+    }
+    
+}


Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/messagestore/src/org/jboss/soa/esb/samples/quickstart/messagestore/test/SendJMSMessage.java
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list