- 1 Spring Configuration with JMS on an external ActiveMQ Message Broker
- 1.1 ActiveMQ Setup:
- 1.2 Adjusting the Stardust RAD Environment Configuration:a) Basic RAD Project and Test Case
- 1.3 b) ActiveMQ Resource Adapter Libraries
- 1.4 c) Spring JMS Configuration
- 1.5 carnot-spring-jms-context.xml
- 1.6 jencks-amq-jms-context.xml
- 1.7 amq-jms-queues-context.xml
- 1.8 d) Switching Stardust to a JMS-based ForkingService
- 1.9 carnot-spring-context.xml
- 1.10 e) Testing the New Configuration
- 1.11 Note on JNDI Names
Spring Configuration with JMS on an external ActiveMQ Message Broker
Note: The XPDL models, Spring configuration files and JARs referenced in this article can be downloaded from here.
- Download Active MQ from http://activemq.apache.org/download.html
- Unzip the file into ACTIVEMQ_HOME, e.g. into c:\servers\amq
- Start amq using ACTIVEMQ_HOME\bin\activemq.bat
- Find the AMQ console on http://localhost:8161/admin
- Click on the ‘Queues’ menu entry to check the existing queues http://<hostname>:8161/admin/queues.jsp
More information on the use of the ActiveMQ web console can be found at http://activemq.apache.org/web-console.html
Start the server, deploy your process model and check that the RAD setup and the process are working fine. Then stop the server.
Adjusting the Stardust RAD Environment Configuration:
a) Basic RAD Project and Test Case
Set up a regular Stardust RAD project (create a dynamic web project, add the Stardust project facets, create a Tomcat server, create a database, add project to the server). Create a basic Stardust process model with one process definition consisting of a manual trigger and two manual activities.
On the transition that connects the two activities check the ‘Fork on traversal’ check box.
If configured to use JMS, Stardust uses the CarnotSystemQueue for its internal forking. So the ‘Fork on traversal’ usage should result in a message being sent to (and consumed from) this Queue. (If you want to use a more complex example use the attached example process model JMSSyncExample.xpdl. This example also uses the CarnotApplicationQueue). Start the server, deploy your process model and check that the RAD setup and the process are working fine. Then stop the server.
b) ActiveMQ Resource Adapter Libraries
Extract the following files from ACTIVEMQ_HOME\lib\optional\activemq-rar-x.x.x.rar and copy them into your project’s WebContent\WEB-INF\lib folder:
c) Spring JMS Configuration
Add a new folder WebContent\WEB-INF\config\ipp\spring to your project.
Stardust ships example Spring JMS configuration files for an embedded broker in <Stardust Home>\etc\spring\jms. Some of those files can be reused for a setup with an external broker. From <Stardust Home>\etc\spring copy the following files into the newly created folder:
Contains the resource bindings for the three Stardust JMS queues and the connection factory. (If you want to send messages to an additional queue (not only to the CarnotApplicationQueue), e.g. using Stardust’s JMS Application type, then you have to add a corresponding resource binding.)
Bean and alias declaration for the JMS-based forking service
Declaration and configuration of the message listener beans (The number of concurrent message consumers can be configured here)
For usage with an external broker the file needs to be modified.
Remove the dependency on the embedded broker from line 9: depends-on="amqEmbeddedBroker"
Replace the serverURL value “vm://localhost” in line 10 with the URL of the external message broker: “tcp://localhost:61616” (Note that this file contains the server url. If your ActiveMQ server is running on a different machine or port, then you have to adjust the serverURL value accordingly.)
This file also contains the connection pool and connection factory declaration and configuration. If you modify the number of concurrent consumers in carnot-spring-jms-context.xml, then you should also review the connection pool settings (poolMinSize, poolMaxSize) specified in this file.
This file registers the queues and maps the queue names used in carnot-spring-jms-context.xml to the physical queue names used in ActiveMQ.
(If you want to send messages to an additional queue, e.g. using Stardust’s JMS Application type, then you have to register and map the queue here.)
d) Switching Stardust to a JMS-based ForkingService
To make Stardust use the new JMS-based ForkingService declared in carnot-spring-jms-context.xml the old ForkingService needs to be replaced by an alias which points to the new ForkingService. Furthermore the new ForkingService requires a JmsResourceResolver bean which needs to be declared and injected into the Stardust services.
Replace the declaration of the bean carnotForkingService in ipp-portal\WEB-INF\config\ipp\spring\carnot-spring-context.xml (line 93) with an alias:
<alias alias="carnotForkingService" name="jmsForkingService" />
Add a new bean declaration in line 90:
<bean name="carnotJmsResourceResolver" class="com.infinity.bpm.rt.integration.spring.jms.DefaultJmsResourceResolver" />
To inject it into the Stardust service add a property:
<property name="jmsResourceProvider" ref="carnotJmsResourceResolver" /> to the "abstractCarnotService" bean in line 87.
e) Testing the New Configuration
Make sure the ActiveMQ server is running and restart the Tomcat server. Then check if the server started up without errors. If the server started successfully and the JMS configuration was picked up, then you should now see the Stardust queues (viz. CarnotSystemQueue, CarnotDaemonQueue and CarnotApplicationQueue) in the ActiveMQ console. Each queue should have the specified number of consumers (5). After starting a new process instance via the portal and after completing the first activity, you should see that messages are enqueued and dequeued on the CarnotSystemQueue. You can use a JMS Application type or a JMS trigger to process messages on CarnotApplicationQueue (see attached JMSSyncExample.xpdl).
Note on JNDI Names
Use the following settings e.g. in the Stardust JMS Application Type when sending JMS messages from one process instance to another as illustrated in JMSSyncExample.xpdl:
Connection Factory: java:comp/env/jms/CarnotXAConnectionFactory