[jboss-svn-commits] JBL Code SVN: r17869 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product: rosetta/src/org/jboss/internal/soa/esb/couriers and 23 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jan 15 11:20:55 EST 2008
Author: beve
Date: 2008-01-15 11:20:54 -0500 (Tue, 15 Jan 2008)
New Revision: 17869
Added:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/JmsCourierIntegrationTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/build.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/deployment.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbm-queue-service.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbmq-queue-service.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jboss-esb.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbossesb-properties.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbossesb-service.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jndi.properties
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/juddi.properties
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/log4j.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/quickstart-ds.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/readme.txt
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/hsqldb/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/hsqldb/create.sql
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/DBInsertAction.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/SendJMSMessage.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/ThrowExceptionAction.java
Modified:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/etc/schemas/xml/jbossesb-1.0.1.xsd
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolContainer.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetter.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/JMSPropertiesSetter.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolContainerUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/JMSEprUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_esbaware.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_gateways.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_02.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetterUnitTest.java
Log:
Work for JBESB-1438 "JMS Courrier does not support transacted mode".
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/etc/schemas/xml/jbossesb-1.0.1.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/etc/schemas/xml/jbossesb-1.0.1.xsd 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/etc/schemas/xml/jbossesb-1.0.1.xsd 2008-01-15 16:20:54 UTC (rev 17869)
@@ -626,6 +626,15 @@
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
+ <xsd:attribute default="false" name="transacted"
+ type="xsd:boolean" use="optional">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ If true, JMS sessions will be transaction aware.
+ Default is false.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="jms-bus" substitutionGroup="jesb:bus">
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -240,6 +240,8 @@
}
}
sendMessage(message);
+ if ( jmsSession.getTransacted() )
+ jmsSession.commit();
return true;
}
catch (JMSException e) {
@@ -368,6 +370,7 @@
Properties properties;
String username;
String password;
+ boolean transacted;
try {
sFactoryClass = _epr.getConnectionFactory();
@@ -375,6 +378,7 @@
properties = _epr.getJndiEnvironment();
username = _epr.getJMSSecurityPrincipal();
password = _epr.getJMSSecurityCredential();
+ transacted = _epr.getTransacted();
} catch (URISyntaxException e) {
throw new ConnectionException("Unexpected exception while getting JMS connection pool.", e);
}
@@ -383,7 +387,7 @@
sFactoryClass = "ConnectionFactory";
}
- jmsConnectionPool = JmsConnectionPoolContainer.getPool(properties, sFactoryClass, sType, username, password);
+ jmsConnectionPool = JmsConnectionPoolContainer.getPool(properties, sFactoryClass, sType, username, password, transacted);
}
}
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -162,18 +162,17 @@
}) ;
jmsConnection.start();
}
+ final boolean transacted = Boolean.valueOf(poolKey.get(JMSEpr.TRANSACTED_TAG));
//Create a new Session
ArrayList<Session> freeSessions = freeSessionsMap.get( acknowledgeMode );
if (JMSEpr.QUEUE_TYPE.equals(destinationType)) {
- logger.debug("Creating a new Queue session.");
- QueueSession session = ((QueueConnection)jmsConnection).createQueueSession(false,acknowledgeMode);
+ QueueSession session = ((QueueConnection)jmsConnection).createQueueSession(transacted,acknowledgeMode);
freeSessions.add(session);
} else if (JMSEpr.TOPIC_TYPE.equals(destinationType)) {
- logger.debug("Creating a new Topic session.");
- TopicSession session = ((TopicConnection) jmsConnection).createTopicSession(false,acknowledgeMode);
+ TopicSession session = ((TopicConnection) jmsConnection).createTopicSession(transacted,acknowledgeMode);
freeSessions.add(session);
} else {
throw new ConnectionException("Unknown destination type");
@@ -274,7 +273,9 @@
try
{
ArrayList<Session> sessions = freeSessionsMap.get(sessionToClose.getAcknowledgeMode());
- sessions.add(sessionToClose);
+ if ( sessions != null )
+ sessions.add(sessionToClose);
+
releaseSession(sessionToClose) ;
} catch (JMSException e)
{
@@ -291,7 +292,8 @@
try
{
ArrayList<Session> inUseSessions = inUseSessionsMap.get(sessionToClose.getAcknowledgeMode());
- inUseSessions.remove(sessionToClose);
+ if ( inUseSessions != null )
+ inUseSessions.remove(sessionToClose);
notifyAll() ;
} catch (JMSException e)
{
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolContainer.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolContainer.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolContainer.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -66,8 +66,12 @@
*/
public static JmsConnectionPool getPool(JMSEpr jmsEpr) throws ConnectionException, URISyntaxException
{
- return getPool(jmsEpr.getJndiEnvironment()
- , jmsEpr.getConnectionFactory(), jmsEpr.getDestinationType(), jmsEpr.getJMSSecurityPrincipal(), jmsEpr.getJMSSecurityCredential());
+ return getPool(jmsEpr.getJndiEnvironment(),
+ jmsEpr.getConnectionFactory(),
+ jmsEpr.getDestinationType(),
+ jmsEpr.getJMSSecurityPrincipal(),
+ jmsEpr.getJMSSecurityCredential(),
+ jmsEpr.getTransacted());
}
/**
* Returns the pool given the identifiers for the JMS provider.
@@ -81,8 +85,15 @@
public static JmsConnectionPool getPool(Properties enviroment, String connectionFactory, String destinationType)
throws ConnectionException
{
- return getPool(enviroment, connectionFactory, destinationType, null, null);
+ return getPool(enviroment, connectionFactory, destinationType, null, null, false);
}
+ public static JmsConnectionPool getPool(Properties enviroment, String connectionFactory, String destinationType,
+ final String username, final String password)
+ throws ConnectionException
+ {
+ return getPool( enviroment, connectionFactory, destinationType, username, password, false );
+
+ }
/**
* Returns the pool given the identifiers for the JMS provider.
*
@@ -91,14 +102,15 @@
* @param destinationType - destinationType(Queue or Topic) for which a JMSConnectionPool should be retreived
* @param username - username that should be used to create the JMS Connection
* @param password - password that should be used to create the JMS Connection
+ * @param transacted - should the JMS Session be transacted
* @return <code>JmsConnectionPool</code>
* @throws ConnectionException
*/
public static JmsConnectionPool getPool(Properties enviroment, String connectionFactory, String destinationType,
- final String username, final String password)
+ final String username, final String password, final boolean transacted)
throws ConnectionException
{
- Map<String,String> poolKey = createPoolKey(enviroment, connectionFactory, destinationType, username, password);
+ Map<String,String> poolKey = createPoolKey(enviroment, connectionFactory, destinationType, username, password, transacted);
final Map<Map<String, String>, JmsConnectionPool> poolMap = getMap() ;
if (poolMap.containsKey(poolKey)) {
return poolMap.get(poolKey);
@@ -118,7 +130,7 @@
*/
public static Map<String, String> createPoolKey(Properties environment, String connectionFactory, String destinationType)
{
- return createPoolKey( environment, connectionFactory, destinationType, null, null );
+ return createPoolKey( environment, connectionFactory, destinationType, null, null, false );
}
/**
* Creates a poolKey using the identifying parameters
@@ -131,7 +143,7 @@
* @return
*/
public static Map<String, String> createPoolKey(Properties environment, String connectionFactory, String destinationType,
- final String username, final String password)
+ final String username, final String password, final boolean transacted)
{
Map<String,String> poolKey = new HashMap<String,String>();
if (environment!=null) {
@@ -147,6 +159,9 @@
if (connectionFactory!=null) poolKey.put(JMSEpr.CONNECTION_FACTORY_TAG, connectionFactory);
if (destinationType!=null) poolKey.put(JMSEpr.DESTINATION_TYPE_TAG, destinationType);
+
+ poolKey.put(JMSEpr.TRANSACTED_TAG, String.valueOf(transacted));
+
return poolKey;
}
/**
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -88,6 +88,8 @@
public static final String PERSISTENT_TAG = "persistent";
+ public static final String TRANSACTED_TAG = "transacted";
+
/**
* JMS Client acknowledgment mode configuration tag
*/
@@ -203,6 +205,13 @@
} else if (tag.equals(DESTINATION_TYPE_TAG)) {
getAddr().addExtension(DESTINATION_TYPE_TAG, nl.item(i).getTextContent());
}
+ } else if (tag.equals(TRANSACTED_TAG)) {
+ boolean transacted = false;
+ final String transactedStr = nl.item(i).getTextContent();
+ if ( transactedStr != null )
+ transacted = Boolean.parseBoolean(transactedStr);
+
+ getAddr().addExtension(TRANSACTED_TAG, String.valueOf(transacted));
}
}
}
@@ -298,7 +307,7 @@
String destinationName, String connection, Properties environment,
String messageSelector, boolean peristent)
{
- this(protocol,destinationType,destinationName,connection,environment,messageSelector,peristent,DEFAULT_ACKNOWLEDGE_MODE);
+ this(protocol, destinationType, destinationName, connection, environment, messageSelector, peristent, DEFAULT_ACKNOWLEDGE_MODE);
}
/**
@@ -318,15 +327,72 @@
* reference to the connection factory.
* @param peristent
* true if messages should be sent persistently
+ */
+ public JMSEpr(String protocol, String destinationType,
+ String destinationName, String connection, Properties environment,
+ String messageSelector, boolean peristent,
+ boolean transacted)
+ {
+ this(protocol, destinationType, destinationName, connection, environment, messageSelector, peristent, DEFAULT_ACKNOWLEDGE_MODE, transacted);
+ }
+
+ /**
+ * Create a new JMS EPR.
+ *
+ * @param protocol
+ * the protocol version.
+ * @param destinationType
+ * the type of destination (queue/topic).
+ * @param destinationName
+ * name of the queue/topic.
+ * @param connection
+ * reference to the connection factory.
+ * @param environment
+ * reference to the jndi properties
+ * @param messageSelector
+ * reference to the connection factory.
+ * @param peristent
+ * true if messages should be sent persistently
* @param acknowledgeModeStr
* JMS client acknowledgement mode
+ * @param transacted
+ * true if the jms session should be transaction aware
*/
public JMSEpr(String protocol, String destinationType,
String destinationName, String connection, Properties environment,
+ String messageSelector, boolean peristent, String acknowledgeModeStr,
+ boolean transacted)
+ {
+ this( protocol, destinationType, destinationName, connection, environment,
+ messageSelector, peristent, acknowledgeModeStr, null, null, transacted );
+ }
+
+ /**
+ * Create a new JMS EPR.
+ *
+ * @param protocol
+ * the protocol version.
+ * @param destinationType
+ * the type of destination (queue/topic).
+ * @param destinationName
+ * name of the queue/topic.
+ * @param connection
+ * reference to the connection factory.
+ * @param environment
+ * reference to the jndi properties
+ * @param messageSelector
+ * reference to the connection factory.
+ * @param peristent
+ * true if messages should be sent persistently
+ * @param acknowledgeModeStr
+ * JMS client acknowledgement mode
+ */
+ public JMSEpr(String protocol, String destinationType,
+ String destinationName, String connection, Properties environment,
String messageSelector, boolean peristent, String acknowledgeModeStr)
{
this( protocol, destinationType, destinationName, connection, environment,
- messageSelector, peristent, acknowledgeModeStr, null, null );
+ messageSelector, peristent, acknowledgeModeStr, null, null, false );
}
/**
@@ -349,14 +415,52 @@
* @param acknowledgeModeStr
* JMS client acknowledgement mode
* @param username
+ * username to use when creating JMS connections
+ * @param password
+ * password to use when creating JMS connections
+ */
+ public JMSEpr(String protocol, String destinationType,
+ String destinationName, String connection, Properties environment,
+ String messageSelector, boolean peristent, String acknowledgeModeStr,
+ String username, String password)
+ {
+ this( protocol, destinationType, destinationName, connection, environment,
+ messageSelector, peristent, acknowledgeModeStr, username, password, false );
+
+ }
+
+ /**
+ * Create a new JMS EPR.
+ *
+ * @param protocol
+ * the protocol version.
+ * @param destinationType
+ * the type of destination (queue/topic).
+ * @param destinationName
+ * name of the queue/topic.
+ * @param connection
+ * reference to the connection factory.
+ * @param environment
+ * reference to the jndi properties
+ * @param messageSelector
+ * reference to the connection factory.
+ * @param peristent
+ * true if messages should be sent persistently
+ * @param acknowledgeModeStr
+ * JMS client acknowledgement mode
+ * @param username
* JMS destination username
* @param password
* JMS destination password
+ * @param transacted
+ * true if the jms session should be transaction aware
+ *
*/
public JMSEpr(String protocol, String destinationType,
String destinationName, String connection, Properties environment,
String messageSelector, boolean peristent, String acknowledgeModeStr,
- String username, String password)
+ String username, String password,
+ boolean transacted)
{
// how many of these do we really need? modify accordingly.
@@ -421,6 +525,8 @@
if(password != null)
addr.addExtension(JMS_SECURITY_CREDENTIAL_TAG, password);
+
+ addr.addExtension(TRANSACTED_TAG, String.valueOf(transacted));
}
else
@@ -568,6 +674,14 @@
final String password = getAddr().getExtensionValue(JMS_SECURITY_CREDENTIAL_TAG);
return password == null || password.equals("null") ? null : password;
}
+
+ /**
+ * @return the delivery mode
+ */
+ public final boolean getTransacted()
+ {
+ return Boolean.parseBoolean(getAddr().getExtensionValue(TRANSACTED_TAG));
+ }
public EPR copy ()
{
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -144,7 +144,8 @@
Boolean.valueOf(tree.getAttribute(JMSEpr.PERSISTENT_TAG)),
tree.getAttribute(JMSEpr.ACKNOWLEDGE_MODE_TAG),
username,
- password);
+ password,
+ Boolean.valueOf(tree.getAttribute(JMSEpr.TRANSACTED_TAG)));
return epr;
}
catch (Exception e)
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -147,6 +147,7 @@
toElement.setAttribute(JMSEpr.ACKNOWLEDGE_MODE_TAG, messageFilter.getAcknowledgeMode());
toElement.setAttribute(JMSEpr.JMS_SECURITY_PRINCIPAL_TAG, messageFilter.getJmsSecurityPrincipal());
toElement.setAttribute(JMSEpr.JMS_SECURITY_CREDENTIAL_TAG, messageFilter.getJmsSecurityCredential());
+ toElement.setAttribute(JMSEpr.TRANSACTED_TAG, Boolean.toString( messageFilter.getTransacted()));
}
private static void mapJmsJcaAttributes(final JmsListener listener,
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetter.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetter.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetter.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -34,6 +34,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.addressing.eprs.JMSEpr;
import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.jboss.soa.esb.message.Properties;
import org.jboss.soa.esb.notification.jms.JMSPropertiesSetter;
/**
@@ -45,6 +46,7 @@
* <li> JMSCorrelationID -> Call.setRelatesTo URI = jms:correlationID#YYXX-123456780-GG
* <li> JMSReplyTo -> Call.setReplyTo
* <li> JMSExpiration -> Properties( key = JMSPropertiesSetter.JMS_EXPIRATION )
+ * <li> JMSRedeliverd -> Properties( key = JMSPropertiesSetter.JMS_REDELIVERED
* </lu>
* Note: JMSCorrelationID is set as a fragment on the URI and can be retrieved like this:
* correlationURI.getFragment();
@@ -141,6 +143,7 @@
{
@SuppressWarnings("unchecked")
Enumeration<String> properties = fromJMSMessage.getPropertyNames();
+ Properties esbProperties = toESBMessage.getProperties();
if (null != properties)
{
while (properties.hasMoreElements())
@@ -148,9 +151,11 @@
String key = properties.nextElement();
Object value = fromJMSMessage.getObjectProperty(key);
if (null != value)
- toESBMessage.getProperties().setProperty(key, value);
+ esbProperties.setProperty(key, value);
}
}
+ final boolean redelivered = fromJMSMessage.getJMSRedelivered();
+ esbProperties.setProperty( JMSPropertiesSetter.JMS_REDELIVERED, Boolean.valueOf( redelivered ));
}
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -39,6 +39,7 @@
import javax.jms.Session;
import javax.jms.Topic;
import javax.jms.TopicSession;
+import javax.jms.XASession;
import javax.naming.Context;
import javax.naming.NamingException;
@@ -146,8 +147,12 @@
if (null != msgIn) {
try {
- Object obj = _processMethod.invoke(_composer, new Object[]
- {msgIn});
+ Object obj = _processMethod.invoke(_composer, new Object[] {msgIn});
+ // commit and acknowledge the reception of the message
+ // this is done after extracting the content of the JMS Message.
+ if ( jmsSession != null && jmsSession.getTransacted() )
+ jmsSession.commit();
+
if (null == obj) {
_logger.warn("Action class method <"
+ _processMethod.getName()
@@ -190,6 +195,8 @@
_logger.error("Action class method <"
+ _processMethod.getName()
+ "> returned a non Message object", e);
+
+ rollbackJMSTransaction();
continue;
}
catch (CourierException e) {
@@ -198,6 +205,7 @@
+ ".deliverAsync(Message) FAILED"
: "NULL courier can't deliverAsync Message";
_logger.error(text, e);
+ rollbackJMSTransaction();
continue;
}
continue;
@@ -205,13 +213,16 @@
catch (InvocationTargetException e) {
_logger.error("Problems invoking method <"
+ _processMethod.getName() + ">", e);
+ rollbackJMSTransaction();
}
catch (IllegalAccessException e) {
_logger.error("Problems invoking method <"
+ _processMethod.getName() + ">", e);
+ rollbackJMSTransaction();
}
catch (Exception e) {
_logger.error("Unexpected problem", e);
+ rollbackJMSTransaction();
}
}
}
@@ -228,13 +239,32 @@
protected void doThreadedDestroy() throws ManagedLifecycleException {
cleanup();
}
+
+ private void rollbackJMSTransaction()
+ {
+ try
+ {
+ if ( jmsSession != null && jmsSession.getTransacted() )
+ jmsSession.rollback();
+ } catch (JMSException e) {
+ final String errorMsg = "JMSException during jmsSession.rollback()";
+ _logger.error( errorMsg, e );
+ }
+ }
+
private void cleanup() {
try {
if (_serviceName != null) {
RegistryUtil.unregister(_serviceCategory, _serviceName, _myEpr);
}
- } finally {
+ if ( jmsSession != null && jmsSession.getTransacted() )
+ jmsSession.rollback();
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ } finally {
try {
if (jmsMessageConsumer != null) {
try {
@@ -364,6 +394,8 @@
String destType = _config.getAttribute(JMSEpr.DESTINATION_TYPE_TAG);
boolean persistent = Boolean.valueOf( _config.getAttribute(JMSEpr.PERSISTENT_TAG));
+ boolean transacted = Boolean.valueOf( _config.getAttribute(JMSEpr.TRANSACTED_TAG));
+
String acknowledgeMode = _config.getAttribute(JMSEpr.ACKNOWLEDGE_MODE_TAG);
final String username = _config.getAttribute( JMSEpr.JMS_SECURITY_PRINCIPAL_TAG );
@@ -373,11 +405,12 @@
environment.put( JMSEpr.JMS_SECURITY_PRINCIPAL_TAG, username );
environment.put( JMSEpr.JMS_SECURITY_CREDENTIAL_TAG, password );
}
+ _logger.debug( "JMSGateway isTransacted = " + transacted );
_myEpr = (null == _serviceName) ? null : new JMSEpr(JMSEpr.ONE_ONE_PROTOCOL, destType,
jmsDestinationName, sFactClass, environment, _messageSelector, persistent, acknowledgeMode,
- username, password);
- jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment, sFactClass, destType,username, password);
+ username, password, transacted );
+ jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment, sFactClass, destType,username, password, transacted);
try {
jmsSession = _myEpr != null ? jmsConnectionPool.getSession(((JMSEpr)_myEpr).getAcknowledgeMode()):
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -48,14 +48,15 @@
{
private Logger log = Logger.getLogger( DefaultJMSPropertiesSetter.class );
- /**
- * Client JMSX Group ID.
- */
- private static final String JMSX_GROUP_ID = "JMSXGroupID" ;
- /**
- * Client JMSX Group Seq.
- */
- private static final String JMSX_GROUP_SEQ = "JMSXGroupSeq" ;
+ /**
+ * Client JMSX Group ID.
+ */
+ private static final String JMSX_GROUP_ID = "JMSXGroupID" ;
+ /**
+ * Client JMSX Group Seq.
+ */
+ private static final String JMSX_GROUP_SEQ = "JMSXGroupSeq" ;
+
/**
* Set JMS Header fields on the outgoing JMS Message.
* </p>
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/JMSPropertiesSetter.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/JMSPropertiesSetter.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/JMSPropertiesSetter.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -40,6 +40,12 @@
String JMS_EXPIRATION = "javax.jms.message.expiration";
/**
+ * Key used when setting the JMSRedelivered as a
+ * property on an ESB Message instance.
+ */
+ String JMS_REDELIVERED = "javax.jms.message.redelivered";
+
+ /**
* Sets JMS properties fields on the outgoing JMS Message.
* </p>
*
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/JmsCourierIntegrationTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/JmsCourierIntegrationTest.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/JmsCourierIntegrationTest.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,84 @@
+/*
+ * 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.internal.soa.esb.couriers;
+
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Unit test for JmsCourier
+ *
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class JmsCourierIntegrationTest
+{
+ @SuppressWarnings("unused")
+ private Logger log = Logger.getLogger( JmsCourierIntegrationTest.class );
+
+ private JmsCourier jmsCourier;
+
+ @Test
+ public void getJmsSession() throws CourierException, JMSException
+ {
+ Session jmsSession = jmsCourier.getJmsSession();
+ assertTrue( jmsSession.getTransacted() );
+ jmsCourier.cleanup();
+ }
+
+ @Before
+ public void createJmsCourierInstance() throws CourierException
+ {
+ final Properties env = null;
+ final String messageSelector = null;
+ final boolean persistent = true;
+ final boolean transacted = true;
+ JMSEpr epr = new JMSEpr(JMSEpr.ONE_ONE_PROTOCOL,
+ JMSEpr.QUEUE_TYPE,
+ "queue/A",
+ "ConnectionFactory",
+ env,
+ messageSelector,
+ persistent,
+ transacted);
+ jmsCourier = new JmsCourier( epr );
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter( JmsCourierIntegrationTest.class );
+ }
+
+}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolContainerUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolContainerUnitTest.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolContainerUnitTest.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -74,12 +74,31 @@
final String password = "passwd";
final Properties env = null;
Map<String, String> poolKey = JmsConnectionPoolContainer.createPoolKey( env, connectionFactory, QUEUE_TYPE,
- username, password);
+ username, password, false);
assertEquals( username, poolKey.get( JMSEpr.JMS_SECURITY_PRINCIPAL_TAG ) );
assertEquals( password, poolKey.get( JMSEpr.JMS_SECURITY_CREDENTIAL_TAG ) );
}
+ @Test
+ public void createPoolKey_with_transacted_properties()
+ {
+ final boolean transacted = true;
+ final Properties env = null;
+ Map<String, String> poolKey = JmsConnectionPoolContainer.createPoolKey( env, connectionFactory, QUEUE_TYPE,
+ null, null, transacted);
+ assertEquals( transacted, Boolean.valueOf ( poolKey.get( JMSEpr.TRANSACTED_TAG ) ) );
+ }
+ @Test
+ public void createPoolKey_with_non_transacted_properties()
+ {
+ final boolean transacted = false;
+ final Properties env = null;
+ Map<String, String> poolKey = JmsConnectionPoolContainer.createPoolKey( env, connectionFactory, QUEUE_TYPE,
+ null, null, transacted);
+ assertEquals( transacted, Boolean.valueOf ( poolKey.get( JMSEpr.TRANSACTED_TAG ) ) );
+ }
+
public static junit.framework.Test suite()
{
return new JUnit4TestAdapter( JmsConnectionPoolContainerUnitTest.class );
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/JMSEprUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/JMSEprUnitTest.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/JMSEprUnitTest.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -208,6 +208,29 @@
assertEquals( Session.DUPS_OK_ACKNOWLEDGE, ackMode.getAcknowledgeModeInt() );
}
+ @Test
+ public void contstructor_non_transacted() throws CourierException, URISyntaxException
+ {
+ JMSEpr jmsEpr = new JMSEpr( ONE_ONE_PROTOCOL, expectedDestinationType, expectedDestination ,
+ expectedConnectionFactory,
+ nullEnvironment, expectedSelector,
+ NON_PERSISTENT);
+
+ assertEquals( false, jmsEpr.getTransacted() );
+ }
+
+ @Test
+ public void contstructor_transacted() throws CourierException, URISyntaxException
+ {
+ final boolean transacted = true;
+ JMSEpr jmsEpr = new JMSEpr( ONE_ONE_PROTOCOL, expectedDestinationType, expectedDestination ,
+ expectedConnectionFactory,
+ nullEnvironment, expectedSelector,
+ NON_PERSISTENT, transacted);
+
+ assertEquals( transacted, jmsEpr.getTransacted() );
+ }
+
private void assertDefaults(final String destination, final String connectionFactory, final String destinationType)
{
assertEquals( expectedDestination, destination );
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_esbaware.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_esbaware.xml 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_esbaware.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -5,7 +5,7 @@
-->
<jbossesb-listeners parameterReloadSecs="180">
<Bank-Listener listenerClass="org.jboss.soa.esb.listeners.message.MessageAwareListener" maxThreads="2" service-category="Bank" service-description="Bank Reconciliation Service" service-name="Reconciliation">
-<EPR acknowledge-mode="AUTO_ACKNOWLEDGE" connection-factory="ConnectionFactory" destination-name="queue/B" destination-type="topic" jndi-URL="jnp://localhost:1099" message-selector="service='Reconciliation'" persistent="true" protocol="jms"/>
+<EPR acknowledge-mode="AUTO_ACKNOWLEDGE" connection-factory="ConnectionFactory" destination-name="queue/B" destination-type="topic" jndi-URL="jnp://localhost:1099" message-selector="service='Reconciliation'" persistent="true" protocol="jms" transacted="false"/>
<action action="TestDefaultRouteAction" class="org.jboss.soa.esb.actions.ContentBasedRouter" propName="propValue">
This is some complex..
<!-- property -->
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_gateways.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_gateways.xml 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_gateways.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8"?><!-- NOTE: DO NOT MODIFY This file was auto-generated.--><jbossesb-gateways parameterReloadSecs="180"><Bank-JMS-Gateway acknowledge-mode="AUTO_ACKNOWLEDGE" connection-factory="com.xyz.provider.XYZConnectionFactory" destination-name="queue/A" destination-type="queue" gatewayClass="org.jboss.soa.esb.listeners.gateway.JmsGatewayListener" is-gateway="true" jndi-URL="xyz://server1:9876" jndi-context-factory="com.xyz.provider.NamingContextFactory" jndi-pkg-prefix="com.xyz" maxThreads="1" message-selector="service='Reconciliation'" persistent="true" protocol="jms" service-description="Bank Reconciliation Service" target-service-category="Bank" target-service-name="Reconciliation"/><Bank-HTTP-Gateway gatewayClass="org.jboss.soa.esb.listeners.gateway.JBossRemotingGatewayListener" is-gateway="true" jbr-serverBindAddress="192.168.1.111" jbr-serverBindPort="8765" jbr-serverProtocol="http" maxThreads="1" service-description="Bank Reconciliation Serv!
ice" target-service-category="Bank" target-service-name="Reconciliation"/></jbossesb-gateways>
+<?xml version="1.0" encoding="UTF-8"?><!-- NOTE: DO NOT MODIFY This file was auto-generated.--><jbossesb-gateways parameterReloadSecs="180"><Bank-JMS-Gateway acknowledge-mode="AUTO_ACKNOWLEDGE" connection-factory="com.xyz.provider.XYZConnectionFactory" destination-name="queue/A" destination-type="queue" gatewayClass="org.jboss.soa.esb.listeners.gateway.JmsGatewayListener" is-gateway="true" jndi-URL="xyz://server1:9876" jndi-context-factory="com.xyz.provider.NamingContextFactory" jndi-pkg-prefix="com.xyz" maxThreads="1" message-selector="service='Reconciliation'" persistent="true" protocol="jms" service-description="Bank Reconciliation Service" target-service-category="Bank" target-service-name="Reconciliation" transacted="false"/><Bank-HTTP-Gateway gatewayClass="org.jboss.soa.esb.listeners.gateway.JBossRemotingGatewayListener" is-gateway="true" jbr-serverBindAddress="192.168.1.111" jbr-serverBindPort="8765" jbr-serverProtocol="http" maxThreads="1" service-description="Bank !
Reconciliation Service" target-service-category="Bank" target-service-name="Reconciliation"/></jbossesb-gateways>
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_02.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_02.xml 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_02.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -13,6 +13,7 @@
<property name="message-selector" value="service='Reconciliation'"/>
<property name="persistent" value="true" />
<property name="acknowledge-mode" value="AUTO_ACKNOWLEDGE" />
+ <property name="transacted" value="false" />
</bus>
</bus-provider>
@@ -29,6 +30,7 @@
<property name="message-selector" value="service='Reconciliation'" />
<property name="persistent" value="true" />
<property name="acknowledge-mode" value="AUTO_ACKNOWLEDGE" />
+ <property name="transacted" value="false" />
</bus>
</bus-provider>
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetterUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetterUnitTest.java 2008-01-15 16:19:52 UTC (rev 17868)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetterUnitTest.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -128,6 +128,17 @@
assertEquals( propertyValue, toESBMessage.getProperties().getProperty( propertyKey )) ;
}
+ @Test
+ public void setPropertiesFromJMSMessage_withJMSRedelivererdProperty_false() throws JMSException
+ {
+ boolean redelivered = false;
+ fromJMSTextMessage.setJMSRedelivered( redelivered );
+
+ strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
+
+ assertEquals( redelivered, toESBMessage.getProperties().getProperty( JMSPropertiesSetter.JMS_REDELIVERED )) ;
+ }
+
@Before
public void setup()
{
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/build.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/build.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,70 @@
+<project name="Quickstart_JMS_Transacted" default="deploy" basedir=".">
+
+ <description>
+ ${ant.project.name}
+ ${line.separator}
+ </description>
+
+ <property name="additional.deploys" value="jbossesb-service.xml" />
+
+ <!-- Import the base Ant build script... -->
+ <import file="../conf/base-build.xml"/>
+
+ <target name="quickstart-specific-deploys">
+ <copy file="quickstart-ds.xml"
+ todir="${org.jboss.esb.server.deploy.dir}"
+ overwrite="false"/>
+ </target>
+
+ <target name="quickstart-specific-undeploys">
+ <delete file="${org.jboss.esb.server.deploy.dir}/quickstart-ds.xml"/>
+ </target>
+
+ <target name="runtest" depends="compile"
+ description="sends a JMS message to queue/quickstart_jms_transacted_Request_gw">
+ <echo>Runs Test JMS Sender</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.jmstransacted.test.SendJMSMessage" failonerror="true">
+ <arg value="Hello Transacted JMS World]"/>
+ <classpath refid="exec-classpath"/>
+ </java>
+ </target>
+
+ <target name="select" depends="dependencies" description="select * from jsm_transacted_table">
+ <property name="hsqldb.jar"
+ value="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/lib/hsqldb.jar"/>
+ <echo>Select * from jms_transacted_table</echo>
+ <sql
+ print="true"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost:1703"
+ userid="sa"
+ autocommit="true"
+ password="">
+ <classpath>
+ <pathelement path="${hsqldb.jar}"/>
+ </classpath>
+ <transaction>
+ select data_column from jms_transacted_table
+ </transaction>
+ </sql>
+
+ </target>
+
+ <target name="truncate" depends="dependencies" description="delete from jms_transacted_table">
+ <property name="hsqldb.jar"
+ value="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/lib/hsqldb.jar"/>
+ <echo>Delete from jms_transacted_table </echo>
+ <sql
+ print="true"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost:1703"
+ userid="sa"
+ autocommit="true"
+ password="">
+ <classpath>
+ <pathelement path="${hsqldb.jar}"/>
+ </classpath>
+ <transaction>delete from jms_transacted_table</transaction>
+ </sql>
+ </target>
+</project>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/deployment.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/deployment.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/deployment.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,4 @@
+<jbossesb-deployment>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_transacted_Request_esb</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_transacted_Request_gw</depends>
+</jbossesb-deployment>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbm-queue-service.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbm-queue-service.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbm-queue-service.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_transacted_Request_gw"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_transacted_Request_esb"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+</server>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbmq-queue-service.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbmq-queue-service.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbmq-queue-service.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_transacted_Request_gw">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_transacted_Request_esb">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+</server>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jboss-esb.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jboss-esb.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jboss-esb.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,71 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
+
+ <providers>
+ <jms-jca-provider name="JBossMessaging" connection-factory="XAConnectionFactory"
+ jndi-URL="jnp://127.0.0.1:1099" jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-pkg-prefix="org.jboss.naming:org.jnp.interfaces">
+
+ <jms-bus busid="quickstartGwChannel">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/quickstart_jms_transacted_Request_gw"
+ transacted="true"
+ />
+ </jms-bus>
+ <jms-bus busid="quickstartEsbChannel">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/quickstart_jms_transacted_Request_esb"
+ transacted="true"
+ />
+ </jms-bus>
+
+ </jms-jca-provider>
+ </providers>
+
+ <services>
+ <service
+ category="JMSSecuredESB"
+ name="SimpleListener"
+ description="JMS Secured quickstart sample">
+ <listeners>
+ <jms-listener name="JMS-Gateway"
+ busidref="quickstartGwChannel"
+ maxThreads="1"
+ is-gateway="true"
+ />
+ <jms-listener name="jmssecured"
+ busidref="quickstartEsbChannel"
+ maxThreads="1"/>
+ </listeners>
+ <actions mep="OneWay">
+
+ <action name="printMessage" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message" value="JMS Transacted Quickstart start..."/>
+ <property name="printfull" value="false"/>
+ </action>
+
+ <action name="insertDBAction" class="org.jboss.soa.esb.samples.quickstart.jmstransacted.test.DBInsertAction">
+ <property name="datasource-name" value="java:QuickstartDS"/>
+ <property name="db-insert-sql" value="insert into jms_transacted_table(data_column) values(?)"/>
+ </action>
+
+ <!--
+ Will throw an Exception upon every other first. This should trigger the transaction to be
+ rolledback and the message placed back onto the JMS queue.
+ -->
+ <action name="throwExceptionAction" class="org.jboss.soa.esb.samples.quickstart.jmstransacted.test.ThrowExceptionAction"/>
+
+ <action name="printMessageDone" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message" value="JMS Transacted Quickstart processed sucessfully"/>
+ <property name="printfull" value="false"/>
+ </action>
+
+ <!-- The next action is for Continuous Integration testing -->
+ <action name="testStore" class="org.jboss.soa.esb.actions.StoreMessageToFile"/>
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbossesb-properties.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbossesb-properties.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.type" value="jboss"/>
+ <property name="org.jboss.soa.esb.jndi.server.url" value="localhost"/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI"
+ value="jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI"
+ value="jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish" />
+ <property name="org.jboss.soa.esb.registry.implementationClass"
+ value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass"
+ value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user"
+ value="jbossesb"/>
+ <property name="org.jboss.soa.esb.registry.password"
+ value="password"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass"
+ value="org.apache.ws.scout.transport.RMITransport"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool=size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="dbstore">
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <!-- # of milliseconds to timeout waiting for a connection from pool -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/>
+ </properties>
+ <properties name="messagerouting">
+ <property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
+ </properties>
+</esb>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbossesb-service.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbossesb-service.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jbossesb-service.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+ <mbean code="org.jboss.internal.soa.esb.dependencies.DatabaseInitializer"
+ name="jboss.esb:service=QuickstartDatabaseInitializer">
+ <attribute name="Datasource">java:/QuickstartDS</attribute>
+ <attribute name="ExistsSql">select * from jms_transacted_table</attribute>
+ <attribute name="SqlFiles">
+ hsqldb/create.sql
+ </attribute>
+ <depends>jboss.jca:name=QuickstartDS,service=DataSourceBinding</depends>
+ </mbean>
+</server>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jndi.properties
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jndi.properties (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/jndi.properties 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,5 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+java.naming.factory.url.pkgs=org.jnp.interfaces
+
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/juddi.properties
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/juddi.properties (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/juddi.properties 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,69 @@
+# jUDDI Registry Properties (used by RegistryServer)
+# see http://www.juddi.org for more information
+
+# The UDDI Operator Name
+juddi.operatorName = jUDDI.org
+
+# The i18n locale default codes
+juddi.i18n.languageCode = en
+juddi.i18n.countryCode = US
+
+# The UDDI DiscoveryURL Prefix
+juddi.discoveryURL = http://localhost:8080/juddi/uddiget.jsp?
+
+# The UDDI Operator Contact Email Address
+juddi.operatorEmailAddress = admin at juddi.org
+
+# The maximum name size and maximum number
+# of name elements allows in several of the
+# FindXxxx and SaveXxxx UDDI functions.
+juddi.maxNameLength=255
+juddi.maxNameElementsAllowed=5
+
+# The maximum number of UDDI artifacts allowed
+# per publisher. A value of '-1' indicates any
+# number of artifacts is valid (These values can be
+# overridden at the individual publisher level).
+juddi.maxBusinessesPerPublisher=25
+juddi.maxServicesPerBusiness=20
+juddi.maxBindingsPerService=10
+juddi.maxTModelsPerPublisher=100
+
+# jUDDI Authentication module to use
+juddi.auth = org.apache.juddi.auth.DefaultAuthenticator
+
+# jUDDI DataStore module currently to use
+juddi.dataStore = org.apache.juddi.datastore.jdbc.JDBCDataStore
+
+# use a dataSource (if set to false a direct
+# jdbc connection will be used.
+juddi.isUseDataSource=false
+juddi.jdbcDriver=com.mysql.jdbc.Driver
+juddi.jdbcUrl=jdbc:mysql://localhost:3306/juddi
+juddi.jdbcUsername=root
+juddi.jdbcPassword=admin
+# jUDDI DataSource to use
+# juddi.dataSource=java:comp/env/jdbc/MySqlDS
+
+# jUDDI UUIDGen implementation to use
+juddi.uuidgen = org.apache.juddi.uuidgen.DefaultUUIDGen
+
+# jUDDI Cryptor implementation to use
+juddi.cryptor = org.apache.juddi.cryptor.DefaultCryptor
+
+# jUDDI Validator to use
+juddi.validator=org.apache.juddi.validator.DefaultValidator
+
+# jUDDI Proxy Properties (used by RegistryProxy)
+juddi.proxy.adminURL = http://localhost:8080/juddi/admin
+juddi.proxy.inquiryURL = http://localhost:8080/juddi/inquiry
+juddi.proxy.publishURL = http://localhost:8080/juddi/publish
+juddi.proxy.transportClass = org.apache.juddi.proxy.AxisTransport
+juddi.proxy.securityProvider = com.sun.net.ssl.internal.ssl.Provider
+juddi.proxy.protocolHandler = com.sun.net.ssl.internal.www.protocol
+
+# JNDI settings (used by RMITransport)
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/log4j.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/log4j.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/log4j.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A size based file rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="./listener.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%t][%c] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="WARN"/>
+ </category>
+ <category name="org.jboss.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.jboss.internal.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.apache">
+ <priority value="ERROR"/>
+ </category>
+ <category name="quickstart">
+ <priority value="DEBUG"/>
+ </category>
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/quickstart-ds.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/quickstart-ds.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/quickstart-ds.xml 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+ <local-tx-datasource>
+ <jndi-name>QuickstartDS</jndi-name>
+ <connection-url>jdbc:hsqldb:hsql://${jboss.bind.address}:1703</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ <idle-timeout-minutes>0</idle-timeout-minutes>
+ <depends>jboss:service=Hypersonic</depends>
+ <prepared-statement-cache-size>32</prepared-statement-cache-size>
+ </local-tx-datasource>
+
+ <!-- For hsqldb accessed from jboss only, in-process (standalone) mode -->
+ <mbean code="org.jboss.jdbc.HypersonicDatabase"
+ name="jboss:service=Hypersonic">
+ <attribute name="Port">1703</attribute>
+ <attribute name="BindAddress">${jboss.bind.address}</attribute>
+ <attribute name="Database">QuickstartDB</attribute>
+ <attribute name="Silent">true</attribute>
+ <attribute name="Trace">false</attribute>
+ <attribute name="No_system_exit">true</attribute>
+ </mbean>
+</datasources>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/readme.txt
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/readme.txt (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/readme.txt 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,111 @@
+Overview:
+=========
+ The purpose of the jms_transacted quickstart is to show how the JMS transport
+ in the ESB can be configured to use transactions and how redelivery can be
+ accomplished by taking advantage of the JMS transport.
+
+ This quickstart consists of a single service that contains 4 actions:
+ 1. Log a statement that we have entered the quickstart.
+ 2. Insert the contents of the ESB Message object to a database table
+ 3. Call a custom action that throws an exception if the message has not
+ been redelivered. (more on this later)
+ 4. Log a statement that we are about to exit the quickstart.
+
+ The main thing to look for is that the first time we enter the action processing
+ pipleline, we insert a row into the database, but since the commit is not done
+ until the whole pipeline has been executed (as we are using the jms-jca-provider)
+ the commit for this insert is not performed. The same goes for the message
+ acknowledement of the JMS Message, which in turn causes the JMS message to be
+ put back onto the queue.
+
+ For more details about how this quickstart works look at the
+ "What to look at in this Quckstart" section below.
+
+ This quickstart uses jms-jca-provider and more information about jms jca can
+ be found here: http://wiki.jboss.org/wiki/Wiki.jsp?page=UsingJCAWithJBossESB
+
+Running this quickstart:
+========================
+ Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
+ and a more detailed descripton of the different ways to run the quickstarts.
+
+To Run '.esb' archive mode:
+===========================
+ 1. In a command terminal window in this folder ("Window1"), type:
+ 'ant deploy'
+ This will deploy the quickstart
+ 2. Open another command terminal window in this folder ("Window2"), type:
+ 'ant runtest'
+ 3. Switch back to Application Server console to see the output from the ESB
+ 4. In this folder ("Window1"), type:
+ 'ant select'
+ This will display the content of the database table
+ 5. [optional] In this folder ("Window1"), type:
+ 'ant truncate'
+ This will delete the content of the database table.
+ 6. In this folder ("Window1"), type:
+ 'ant undeploy'
+ This will undeploy the quickstart.
+
+What to look at in this Quickstart:
+===================================
+ 1. DBInsertAction
+ Inserts the contents of the ESB Message object into the database table
+ by using the sql statement defined in the property 'db-insert-sql'.
+ This class contains a counter that is incremented for each call. This
+ counter is added to the text inserted into the table. The string looks
+ like this:
+ [Hello Transacted JMS World] counter[1]] // counter == 1;
+ This is done to seperate the inserts and visually verify that the correct
+ data is committed to the database. In a normal run, when the counter is
+ '1', the counter should be 2 indicating that only the second commit succeeded.
+
+ 2. ThrowExceptionAction
+ Checks if the ESB Messae property 'javax.jms.message.redelivered'
+ is false, in which case an IllegalArgumentException will be thrown.
+ This will will cause the message to be redelivered by JMS transaction handling.
+
+ 3. jboss-esb.xml
+ The message-filter for the jms-bus-filter now specifies 'transacted' attribute.
+
+ 4. 'ant select'
+ Ant target that will display all the rows in the database table.
+
+ 5. 'ant truncate'
+ Ant target that will delete all the rows in the database table.
+ Useful to clear the table after multiple runs.
+
+
+Inside look:
+============
+ 1. Transactions with JMSGateway
+
+ Lets walk through a client publishing a message to a queue. The queue
+ will be the queue that our gateway is configured to listen on.
+
+ 1. Client publishes message to JMS queue. It can use a JMS session that
+ is transacted to do so or not. It does not matter.
+ 2. The gateway listener will create a JMS session, or use an existing
+ session from the pool, that is transacted. While the JMS Listener
+ is running it will consume a JMS message from the queue, package the
+ contents of that JMS message into an ESB Message, and use a courier to
+ pass the message on to the action pipeline.
+
+ Commit:
+ When the message has be sent to the courier, and no exception has
+ been thrown, the transaction will commit and acknowledge that it
+ has accepted the JMS Message.
+
+ Rollback:
+ But if an exception has occurred, the transaction will be rolled-back
+ and the JMS message will not be acknowledged, hence it will be put
+ back on the queue.
+
+ Usecase for transactions in JMSGateway
+ Now, this situation may seem far fetched, but one usecase for
+ it might be that the task of packaging the content of the JMS
+ Message into the ESB Message is a memory intensive process.
+ Lets say that one of your machines is under more heavy load then others
+ which could cause it to throw an OutOfMemory Exception. In this case the
+ message could be picked up by another ESB instance, which hopefully
+ can deal with the message.
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/hsqldb/create.sql
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/hsqldb/create.sql (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/hsqldb/create.sql 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,5 @@
+create table jms_transacted_table
+(
+unique_id INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY,
+data_column VARCHAR(255) NOT NULL
+);
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/DBInsertAction.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/DBInsertAction.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/DBInsertAction.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,106 @@
+/*
+ * 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.jmstransacted.test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionLifecycle;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ *
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class DBInsertAction implements ActionLifecycle
+{
+ private Logger log = Logger.getLogger( DBInsertAction.class );
+
+ private String sql;
+ private String dataSourceName;
+
+ private int counter = 1;
+
+ public DBInsertAction(final ConfigTree config) throws ConfigurationException
+ {
+ dataSourceName = config.getRequiredAttribute( "datasource-name" );
+ sql = config.getRequiredAttribute( "db-insert-sql" );
+
+ }
+
+ public Message process( final Message message ) throws ActionProcessingException
+ {
+ Connection con = null;
+ PreparedStatement stmnt = null;
+ final String inputText = message.getBody().get() + " counter[" + counter + "]";
+ try
+ {
+ con = getConnection();
+ stmnt = con.prepareStatement( sql );
+ stmnt.setString( 1, inputText );
+ int executeUpdate = stmnt.executeUpdate();
+
+ if ( executeUpdate == 1 )
+ log.info("Successfully inserted [" + inputText + "] into jms_transacted_table");
+ else
+ log.info("Failed to inserted [" + inputText + "] into jms_transacted_table");
+
+ counter++;
+ }
+ catch (Exception e)
+ {
+ log.error( "Exception " , e );
+ throw new ActionProcessingException( e );
+ }
+ finally
+ {
+ if (stmnt != null) try { stmnt.close();} catch (SQLException e) { log.warn( e ); /* ignore */ }
+ if (con != null) try { con.close(); } catch (SQLException e) { log.warn( e ); /* ignore */ }
+ }
+
+ return message;
+ }
+
+ public void destroy() throws ActionLifecycleException { }
+
+ public void initialise() throws ActionLifecycleException { }
+
+ private Connection getConnection() throws NamingException, SQLException
+ {
+ Context ctx = new InitialContext();
+ DataSource ds = (DataSource)ctx.lookup( dataSourceName );
+ return ds.getConnection();
+ }
+
+}
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/SendJMSMessage.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/SendJMSMessage.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,83 @@
+/*
+ * 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.jmstransacted.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;
+
+/**
+ *
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class SendJMSMessage
+{
+ private QueueConnection connection;
+ private QueueSession session;
+ private Queue queue;
+
+ public void setupConnection() throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+
+ QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) iniCtx.lookup("ConnectionFactory");
+
+ connection = queueConnectionFactory.createQueueConnection();
+
+ queue = (Queue) iniCtx.lookup("queue/quickstart_jms_transacted_Request_gw");
+ session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ connection.start();
+ System.out.println("Connection Started");
+ }
+
+ public void stop() throws JMSException
+ {
+ connection.stop();
+ session.close();
+ connection.close();
+ }
+
+ public void sendAMessage(String msg) throws JMSException {
+
+ QueueSender sender = session.createSender(queue);
+ ObjectMessage objectMsg = session.createObjectMessage(msg);
+
+ sender.send(objectMsg);
+ sender.close();
+ }
+
+
+ public static void main(String args[]) throws Exception
+ {
+ SendJMSMessage sm = new SendJMSMessage();
+ sm.setupConnection();
+ sm.sendAMessage(args[0]);
+ sm.stop();
+ }
+
+}
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/ThrowExceptionAction.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/ThrowExceptionAction.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/jms_transacted/src/org/jboss/soa/esb/samples/quickstart/jmstransacted/test/ThrowExceptionAction.java 2008-01-15 16:20:54 UTC (rev 17869)
@@ -0,0 +1,71 @@
+/*
+ * 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.jmstransacted.test;
+
+import static org.jboss.soa.esb.notification.jms.JMSPropertiesSetter.JMS_REDELIVERED;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.ActionLifecycle;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * ThrowExceptionAction is a simple action that throws an exception <br>
+ * if the message has not been redelivered (first call to this action).
+ * </p>
+ * Note that this class in only intended to be used with the
+ * jms_transacted quickstart.
+ * </p>
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class ThrowExceptionAction implements ActionLifecycle
+{
+ private Logger log = Logger .getLogger( ThrowExceptionAction.class );
+
+ public ThrowExceptionAction( final ConfigTree config ) { }
+
+ /**
+ * Checks if the ESB Messae property 'javax.jms.message.redelivered'
+ * is false, in which case an IllegalArgumentException will be thrown. <br>
+ * This will will cause the message to be redelivered by JMS transaction
+ * handling.
+ *
+ * @param message - ESB Message object
+ * @return Message - unchanged ESB Message Object
+ */
+ public Message process( final Message message )
+ {
+ final Boolean redelivered = (Boolean) message.getProperties().getProperty( JMS_REDELIVERED );
+ log.info("[" +JMS_REDELIVERED + ":" + redelivered + "]" );
+
+ if ( redelivered )
+ return message;
+ else
+ throw new IllegalStateException( "[Throwing Exception to trigger a transaction rollback]");
+ }
+
+ public void processException(final Message message, final Throwable th) { }
+ public void destroy() throws ActionLifecycleException {}
+ public void initialise() throws ActionLifecycleException {}
+
+}
More information about the jboss-svn-commits
mailing list