Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/Deployment/SpringConfigurations

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.


ActiveMQ Setup:

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.

Stardust AMQ1.png

On the transition that connects the two activities check the ‘Fork on traversal’ check box.

Stardust AMQ2.png

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:

  • activemq-core-5.3.2.jar
  • activemq-ra-5.3.2.jar
  • geronimo-j2ee-management_1.0_spec-1.0.jar
  • xbean-spring-3.6.jar
    Stardust AMQ3.png


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:

carnot-spring-jms-context.xml

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)

jencks-amq-jms-context.xml

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.

amq-jms-queues-context.xml

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.)

Stardust AMQ4.png

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.

carnot-spring-context.xml

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.

Stardust AMQ5.png

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
CarnotApplicationQueue: java:comp/env/jms/CarnotApplicationQueue

Copyright © Eclipse Foundation, Inc. All Rights Reserved.